Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Library with advanced .NET reflection APIs.

TODO: The idea is to move all reflection APIs from my other libraries (mainly NJsonSchema) into this general purpose library.


C# 8 nullability reflection

With the TypeWithContext class you can reflect on the nullability of properties, fields, method parameters and return types which will be available when compiling with the C# 8 compiler with the Nullable Reference Types feature enabled.

Given the following test class with some C# 8 nullability annotations (?):

#nullable enable

public class TestClass
    public void Process(Dictionary<string, string?> dictionary)

To reflect on the first parameter's nullability, we can load a TypeWithContext instance and display the nullability of the parameter's types:

var method = typeof(TestClass).GetMethod(nameof(TestClass.Process));
var parameter = method.GetParameters().First();
var parameterTypeWithContext = parameter.GetTypeWithContext();

Console.WriteLine("Dictionary: " + parameterTypeWithContext.Nullability);
Console.WriteLine("Key: " + parameterTypeWithContext.GenericArguments[0].Nullability);
Console.WriteLine("Value: " + parameterTypeWithContext.GenericArguments[1].Nullability);

The output is:

Dictionary: NotNullable
Key: NotNullable
Value: Nullable

For more details, see

XML Docs

TODO: Move into this repo

Other APIs

TODO: Move into this repo

You can’t perform that action at this time.