Overview
Cuemon.Extensions.Reflection adds extension methods to Assembly, MemberInfo, PropertyInfo, and Type for reflection tasks that otherwise require repetitive filtering or lower-level decorator calls from Cuemon.Reflection. It turns assembly version inspection, attribute checks, auto-property detection, and full hierarchy traversal into direct framework-style extension calls.
The package is strongest when you need reflection over inherited members or type graphs instead of one-off lookups. It also includes helpers for embedded resources and assembly-qualified type names so metadata-driven code can stay close to the standard reflection surface.
Key APIs
GetAssemblyVersion, GetFileVersion, and GetProductVersion read version metadata from an Assembly and return VersionResult, which lets callers distinguish plain assembly versions from informational product versions such as semantic versions with alphanumeric suffixes.
IsDebugBuild answers whether an Assembly was built with debug symbols, which is useful when diagnostics or tooling behavior needs to branch on the build flavor of the loaded assembly.
HasAttributes checks whether a MemberInfo is decorated with any of the supplied attribute types, so callers can query types, fields, properties, and methods without manually enumerating custom attributes.
IsAutoProperty detects whether a PropertyInfo represents an automatic property implementation, which helps when generators, mappers, or inspection code need to treat compiler-backed properties differently from custom accessors.
GetAllProperties, GetAllFields, GetAllEvents, and GetAllMethods traverse the full inheritance chain of a type and accept an optional Action<MemberReflectionOptions> so you can shape how members are gathered without hand-rolling repeated reflection loops.
GetInheritedTypes, GetDerivedTypes, and GetHierarchyTypes expose ancestor, descendant, and combined type traversal from a single starting Type, making hierarchy discovery easier than stitching together multiple reflection queries.
GetRuntimePropertiesExceptOf<T> returns the runtime properties of a type while excluding the properties declared on a specified base type, which is useful when you need to isolate the contract introduced by a derived type.
GetEmbeddedResources loads embedded resources from the assembly behind a Type and applies a ManifestResourceMatch rule, so callers can search by exact name, partial name, or extension through one entry point.
ToFullNameIncludingAssemblyName formats a type as its fully qualified name plus the simple assembly name, which is handy for diagnostics, serialization metadata, and storing reflection-based identifiers.
Basic usage
using System;
using System.Linq;
using Cuemon.Extensions.Reflection;
using Codebelt.Extensions.Xunit;
using Xunit;
namespace Contoso.Reflection.Tests;
public class ExceptionMetadataTest : Test
{
public ExceptionMetadataTest(ITestOutputHelper output) : base(output)
{
}
[Fact]
public void ShouldListOnlyPropertiesIntroducedByDerivedException()
{
var propertyNames = typeof(DomainValidationException)
.GetRuntimePropertiesExceptOf<AggregateException>()
.Select(pi => pi.Name)
.ToArray();
TestOutput.WriteLines(propertyNames);
Assert.Equal(new[] { "Code", "CodePhrase" }, propertyNames);
}
private sealed class DomainValidationException : AggregateException
{
public int Code { get; } = 422;
public string CodePhrase { get; } = "validation-failed";
}
}
Use this pattern when you need reflection output that focuses on members introduced by your own derived type instead of the full inherited surface. It matters because the package removes repetitive exclusion logic and keeps metadata-driven code aligned with the contract you actually own.
Installation
dotnet add package Cuemon.Extensions.Reflection
Usage guidance
Adopt this package when your code already works with System.Reflection but repeatedly needs inherited member traversal, assembly version inspection, or member filtering expressed as extension methods. If you only need a direct framework reflection call or you want the lower-level reflection abstractions behind these helpers, stay with System.Reflection or use Cuemon.Reflection directly.
Family packages
- 🌐Cuemon.AspNetCore
- 🏭Cuemon.AspNetCore.App
- 🌐Cuemon.AspNetCore.Authentication
- 🌐Cuemon.AspNetCore.Mvc
- 🌐Cuemon.AspNetCore.Razor.TagHelpers
- 📦Cuemon.Core
- 🏭Cuemon.Core.App
- 🗄️Cuemon.Data
- 🗄️Cuemon.Data.Integrity
- 🗄️Cuemon.Data.SqlClient
- 🩺Cuemon.Diagnostics
- 🌐Cuemon.Extensions.AspNetCore
- 🌐Cuemon.Extensions.AspNetCore.Authentication
- 🌐Cuemon.Extensions.AspNetCore.Mvc
- 🌐Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json
- 🌐Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml
- 🌐Cuemon.Extensions.AspNetCore.Mvc.RazorPages
- 🌐Cuemon.Extensions.AspNetCore.Text.Json
- 🌐Cuemon.Extensions.AspNetCore.Xml
- 📦Cuemon.Extensions.Collections.Generic
- 📦Cuemon.Extensions.Collections.Specialized
- 📦Cuemon.Extensions.Core
- 🗄️Cuemon.Extensions.Data
- 🗄️Cuemon.Extensions.Data.Integrity
- 📦Cuemon.Extensions.DependencyInjection
- 🩺Cuemon.Extensions.Diagnostics
- 🏗️Cuemon.Extensions.Hosting
- 📦Cuemon.Extensions.IO
- 📦Cuemon.Extensions.Net
- 📦Cuemon.Extensions.Runtime.Caching
- 📝Cuemon.Extensions.Text
- 📝Cuemon.Extensions.Text.Json
- 📦Cuemon.Extensions.Threading
- 📦Cuemon.Extensions.Xml
- 📦Cuemon.IO
- ⚙️Cuemon.Kernel
- 📦Cuemon.Net
- 📦Cuemon.Resilience
- 📦Cuemon.Runtime.Caching
- 🔐Cuemon.Security.Cryptography
- 📦Cuemon.Threading
- 📦Cuemon.Xml