![]() |
VOOZH | about |
dotnet add package System.Reflection.Context --version 10.0.9
NuGet\Install-Package System.Reflection.Context -Version 10.0.9
<PackageReference Include="System.Reflection.Context" Version="10.0.9" />
<PackageVersion Include="System.Reflection.Context" Version="10.0.9" />Directory.Packages.props
<PackageReference Include="System.Reflection.Context" />Project file
paket add System.Reflection.Context --version 10.0.9
#r "nuget: System.Reflection.Context, 10.0.9"
#:package System.Reflection.Context@10.0.9
#addin nuget:?package=System.Reflection.Context&version=10.0.9Install as a Cake Addin
#tool nuget:?package=System.Reflection.Context&version=10.0.9Install as a Cake Tool
Provides the CustomReflectionContext class to enable adding or removing custom attributes from reflection objects, or adding dummy properties to those objects, without re-implementing the complete reflection model.
Defining a custom Attribute and implement a CustomReflectionContext to add the attribute to specic methods.
using System.Reflection;
using System.Reflection.Context;
[AttributeUsage(AttributeTargets.Method)]
class CustomAttribute : Attribute
{
}
class CustomContext : CustomReflectionContext
{
// Called whenever the reflection context checks for custom attributes.
protected override IEnumerable<object> GetCustomAttributes(MemberInfo member, IEnumerable<object> declaredAttributes)
{
// Add custom attribute to "ToString" members
if (member.Name == "ToString")
{
yield return new CustomAttribute();
}
// Keep existing attributes as well
foreach (var attr in declaredAttributes)
{
yield return attr;
}
}
}
Inspecting the string type with both the default and custom reflection context.
Type type = typeof(string);
// Representation of the type in the default reflection context
TypeInfo typeInfo = type.GetTypeInfo();
Console.WriteLine("\"To*\" members and their attributes in the default reflection context");
foreach (MemberInfo memberInfo in typeInfo.DeclaredMembers)
{
if (memberInfo.Name.StartsWith("To"))
{
Console.WriteLine(memberInfo.Name);
foreach (Attribute attribute in memberInfo.GetCustomAttributes())
{
Console.WriteLine($" - {attribute.GetType()}");
}
}
}
Console.WriteLine();
// Output:
// "To*" members and their attributes in the default reflection context
// ToCharArray
// ToCharArray
// ToString
// ToString
// ToLower
// ToLower
// ToLowerInvariant
// ToUpper
// ToUpper
// ToUpperInvariant
// Representation of the type in the customized reflection context
CustomContext customContext = new();
TypeInfo customTypeInfo = customContext.MapType(typeInfo);
Console.WriteLine("\"To*\" members and their attributes in the customized reflection context");
foreach (MemberInfo memberInfo in customTypeInfo.DeclaredMembers)
{
if (memberInfo.Name.StartsWith("To"))
{
Console.WriteLine(memberInfo.Name);
foreach (Attribute attribute in memberInfo.GetCustomAttributes())
{
Console.WriteLine($" - {attribute.GetType()}");
}
}
}
// Output:
// "To*" members and their attributes in the customized reflection context
// ToCharArray
// ToCharArray
// ToString
// - CustomAttribute
// ToString
// - CustomAttribute
// ToLower
// ToLower
// ToLowerInvariant
// ToUpper
// ToUpper
// ToUpperInvariant
The main type provided by this library is:
System.Reflection.Context.CustomReflectionContextSystem.Reflection.Context is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
| 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 is compatible. 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 is compatible. 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 is compatible. |
| .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 System.Reflection.Context:
| Package | Downloads |
|---|---|
|
Microsoft.Windows.Compatibility
This Windows Compatibility Pack provides access to APIs that were previously available only for .NET Framework. It can be used from both .NET as well as .NET Standard. |
|
|
System.ComponentModel.Composition.Registration
This namespace provides classes that constitute the core of the Managed Extensibility Framework, or MEF. Commonly Used Types: System.ComponentModel.Composition.Registration.RegistrationBuilder System.ComponentModel.Composition.Registration.PartBuilder System.ComponentModel.Composition.Registration.PartBuilder<T> System.ComponentModel.Composition.Registration.ParameterImportBuilder System.ComponentModel.Composition.Registration.ImportBuilder System.ComponentModel.Composition.Registration.ExportBuilder |
|
|
Microsoft.NETCore.UniversalWindowsPlatform
Provides a set of packages that can be used when building Universal Windows applications on .NETCore. d67bd83a075b8b10cb95810568073c1a3211f28b When using NuGet 3.x this package requires at least version 3.4. |
|
|
More
The core library for the "More" framework. |
|
|
Gorgon.Core
Contains common core functionality used by the various Gorgon libraries. |
Showing the top 1 popular GitHub repositories that depend on System.Reflection.Context:
| Repository | Stars |
|---|---|
|
Tape-Worm/Gorgon
A modular set of libraries for .Net that are useful for graphics and video game development.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.0-preview.5.26302.115 | 799 | 6/9/2026 |
| 11.0.0-preview.4.26230.115 | 1,344 | 5/12/2026 |
| 11.0.0-preview.3.26207.106 | 2,267 | 4/14/2026 |
| 11.0.0-preview.2.26159.112 | 1,905 | 3/10/2026 |
| 11.0.0-preview.1.26104.118 | 2,996 | 2/10/2026 |
| 10.0.9 | 22,992 | 6/9/2026 |
| 10.0.8 | 81,148 | 5/12/2026 |
| 10.0.7 | 130,658 | 4/21/2026 |
| 10.0.6 | 41,873 | 4/14/2026 |
| 10.0.5 | 253,090 | 3/12/2026 |
| 10.0.4 | 13,243 | 3/10/2026 |
| 10.0.3 | 138,210 | 2/10/2026 |
| 10.0.2 | 206,768 | 1/13/2026 |
| 10.0.1 | 140,501 | 12/9/2025 |
| 9.0.17 | 2,953 | 6/9/2026 |
| 9.0.16 | 13,735 | 5/12/2026 |
| 9.0.15 | 39,045 | 4/14/2026 |
| 9.0.14 | 63,131 | 3/10/2026 |
| 9.0.13 | 8,893 | 2/10/2026 |
| 9.0.12 | 24,798 | 1/13/2026 |