PerformantReflection 1.0.0
See the version list below for details.
dotnet add package PerformantReflection --version 1.0.0
NuGet\Install-Package PerformantReflection -Version 1.0.0
<PackageReference Include="PerformantReflection" Version="1.0.0" />
paket add PerformantReflection --version 1.0.0
#r "nuget: PerformantReflection, 1.0.0"
// Install PerformantReflection as a Cake Addin #addin nuget:?package=PerformantReflection&version=1.0.0 // Install PerformantReflection as a Cake Tool #tool nuget:?package=PerformantReflection&version=1.0.0
PerformantReflection
A super small library for making Reflection FAST.
The current version only exposes Properties, allowing you to read their values as well as write new values with basically no performance penalty compared to when not using Reflection.
This is archived by Reflecting types just once, and emitting IL to create a new dynamic method matching the getter and setter. Finally a delegate is cached for these dynamic methods, and invoking these delegates has basically no performance penalty.
Installation
I recommend using the NuGet package: PerformantReflection however feel free to clone the source instead if that suits your needs better.
Usage
Simply instantiate an ObjectAccessor
and feed it the object you want to access.
Then you can loop over the Properties
, index into them with ["PropertyName"]
or use TryGetValue
if you're unsure whether the property even exists:
Examples:
class User {
public string Username { get;set; }
}
var user = new User {
Username = "Old username"
};
var accessor = new ObjectAccessor(user);
var existingUsername = accessor.Properties["Username"].GetValue();
accessor.Properties["Username"].SetValue("New username");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- No dependencies.
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 |
---|---|---|
1.8.1 | 34,014 | 5/3/2024 |
1.8.0 | 560 | 4/27/2024 |
1.7.6 | 717 | 3/26/2024 |
1.7.5 | 5,595 | 1/13/2024 |
1.7.4 | 5,600 | 11/11/2023 |
1.7.3 | 584 | 9/20/2023 |
1.7.2 | 862 | 6/29/2023 |
1.7.1 | 590 | 6/12/2023 |
1.7.0 | 164 | 6/12/2023 |
1.6.0 | 202 | 6/9/2023 |
1.5.1 | 434 | 5/31/2023 |
1.5.0 | 161 | 5/30/2023 |
1.4.0 | 195 | 5/9/2023 |
1.3.0 | 2,400 | 10/4/2022 |
1.2.1 | 409 | 7/23/2022 |
1.2.0 | 410 | 6/23/2022 |
1.1.1 | 417 | 6/20/2022 |
1.1.0 | 402 | 6/20/2022 |
1.0.0 | 1,549 | 5/9/2022 |