“Implementing” a non-public interface in .NET Core with DispatchProxy

Reflection is a tremendously powerful concept in .NET, which every C# developer, sooner or later, ends up working with. It is very useful for a lot of perfectly honest scenarios such as for example assembly scanning, type discovery or all kinds of application composability features.

However, it can also be used to circumvent the public API surface of the dependencies you consume – to modify them or gain access to things that the author of your dependency didn’t exactly envision. That said, this process of “hacking around” is very typical for C# development world and, albeit somewhat risky, it sometimes might be the only way out of a coding jam you are in.

Things start to get interesting if you are forced to implement a non-public (for example internal) interface. At that point, the “basic” reflection can’t help anymore, so let’s have a look at how we can do it.

Continue Reading


Dynamic controller routing in ASP.NET Core 3.0

One of the great extensibility points in the routing feature of the older versions of the ASP.NET MVC and ASP.NET Core MVC frameworks was the ability to pick up any route and dynamically point it at a given controller/action.

This had a lot of excellent use cases – as we will briefly see – and since ASP.NET Core 3.0 Preview 7, the feature is actually finally available in ASP.NET Core 3.0 (despite not being mentioned in the official release blog post).

So, let’s have a look at dynamic routing in ASP.NET Core 3.0 together!

Continue Reading


EditorConfig support in OmniSharp and C# extension VS Code

Recently, I blogged about Roslyn analyzers support in OmniSharp and C# extension VS Code and some background on how that feature came together.

Today I am pleased to announce that in the latest OmniSharp release – 1.33.0, where we have shipped another large feature (in fact, the 2nd most requested feature in OmniSharp repo, after, well, analyzers) and that is support for EditorConfig.

Between then, and the time it took me to finally write this post, we actually have 1.34.0 which is even better – and is in fact included in the corresponding release 1.21.0 of the C# extension for VS Code.

More after the jump.

Continue Reading


Building a C# Interactive shell in a browser with Blazor (WebAssembly) and Roslyn

In this post I wanted to show you how to write and embed a C# interactive shell (a REPL – read-evaluate-print-loop) in a browser, on top of WebAssembly.

The REPL will give you fully fledged C# interactive development playground, while still being completely sandboxed in the browser environment. I originally wrote this example for my session at Dotnet Cologne on May 10 this year.

More after the jump.

Continue Reading


Reactive Azure Service Bus messaging with Azure Event Grid

Earlier this month, I wrote an article for my friends over at DotNetCurry. They run a free digital magazine called DNC Magazine, that comes out every 2 months, is free to download and to which I occasionally contribute.

The article is entitled "Reactive Azure Service Bus messaging with Azure Event Grid". In the article, I explore Service Bus integration with Azure Event Grid, and the advantages and scenarios it brings to the table. This is a relatively new feature (launched in the fall of 2018) and I already use it extensively in some of my projects, so I wanted to create sort of a general purpose guide on getting started with this, including having a look at some of the potential use cases.

You can subscribe to the magazine (for free) or download single issues (also for free) here – the article can be found in the latest issue May-June 2019.

And of course big thanks to Suprotim and the entire DNC team for their hard work and bringing this magazine to .NET devs for free for 7 years now.



Elegant way of producing HTTP responses in ASP.NET Core outside of MVC controllers

ASP.NET Core 2.1 introduced support for a little (or, should I say, not at all) documented feature called IActionResultExecutor<T>. It allows us to use some of the action results -those that we are used to from MVC controllers – outside of the controller context, so for example from a middleware component.

Kristian has a great blog post about result executors, that I recommend you check out. From my side, I wanted to show you today a set of extension methods that were recently introduced into WebApiContrib.Core that make working with IActionResultExecutor<T> and in general authoring HTTP endpoints outside of controllers even easier.

Continue Reading


Be careful when manually handling JSON requests in ASP.NET Core

The other day I was reviewing some code in an ASP.NET Core app. It was an HTTP endpoint, written as a simple, lightweight middleware component (so no MVC), that was handling incoming JSON requests.

The endpoint was intended to act as an ingestion point for larger amounts of data, so by definition it was supposed to perform well. I immediately noticed a few things that raised my eyebrow, that I wanted to share with you today.

Continue Reading



Collectible assemblies in .NET Core 3.0

Since the beginning of .NET Core, the one feature that I have been most anxiously waiting for, has been support for collectible assemblies. It took a while (a while!), but finally, in .NET Core 3.0 (at the time of writing 3.0.0-preview-27122-01 from 2018-12-04), it’s here.

It’s going to be a killer functionality, that will support some excellent use cases in .NET Core – especially around application plugins, extensibility and dynamic assembly generation.

Let’s have a quick look at how we can load and unload assemblies in .NET Core.

Continue Reading


Pages:123...22»