CoreSharp.ReflectionCache
8.0.0
dotnet add package CoreSharp.ReflectionCache --version 8.0.0
NuGet\Install-Package CoreSharp.ReflectionCache -Version 8.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CoreSharp.ReflectionCache" Version="8.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CoreSharp.ReflectionCache --version 8.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CoreSharp.ReflectionCache, 8.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CoreSharp.ReflectionCache as a Cake Addin
#addin nuget:?package=CoreSharp.ReflectionCache&version=8.0.0
// Install CoreSharp.ReflectionCache as a Cake Tool
#tool nuget:?package=CoreSharp.ReflectionCache&version=8.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CoreSharp.ReflectionCache
Caching utilities for reflection.
Features
Cachable members
- Types
- Constructors
- Attributes
- Properties
- Fields
- Methods
Installation
Install the package with Nuget.
dotnet add package CoreSharp.ReflectionCache
Examples
var student = GetStudent();
var cachedType = ReflectionCache.GetCachedType<Student>();
var grade = cachedType
.Properties[nameof(Student.Grade)]
.GetValue<Student, double>(student);
grade *= 1.5;
cachedType
.Properties[nameof(Student.Grade)]
.SetValue<Student, double>(student, grade);
var studentDisplayName = cachedType
.Attributes
.OfType<DisplayAttribute>()?.Name;
Benchmarks
dotnet run --project .\src\Benchmarks -c Release
Method | Categories | Mean | Ratio | Allocated |
---|---|---|---|---|
Reflection | Get constructors | 23.054 ns | baseline | 32 B |
Cached | Get constructors | 1.288 ns | 17.93x faster | - |
Reflection | Get attributes | 730.227 ns | baseline | 512 B |
Cached | Get attributes | 1.495 ns | 489.524x faster | - |
Reflection | Get methods | 128.543 ns | baseline | 192 B |
Cached | Get methods | 1.283 ns | 100.295x faster | - |
Reflection | Get properties | 20.764 ns | baseline | 32 B |
Cached | Get properties | 1.507 ns | 13.69x faster | - |
Reflection | Get fields | 20.814 ns | baseline | 32 B |
Cached | Get fields | 1.203 ns | 17.28x faster | - |
Reflection | Get property value | 35.200 ns | baseline | - |
Cached | Get property value | 19.920 ns | 1.77x faster | - |
Reflection | Set property value | 64.437 ns | baseline | - |
Cached | Set property value | 21.387 ns | 3.01x faster | - |
Reflection | Get field value | 49.821 ns | baseline | - |
Cached | Get field value | 52.631 ns | 1.06x slower | - |
Reflection | Set field value | 55.967 ns | baseline | - |
Cached | Set field value | 57.180 ns | 1.02x slower | - |
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.Caching.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Caching.Memory (>= 7.0.0)
- Microsoft.Extensions.Options (>= 7.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.0 | 54 | 6/4/2024 |