Oakrey.Reflection 2.1.0

dotnet add package Oakrey.Reflection --version 2.1.0
                    
NuGet\Install-Package Oakrey.Reflection -Version 2.1.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="Oakrey.Reflection" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Oakrey.Reflection" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.Reflection" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Oakrey.Reflection --version 2.1.0
                    
#r "nuget: Oakrey.Reflection, 2.1.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.
#:package Oakrey.Reflection@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Oakrey.Reflection&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.Reflection&version=2.1.0
                    
Install as a Cake Tool

Oakrey.Reflection

Oakrey.Reflection provides focused helpers for common .NET reflection tasks: loading assemblies, working with enums, finding implementors, creating instances, clearing event handlers, and setting properties dynamically.

Features

  • AppDomainExtensions loads assemblies from the current application directory or a selected directory and skips assemblies that are already loaded.
  • Enums reads enum descriptions, enumerates values, converts enums by name or value, and exposes non-throwing conversion helpers.
  • Events clears typed event delegates and removes field-like event handlers from an object, including inherited events.
  • PropertyReflection sets public properties dynamically with invariant-culture conversion, enum parsing, nullable support, and optional case-insensitive lookup.
  • TypeExtensions finds concrete implementors, caches allow-list searches safely, creates instances, and provides a TryCreateInstanceOfBase helper.

Installation

dotnet add package Oakrey.Reflection

Package Manager Console:

Install-Package Oakrey.Reflection

Examples

Set a property dynamically:

Soldier soldier = new();

bool changed = soldier.TrySetProperty("Rank", "Major");
bool changedCaseInsensitive = soldier.TrySetProperty("rank", "General", ignoreCase: true);

Convert enum values safely:

if (sourceRank.TryConvertByNameTo<TargetRank>(out TargetRank targetRank))
{
    Console.WriteLine(targetRank);
}

Find implementors in selected assemblies:

List<Type> commands = typeof(ICommand).GetImplementors(["MyCompany.MyApp"]);

Create an instance without throwing:

if (typeof(MyService).TryCreateInstanceOfBase<IMyService>(out IMyService? service))
{
    service.Run();
}

Clear field-like event subscriptions:

publisher.UnsubscribeAllEventHandlers();

Notes

  • Reflection can bypass normal compile-time guarantees. TrySetProperty therefore rejects null for non-nullable properties when nullable metadata is available.
  • GetImplementors(type, allowList) filters by assembly full name and returns a defensive copy of cached results.
  • LoadAssemblies catches common load failures such as BadImageFormatException, FileLoadException, and FileNotFoundException and writes diagnostics to trace output.

Requirements

  • .NET 10 or higher

Project Information

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Oakrey.Reflection:

Package Downloads
Oakrey.ValueSystem.Base

The Oakrey.ValueSystem library provides a framework for managing and transforming values in .NET applications. It supports various value types, content transformations, and value sources, enabling developers to build dynamic and data-driven applications.

Oakrey.Applications.ViewModels

Base ViewModel utilities for MVVM/.NET applications. Provides IAutoConfigurable marker interfaces (singleton, scoped, transient) and an IServiceCollection extension that automatically discovers and registers all ViewModels via reflection — no manual DI wiring required.

Oakrey.Peak.Lin.Driver

A .NET 10 high-level LIN driver built on Oakrey.Peak.Lin.Wrapper. Exposes IPeakLinClient and ISlaveClient with Rx observable streams for received messages and bus state changes. Supports master and slave operation modes, timer-based polling, frame publisher/subscriber configuration, and hardware discovery for Peak LIN hardware on Windows.

Oakrey.UHD

A .NET P/Invoke wrapper for the Ettus Research UHD (USRP Hardware Driver) native library. Enables TX streaming, frequency and gain tuning, stream metadata handling, and structured logging via IObservable for USRP software-defined radio devices.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 157 7/13/2026
2.0.1 297 5/21/2026
2.0.0 585 11/13/2025
1.1.0 357 11/13/2025
1.0.1 293 9/26/2025
1.0.0 634 4/16/2025