Benchmark results comparing UnsafeAccessor to reflection and direct access. Results show zero overhead for UnsafeAccessor compared to direct access, both clocking in at aroun 0ns, while reflection access takes around 36 ns, or 21 ns when the method info is cached.
| |

.NET 8 Performance: UnsafeAccessor vs. Reflection

In a previous article we covered how to access private members using UnsafeAccessor. This time around, we want to look at it’s performance compared to Reflection, and to see whether it’s truly zero-overhead or not. We’re going to do four benchmarks. If you want to run the benchmarks yourself, you have the code below: Benchmark…

|

How to access private members without reflection in C#

Reflection allows you to obtain type information at runtime and to access private members of a class using that information. This can be particularly useful when dealing with classes outside of your control – provided by a third-party package. While powerful, reflection is also very slow, which is one of the main deterrents in using…

How to fix: MissingPluginException – No implementation found for method getAll

This is quite a common issue that usually occurs in flutter release builds. More often than not the issue is caused by ProGuard stripping away some required APIs at build time, leading to missing implementation exceptions such as the one below. That being said, there are actually multiple possible causes to this issue, as such…

Usage example of Experimental attribute introduced in C# 12.
| |

C# – How to mark features as experimental

Starting with C# 12, a new ExperimentalAttribute is introduced allowing you to mark types, methods, properties or assemblies as being experimental features. This will trigger a compiler warning during usage which can be disabled using a #pragma tag. The Experimental attribute requires a diagnosticId parameter to be passed in the constructor. That diagnostic ID will…

Visual representation of a decillion: a 1 followed by 33 zeros.

What comes after decillion?

This is quite a frequent question. You’ve got: But what comes after decillion? The answer is: undecillion. An undecillion, has 36 zeroes. That’s a lot of zeroes: 1,000,000,000,000,000,000,000,000,000,000,000. But there’s more. If you look past the undecillion, you’ve got: Interested in how long it would take a PC to count to a trillion? Check out this…

|

System.Text.Json – How to modify existing type info resolver

There are some situations in which creating a whole new IJsonTypeInfoResolver will seem overkill, when the default (or any other already defined) type info serializer could do the job with only one or two small modifications. Until now, you could play with the DefaultJsonTypeInfoResolver.Modifiers property for the default type info resolver, but you didn’t have…

|

JsonNode – .NET 8 API updates

Part of .NET 8, JsonNode and JsonArray get a few new additions to their API. We’ve already covered deep copy and deep equality in an earlier article, but there’s more. GetValueKind Returns the JsonValueKind of the current instance. GetPropertyName Returns property name of the current node from the parent object. Throws an InvalidOperationException if the…

|

System.Text.Json – Disable reflection-based serialization

Starting with .NET 8 you can disable the default reflection-based serializer that comes with System.Text.Json. This can be useful in trimmed and native AOT applications where you don’t want to include the reflection components in your build. You can enable this feature by setting the JsonSerializerIsReflectionEnabledByDefault property to false in your .csproj file. As a…