Skip to content

Releases: cocoar-dev/Cocoar.Reflectensions

v1.0.2

Choose a tag to compare

@windischb windischb released this 10 Apr 20:01

Bug Fix: Type compatibility check failed for object target type

What was broken

TypeExtensions.IsImplicitCastableTo() did not handle the fundamental .NET rule that every type is implicitly assignable to System.Object. This caused
InvokeHelper.InvokeMethodAsync<object>() to throw:

Method returns a Type of 'IAsyncEnumerable`1[System.Object]' which is not implicitly castable to System.Object

The bug affected any method returning an interface type (e.g. IAsyncEnumerable<T>, IEnumerable<T>, IDisposable), because interfaces have no BaseType in .NET
reflection metadata — so InheritFromClass<object>() returned false, and none of the other checks (ImplementsInterface, IsImplicitCastableTo, implicit operators)
cover the object case either.

Root cause

This is a follow-up to the v1.0.1 fix for NotEquals<T>(). In v1.0.0, NotEquals<T>() always returned false, which inadvertently skipped the entire type compatibility
check. The v1.0.1 fix made the check work correctly — but exposed this gap.

Fix

Added an early return if (to == typeof(object)) return true in IsImplicitCastableTo().

v1.0.1

Choose a tag to compare

@windischb windischb released this 25 Mar 13:50

fix: correct NotEquals() method to properly compare types

v1.0.0 - First Official Release

Choose a tag to compare

@windischb windischb released this 17 Oct 09:57

🎉 Cocoar.Reflectensions v1.0.0

We're excited to announce the first stable release of Cocoar.Reflectensions - a powerful and intuitive .NET reflection library that makes working with reflection simple and safe.

🔄 Migration from doob.Reflectensions

This package replaces and supersedes doob.Reflectensions. If you're currently using doob.Reflectensions, please migrate to Cocoar.Reflectensions for continued support and updates.

Migration is straightforward:

  1. Remove the doob.Reflectensions package
  2. Install Cocoar.Reflectensions
  3. Update namespace imports from doob.Reflectensions to Cocoar.Reflectensions

✨ What's Included

Core Features

  • Type Casting & Conversion - Fluent APIs for safe type conversions with To<T>(), As<T>(), and Is<T>()
  • Property & Field Reflection - Easy access to object members with .GetValue(), .SetValue(), and batch operations
  • Method Invocation - Simplified method calling through reflection
  • Attribute Inspection - Streamlined attribute reading and validation
  • Collection Extensions - Enhanced LINQ-like operations for common collection tasks
  • String Utilities - Powerful string manipulation and validation helpers
  • DateTime Extensions - Unix timestamp conversions, kind management, and more

Quality & Performance

  • 166 passing tests with full CI/CD validation
  • Nullable reference types enabled for enhanced null safety
  • Zero warnings - clean, maintainable codebase
  • XML documentation for full IntelliSense support
  • Performance optimized with hot paths for common scenarios
  • Cross-platform - tested on Windows and Linux

Developer Experience

  • Intuitive fluent API with .Reflect() wrapper to avoid extension method pollution
  • Comprehensive IntelliSense documentation
  • Strong typing with nullable annotations
  • Minimal dependencies (no JSON libraries required)

📦 Installation

dotnet add package Cocoar.Reflectensions

🚀 Quick Start

using Cocoar.Reflectensions;

// Type conversion
var number = "123".Reflect().To<int>();
var date = "2024-01-01".Reflect().To<DateTime>();

// Property access
var value = myObject.Reflect().GetValue("PropertyName");
myObject.Reflect().SetValue("PropertyName", newValue);

// Attribute inspection
var hasAttribute = myType.Reflect().HasAttribute<MyAttribute>();
var attribute = myType.Reflect().GetAttribute<MyAttribute>();

// Collection operations
var merged = dict1.Merge(dict2);
var formatted = list.ToCommaSeparatedString();

🔗 Resources

📄 License

Licensed under the MIT License - see LICENSE for details.

🙏 Acknowledgments

Special thanks to all contributors and early adopters who helped shape this library!


Ready to simplify your reflection code? Install Cocoar.Reflectensions today and experience the difference!