“Disecting the new() constraint” is very instructive: new() constraint has a big performance impact and we must know its implementation to understand why ctor exceptions are wrapped to a TargetInvocationException.
Dissecting the new() constraint in C#: a perfect example of a leaky abstraction – Dissecting the code
By the way, in same blog post, I’ve discovered that some well known static functions can be custom replaceable. It means you can locally redefined them. System.Activator.CreateInstance<T> is replaced by a faster one.
Beware, this is a completly not documented behavior than can be theoretically remove any time. Just to mitigate previous remark, this undocumented behavior is so important survived the Roslyn transition.
Starting from .Net 4.5 (but I was not aware):
Starting from .NET 4.5 you can use ExceptionDispatchInfo class to rethrow an arbitrary exception object (an inner exception in this case) without altering the exception’s stack trace
via Dissecting the new() constraint in C#: a perfect example of a leaky abstraction – Dissecting the code
For those lock down with plain old .Net 4.x, a MemorySteam replacement for reducing GC pressure:
A library to provide pooling for .NET MemoryStream objects to improve application performance.
This is a small (55 KB) library (.Net 4.5.2) for recording histograms and displaying them as Console tabular date or as .hgrm files (html viewable or at http://hdrhistogram.github.io/HdrHistogram/plotFiles.html):
I’ve really understood all this stuff when reading: corefx/net-platform-standard.md at master · dotnet/corefx. A must!
I don’t know JsonPatch before reading this post from Ben Foster.
It’s a normalized way (RFC 6902) of specifying, in json format, patch to a json document. You write operations for add, remove, replace, copy, move and test.
Main use is for reduce http request size (using http PATCH) but I think json is not necessarily the good format when request size matter (I like protobuf but I don’t know if a patch mechanism exist for it).
And in Ben Foster’s blog entry, I also discovers that .Net core already have an aspnet/JsonPatch (available for .Net 4.5.1). It’s easy to use in http server or outside. You creates a JsonPatchDocument with a list of operation, you can add yours then you apply them with a ApplyTo. Json.Net is used internally and we can add a custom IContractResolver.
Source: How to perform partial resource updates with JSON Patch and ASP.NET Core – Ben Foster
AsyncFriendlyStackTrace try to remove async related stuff from stack traces generated by async code: aelij/AsyncFriendlyStackTrace.
News from my corner of the Visual Studio Project & Build team, programming tips, and solutions to common programming issues.
Source: When TPL Task continuations are inlined | Andrew Arnott
In .Net [1.1 .. 4.6, Silverlight], each literal string value is garantee to exist only once in memory. Cache used to implement this can be access and used through String.Intern(String) static method (String.Intern Method (String) (System)).
damianh/LibLog, a fresh attempt to an old problem: how to log from library without forcing log library dependencies.
Discovered thanks to scriptcs blog: Deprecating Common.Logging