com.IvanMurzak.ReflectorNet 0.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package com.IvanMurzak.ReflectorNet --version 0.2.1
                    
NuGet\Install-Package com.IvanMurzak.ReflectorNet -Version 0.2.1
                    
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="com.IvanMurzak.ReflectorNet" Version="0.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="com.IvanMurzak.ReflectorNet" Version="0.2.1" />
                    
Directory.Packages.props
<PackageReference Include="com.IvanMurzak.ReflectorNet" />
                    
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 com.IvanMurzak.ReflectorNet --version 0.2.1
                    
#r "nuget: com.IvanMurzak.ReflectorNet, 0.2.1"
                    
#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 com.IvanMurzak.ReflectorNet@0.2.1
                    
#: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=com.IvanMurzak.ReflectorNet&version=0.2.1
                    
Install as a Cake Addin
#tool nuget:?package=com.IvanMurzak.ReflectorNet&version=0.2.1
                    
Install as a Cake Tool

ReflectorNet

nuget License Stand With Ukraine

Tests .NET 9.0 .NET 8.0 .NET 6.0 netstandard2.0 netstandard2.1

ReflectorNet is a powerful .NET library designed to provide advanced reflection-based serialization, deserialization, and dynamic method invocation capabilities. It enables developers to inspect, manipulate, and interact with .NET objects, types, and methods at runtime, making it ideal for building tools, frameworks, and applications that require deep introspection or dynamic behavior.

Main Features

  • Advanced Reflection-Based Serialization & Deserialization Seamlessly convert .NET objects—including complex types, collections, and custom structures—to and from a type-preserving, flexible serialized format (SerializedMember). Supports custom converters for specialized scenarios.

  • Dynamic Method Discovery & Invocation Locate and invoke methods at runtime using powerful filters (namespace, type, method name, parameters). Supports both static and instance methods, including asynchronous (Task) methods, enabling dynamic scripting and automation.

  • Automatic JSON Schema Generation Generate JSON Schema representations for method parameters and return types. This enables integration with code generation, documentation, validation tools, and OpenAPI workflows.

  • Extensible Converter & Populator Registry Register custom converters and populators using a flexible, chain-of-responsibility pattern. Easily extend serialization and deserialization logic for any .NET type.

  • Comprehensive Type Introspection Analyze and discover serializable fields, properties, and type metadata. Perform advanced type matching, filtering, and metadata extraction for deep introspection.

  • Robust Error Handling & Logging Integrated error reporting and support for Microsoft.Extensions.Logging provide detailed traceability, diagnostics, and debugging.

  • Integration-Ready Designed for seamless integration with scripting engines, test frameworks, code analyzers, and documentation generators.

Project Goals

  • Maximum Flexibility: Support a broad spectrum of .NET types and use cases, from simple primitives to deeply nested object graphs and custom types.
  • Easy Extensibility: Allow users to plug in custom converters, populators, and serialization strategies with minimal effort.
  • Type Safety: Ensure type information is preserved throughout all serialization, deserialization, and dynamic invocation processes.
  • Dynamic Automation: Empower dynamic code execution, scripting, and automation by exposing runtime method invocation and object manipulation.
  • Seamless Integration: Provide schema and metadata generation for use in code generation, documentation, validation, and interoperability workflows.

Example Use Cases

  • Building scripting engines or automation tools that need to invoke .NET methods dynamically.
  • Creating serialization frameworks that require deep type introspection and custom logic.
  • Generating OpenAPI/JSON Schema documentation for .NET APIs.
  • Developing test frameworks or code analyzers that operate on runtime metadata.

Getting Started

  1. Add the ReflectorNet NuGet package to your project.
  2. Use the Reflector class to serialize, deserialize, or invoke methods dynamically.
  3. Register custom converters as needed for your types.

See the docs/ folder and code comments for more details and advanced usage examples. This project is used in Unity-MCP.

Usage API

  • Reflector.Serialize(...)
  • Reflector.Deserialize(...)
  • Reflector.GetSerializableFields(...)
  • Reflector.GetSerializableProperties(...)
  • Reflector.Populate(...)
  • Reflector.PopulateAsProperty(...)

Override ReflectionConvertor for a custom type

You may need to override convertor in the same way as JsonConvertor works if you have a custom type that should be handled differently.

Here is custom class sample.

public class MyClass
{
    public int health = 100;
}

Create custom convertor

public class MyReflectionConvertor : GenericReflectionConvertor<MyClass>
{

}

Register the convertor

Reflector.Registry.Add(new MyReflectionConvertor());

Contribution

Contributions are welcome! If you would like to help improve ReflectorNet, please follow these steps:

  1. Fork the repository on GitHub.
  2. Create a new branch for your feature or bugfix: git checkout -b my-feature
  3. Make your changes and add tests if applicable.
  4. Commit your changes with a clear and descriptive message.
  5. Push your branch to your forked repository.
  6. Open a Pull Request to the main branch of the original repository. Please describe your changes and reference any related issues.

Before submitting, ensure your code follows the project's style and passes all tests. For major changes, please open an issue first to discuss your proposal.

Thank you for contributing to ReflectorNet!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on com.IvanMurzak.ReflectorNet:

Package Downloads
com.IvanMurzak.Unity.MCP.Common

Shared code between Unity-MCP-Plugin and Unity-MCP-Server projects.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on com.IvanMurzak.ReflectorNet:

Repository Stars
IvanMurzak/Unity-MCP
MCP Server + Plugin for Unity Editor and Unity game. The Plugin allows to connect to MCP clients like Claude Desktop or others.
Version Downloads Last Updated
1.0.6 55 9/10/2025
1.0.5 65 9/9/2025
1.0.4 304 8/16/2025
1.0.3 206 8/14/2025
1.0.2 207 8/14/2025
1.0.1 331 8/8/2025
1.0.0 307 8/8/2025
0.3.0 266 8/4/2025
0.2.4 524 7/25/2025
0.2.3 522 7/25/2025
0.2.1 563 7/24/2025
0.2.0 624 7/23/2025
0.1.13 483 6/24/2025
0.1.12 249 6/22/2025
0.1.11 108 6/22/2025
0.1.10 525 6/13/2025
0.1.9 162 5/29/2025
0.1.8 153 5/29/2025
0.1.7 152 5/28/2025
0.1.6 153 5/28/2025
0.1.5 151 5/28/2025
0.1.4 149 5/28/2025
0.1.3 155 5/28/2025
0.1.2 153 5/28/2025
0.1.1 150 5/28/2025
0.1.0 157 5/28/2025