Advanced reflection utilities for .NET — type parsing, fluent reflection extensions, smart type conversion, and dynamic invocation. Zero external dependencies.
dotnet add package Cocoar.Reflectensions # Core library
dotnet add package Cocoar.Reflectensions.Invoke # + Dynamic method invocation
dotnet add package Cocoar.Reflectensions.ExpandableObject # + Dynamic expandable objectsYou only need Core unless you need invocation or expandable objects. Targets .NET 8.0 and .NET Standard 2.0.
usingCocoar.Reflectensions;// Parse complex type names from stringsvartype=TypeHelper.FindType("Dictionary<string, List<int>>");// Fluent reflection queriesvarmethods=typeof(MyClass).GetMethods().WithName("Process").WithReturnType<Task>().WithParametersOfType(typeof(string));// Smart type conversion — discovers implicit operators automaticallyDateTimedate="2021-03-21T15:50:17+00:00".Reflect().To<DateTime>();intnumber="42".Reflect().To<int>();Trucktruck=camaro.Reflect().To<Truck>();// uses implicit operator- Advanced Type Parsing — Parse
Dictionary<string, List<int>>from strings, with custom type mappings. - Fluent Reflection API — Chainable LINQ-style extensions for types, methods, properties, and parameters.
- Smart Type Conversion —
Reflect().To<T>()with automatic implicit operator detection, Parse/TryParse, IConvertible fallbacks, and optimized hot paths (8x faster for common conversions). - Zero-Cost Abstractions —
ObjectReflection<T>readonly structs with no heap allocations. - Dynamic Invocation — Invoke methods via MethodInfo with automatic parameter type conversion and async support.
- Expandable Objects — Dynamic objects with dictionary-like behavior and
INotifyPropertyChanged. - Zero Dependencies — Completely self-contained, no third-party NuGet packages.
| Package | Description |
|---|---|
| Cocoar.Reflectensions | Core — type helpers, reflection extensions, type conversion, string/enum/DateTime/array utilities |
| Cocoar.Reflectensions.Invoke | Dynamic method invocation with parameter matching |
| Cocoar.Reflectensions.ExpandableObject | Dynamic objects with dictionary-like behavior |
<!-- Before -->
<PackageReferenceInclude="doob.Reflectensions"Version="6.4.2" />
<!-- After -->
<PackageReferenceInclude="Cocoar.Reflectensions"Version="1.0.0" />See the Migration Guide for namespace changes and removed packages.
Contributions welcome! See CONTRIBUTING.md for guidelines.
Apache-2.0 — Copyright 2025 COCOAR e.U.