tabs ↹ over ␣ ␣ ␣ spaces

by Jiří {x2} Činčura

Using string interpolation for ADO.NET parameters

16 Aug 2017 C#, SQL

I was reading the announcement about Entity Framework Core 2 the other morning and saw “String interpolation in raw SQL methods” paragraph. This was already in preview(s) and I kind of took it as granted, not thinking about how it’s done or what it is doing. Not this time. Somehow my curiosity kicked in and I decided to create same feature and maybe do something with it.

Of course, I could peek into sources, but I decided to use the idea, but build it myself from scratch. I like the idea of using already existing feature from C# and then using for different, but reasonable, purpose. String interpolation and SQL parameters are exactly this.

Replacing assembly while the application is running (aka AppDomains are slow)

25 Jul 2017 .NET, C#

As I said in previous post I had to drop AppDomains from my solution to allow replacing assembly while the FbNetExternalEngine is running. Calls across AppDomains are simply too slow (read: I can’t make it fast enough. 😉) for this kind of project. Why I even needed AppDomains? The specs are simple: Allow assembly replacing (rewrite) while it’s loaded in Firebird via my FbNetExternalEngine. Can it be solved without AppDomains?

FbNetExternalEngine performance numbers

24 Jul 2017 .NET, Firebird

Over the last few days I was working on performance of FbNetExternalEngine. Basically doing all I can to make it execute the code quickly as possible. OK, maybe not all I can, but something that gives biggest gain while being able to program it in a reasonable timeframe, because there’s always room for more.

Head- and Tail-like methods in C# (and F# and Python and Haskell)

27 Jun 2017 C#, F#, Functional programming, Haskell, Python

While writing previous post I realized the deconstruction to tuple can be added to any type. As far as compiler is concerned the Deconstruct method needs to exist, doesn’t matter whether it’s an extension method or instance one. That means I can write a Head- and Tail-like methods in C# with nice syntax. I also dusted off my Haskell knowledge and wrote the same logic there for comparison. And then I did it in Python and F# as well. Brace yourself for a true polyglot post.

Nice succinct syntax for tuple deconstruction

25 Jun 2017 C#

As I’m playing more and more with tuple in C# 7 to find out where this is useful and where it falls short and actually bites back later on. And during this I kind of by blind luck discovered more succinct syntax for deconstruction. I reminds me Python, which I like.

WUG: Nejčastější chyby při použití O/R mapperu (Zlín + Praha)

19 Jun 2017 Entity Framework, Presentations & Speaking

O/R mappery jsou výborný sluha, ale špatný pán. Abych tak trochu parafrázoval známé přísloví. David Gešvindr dobře zachytil, že v rámci různých Entity Framework přednášek apod. trousím, často i jako odpovědi na otázky z davu, různá doporcučení co nedělat (nebo co naopak dělat). Drobečky jsou fajn, ale dát to trochu do kupy a celkově sjednotit není od věci. A o tom je tato přednáška.

Example of optimizations “breaking” multithreaded code

11 Jun 2017 .NET, .NET Core, C#, Multithreading/Parallelism/Asynchronous/Concurrency

I realized I have some pieces of code to show some specific behavior, mostly around threading and synchronization, all over my notes. Some of these pieces may be 10+ years old. I use these pieces during my “threading/parallel/async” course, but why not to share it publicly. Maybe I’ll stumble on it after some years, maybe .NET will be history, and it will be interesting to re-read and re-think the code. The code isn’t unique or something where I’m the first to realize it. It’s really just an example code.

Today I have a small example that shows how optimizations (compiler, JIT, ...) can make multithreaded code behave differently than expected. I don’t remember where I’ve seen the code. Some book or blog post from - I guess - Jeffrey Richter. Or maybe Joe Duffy or Stephen Toub or ... These guys are very smart.

How much of objects sharing is there in LXSS?

2 Jun 2017 .NET Core, LXSS, Windows

I’m playing a little with Windows Subsystem for Linux (also known as WSL or LXSS), mostly to see what’s what and how it might be useful for my everyday usage. As I was reading some articles on how it’s implemented and how it works inside I’ve got an idea. What if I create an application, in .NET Core, that uses some resource from kernel and I execute it both regular Windows session and in LXSS, will this resource be shared across?

Getting closer to the “v1” with external procedures in Firebird in .NET

25 May 2017 .NET, C#, Databases in general, Firebird, SQL

It’s been a while since the last time I blogged about FbNetExternalEngine. That doesn’t mean there was nothing happening. I was slowly working on it (really slowly, because of ... time), plus some companies took interest in it, confirming it’s worth working on it and providing some feedback or nice-to-have features wishes (feel free to share your ideas in comments). So what’s really new?

Checking for big blocks of comments in code (NDepend, Roslyn)

21 May 2017 .NET, C#, NDepend, Roslyn

I don’t like comments. Most of the time information in comments is wrong and obsolete. I believe the code should be clear as a fresh snow. Most of the time. Some design decisions or measurements can be commented, but not the code itself. If it needs commenting, it should be rewritten.

One cardinal sin I can’t live with is commenting out code, just because you might need it later or because it’s being “refactored”. Nonsense. Sadly, this is done so often in a team where I’m responsible for code quality. Lucky me.

Thus, to prevent it I decided to test for big chunks of comments in the codebase using a code. More specifically NDepend or Roslyn. Whatever will do the job.

Exploring the finalizers’ timeout

16 May 2017 .NET, .NET Core

I don’t know why, but last week I decided to check whether the 2 seconds timeout for single finalizer and 40 seconds for all finalizers at the end of .NET application are still in place. If you haven’t heard about these two numbers ever, don’t worry. Because if you’ve ever hit one or the other you’ve been doing something seriously wrong. That’s how I’ve got to learn about it as well. 😉

Changes in new FbRemoteEvent

7 May 2017 .NET, C#, Firebird, SQL

The implementation of events via the FbRemoteEvent class was nor wrong nor correct. It was correct in a way that it did what it should do, but it was not clean and it was not guiding the developer into the pit of success, you had to know how it works under the covers to work with it properly. I decided to rewrite the implementation, fix some issues and more importantly give it more high-level feel, where you’re actually using some infrastructure, instead of just close the raw implementation.