Visual Studio 2017 tips

  • We can specify a ,nq in debugger display attribute to prevent VS to visualize quotes surrounding string value:

[DebuggerDisplay(“Name: {FullName,nq}”)]

  • We can use DebuggerDisplayAttribute as assembly attribute to decorates types from other assemblies:
[assembly: DebuggerDisplay("Host: {HostName}", Target = typeof(IPHostEntry))]

Great tips from 7 Hidden Gems in Visual Studio 2017 | The Visual Studio Blog



X.509 certificates in .NET

Great summary: Eight tips for working with X.509 certificates in .NET – Paul Stovell.

Also found:

How to implement a formatter in Asp.Net Core

How to handle raw data in request body either manually or by registering a custom InputFormatter: Accepting Raw Request Body Content in ASP.NET Core API Controllers – Rick Strahl’s Web Log.

One big issue with automatic conversion between content body and an action parameter is how to handle too big content (in case of DOS for example). Reading any content body into a byte array could be very dangerous for server health in case of a large body.  This also prevents an always preferable handling using the streamed way.

.Net Core 2.0: first step to GC customization

.Net Core 2.0 have a new interesting feature: the ability to customize GC. It’s not already in standard version, we must compiled a custom CoreCLR version but it’s in source code now!

This post describes how to build a GC version doing nothing (ie with no garbage collection at all). This can be used in very specific apps and as the first step to a custom GC.

Yet another proof that .Net Core is moving in the right  direction.

Zero Garbage Collector for .NET Core – TooSlowException

Extension to Razor HtmlHelper

How to export a C# enum:

public enum AssetStatusEnum


    var assetStatusEnum = {"Free":0,"Reserved":1,"Inactive":2,"UnderMaintenance":3}

In implementing an extension method:

public static class HtmlEnumExtensions
    public static MvcHtmlString EnumToString<T>(this HtmlHelper helper)
        var values = Enum.GetValues(typeof(T)).Cast<int>();
        var enumDictionary = values.ToDictionary(value => Enum.GetName(typeof(T), value));
        return new MvcHtmlString(JsonConvert.SerializeObject(enumDictionary));

and using it like this:

    var assetStatusEnum = @(Html.EnumToString())


Converting C# enums to JavaScript | Gunnar Peipman – Programming Blog