Skip to content

Cocoar.Reflectensions

.NET 8.0.NET Standard 2.0License: Apache 2.0NuGet

Advanced reflection utilities for .NET — type parsing, fluent reflection extensions, smart type conversion, and dynamic invocation. Zero external dependencies.

Documentation

Install

dotnet add package Cocoar.Reflectensions # Core library
dotnet add package Cocoar.Reflectensions.Invoke # + Dynamic method invocation
dotnet add package Cocoar.Reflectensions.ExpandableObject # + Dynamic expandable objects

You only need Core unless you need invocation or expandable objects. Targets .NET 8.0 and .NET Standard 2.0.

Quick Start

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

Key Features

  • 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 ConversionReflect().To<T>() with automatic implicit operator detection, Parse/TryParse, IConvertible fallbacks, and optimized hot paths (8x faster for common conversions).
  • Zero-Cost AbstractionsObjectReflection<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.

Packages

PackageDescription
Cocoar.ReflectensionsCore — type helpers, reflection extensions, type conversion, string/enum/DateTime/array utilities
Cocoar.Reflectensions.InvokeDynamic method invocation with parameter matching
Cocoar.Reflectensions.ExpandableObjectDynamic objects with dictionary-like behavior

Migration from doob.Reflectensions

<!-- 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.

Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

License

Apache-2.0 — Copyright 2025 COCOAR e.U.

About

A comprehensive .NET library for simplified reflection, type parsing, dynamic invocation, and intelligent type conversion

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages