![]() |
VOOZH | about |
dotnet add package Namotion.Reflection --version 3.5.1
NuGet\Install-Package Namotion.Reflection -Version 3.5.1
<PackageReference Include="Namotion.Reflection" Version="3.5.1" />
<PackageVersion Include="Namotion.Reflection" Version="3.5.1" />Directory.Packages.props
<PackageReference Include="Namotion.Reflection" />Project file
paket add Namotion.Reflection --version 3.5.1
#r "nuget: Namotion.Reflection, 3.5.1"
#:package Namotion.Reflection@3.5.1
#addin nuget:?package=Namotion.Reflection&version=3.5.1Install as a Cake Addin
#tool nuget:?package=Namotion.Reflection&version=3.5.1Install as a Cake Tool
Storage | Messaging | Reflection
👁 Azure DevOps
👁 Azure DevOps
👁 Nuget
👁 Discord
<img align="left" src="https://raw.githubusercontent.com/RicoSuter/Namotion.Reflection/master/assets/Icon.png" width="48px" height="48px">
.NET library with advanced reflection APIs like XML documentation reading, Nullable Reference Types (C# 8) reflection and string based type checks.
This library is mainly used in NJsonSchema and NSwag.
Inheritance hierarchy:
Type object which does not have a context
Type with contextual attributes (e.g. property attributes)
Behavior:
CachedType instance is cached per Type, ParameterInfo or MemberInfo.Type is Nullable<T> then T is unwrapped and stored in the Type property - the original type can be accessed with the OriginalType property.With the ContextualType 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 MyClass
{
public void MyMethod(Dictionary<string, string?> dictionary)
{
}
}
To reflect on the first parameter's nullability, we can load a ContextualType instance and display the nullability of the parameter's types:
using Namotion.Reflection;
var method = typeof(MyClass).GetMethod(nameof(MyClass.MyMethod));
var parameter = method.GetParameters().First();
var contextualParameter = parameter.ToContextualParameter();
Console.WriteLine("Dictionary: " + contextualParameter.Nullability);
Console.WriteLine("Key: " + contextualParameter.GenericArguments[0].Nullability);
Console.WriteLine("Value: " + contextualParameter.GenericArguments[1].Nullability);
The output is:
Dictionary: NotNullable
Key: NotNullable
Value: Nullable
For more details, see https://blog.rsuter.com/the-output-of-nullable-reference-types-and-how-to-reflect-it/
Methods:
It is important to understand that Nullable Reference Types is a compiler feature only and the .NET runtime does not do any checks when your app is running. Consider the following class:
public class Person
{
public string FirstName { get; set; }
public string? MiddleName { get; set; }
public string LastName { get; set; }
}
Inside your application you'll get warnings when you forget to set the FirstName. However when data is coming from outside (e.g. via reflection, serialization, etc.) you could end up with invalid objects. This JSON.NET call throws no exception but will create an invalid object:
var person = JsonConvert.DeserializeObject<Person>("{}");
Call the EnsureValidNullability() extension method which throws an InvalidOperationException when the object is in an invalid state:
person.EnsureValidNullability();
Methods:
Methods:
Type|MemberInfo.GetXmlDocsSummaryAsync():
Type|MemberInfo.GetXmlDocsRemarksAsync():
ParameterInfo.GetXmlDocsAsync(): Gets the parameter's description
ParameterInfo.GetXmlDocsElementAsync(): Gets the XElement of the given type
... and more
XmlDocs.ClearCache()
This functionality can also be used with Cecil types with the Namotion.Reflection.Cecil package.
Methods:
IEnumerable extensions
Object extensions
Type extensions
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Namotion.Reflection:
| Package | Downloads |
|---|---|
|
NJsonSchema
JSON Schema reader, generator and validator for .NET |
|
|
NSwag.Core
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript |
|
|
NSwag.Generation
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript |
|
|
NSwag.AspNetCore
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript |
|
|
NSwag.Generation.AspNetCore
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript |
Showing the top 17 popular GitHub repositories that depend on Namotion.Reflection:
| Repository | Stars |
|---|---|
|
neo-project/neo
NEO Smart Economy
|
|
|
RicoSuter/NJsonSchema
JSON Schema reader, generator and validator for .NET
|
|
|
dotnetcore/sharding-core
high performance lightweight solution for efcore sharding table and sharding database support read-write-separation .一款ef-core下高性能、轻量级针对分表分库读写分离的解决方案,具有零依赖、零学习成本、零业务代码入侵
|
|
|
notifo-io/notifo
Multi channel notification service for collaboration tools, e-commerce, news service and more.
|
|
|
flyingpie/windows-terminal-quake
Enable Quake-style dropdown for (almost) any application.
|
|
|
Coldairarrow/EFCore.Sharding
Database Sharding For EFCore
|
|
|
zarusz/SlimMessageBus
Lightweight message bus interface for .NET (pub/sub and request-response) with transport plugins for popular message brokers.
|
|
|
bilal-fazlani/commanddotnet
A modern framework for building modern CLI apps
|
|
|
dymproject/purest-admin
Purest Admin 是一套真正意义上前后端分离、深度适配企业RBAC权限体系的通用后台管理系统。依托现代化 .NET 10 技术栈、Vue3 生态前端、强大的工作流引擎,力求降低业务框架搭建门槛,实现一站式、敏捷、高可扩展的企业级后台管理平台。
|
|
|
RicoSuter/VisualJsonEditor
A JSON schema based file editor for Windows.
|
|
|
jburzynski/TypeGen
Single-class-per-file C# to TypeScript generator
|
|
|
asyncapi/saunter
Saunter is a code-first AsyncAPI documentation generator for dotnet.
|
|
|
sisk-http/core
Sisk's request and response processor mainframe source code.
|
|
|
admin-shell-io/aasx-package-explorer
C# based viewer / editor for the Asset Administration Shell
|
|
|
eclipse-aaspe/package-explorer
AASX Package Explorer
|
|
|
DigitalPlatform/dp2
Integrated Library System / 图书馆集成系统
|
|
|
unchase/Unchase.OpenAPI.Connectedservice
:scroll: Visual Studio extension to generate OpenAPI (Swagger) web service reference.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.5.1 | 127,190 | 4/8/2026 |
| 3.5.0 | 2,597,698 | 3/23/2026 |
| 3.4.3 | 14,524,007 | 9/15/2025 |
| 3.4.2 | 12,777,353 | 4/28/2025 |
| 3.4.1 | 73,519 | 4/28/2025 |
| 3.4.0 | 73,544 | 4/28/2025 |
| 3.3.0 | 4,413,821 | 3/7/2025 |
| 3.2.0 | 23,072,931 | 11/19/2024 |
| 3.1.1 | 45,406,045 | 12/8/2023 |
| 3.1.0 | 920,213 | 10/31/2023 |
| 3.0.1 | 103,772 | 10/26/2023 |
| 3.0.0 | 430,023 | 8/20/2023 |
| 2.1.2 | 21,668,473 | 5/3/2023 |
| 2.1.1 | 1,490,825 | 9/18/2022 |
| 2.1.0 | 21,281,749 | 9/16/2022 |
| 2.0.10 | 51,880,180 | 1/27/2022 |
| 2.0.9 | 6,822,773 | 12/15/2021 |
| 2.0.8 | 4,096,316 | 12/9/2021 |
| 2.0.7 | 282,840 | 12/7/2021 |
| 2.0.6 | 79,795 | 12/5/2021 |