Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/barsonax/mirror

Making reflection fast and simple
https://github.com/barsonax/mirror

caching csharp invokedynamic netcore reflection

Last synced: 19 days ago
JSON representation

Making reflection fast and simple

Awesome Lists containing this project

README

        

# Mirror
How to do Reflection fast while keeping a simple API.

## What is this?
This little library makes it easy to get a `Func` when given only a type, methodname and optionaly some generic parameters. The main advantage of this is that its alot faster to invoke a a `Func` than it is to use `MethodInfo.Invoke`. Some performance numbers:

2018-03-23 21_44_08-c__windows_system32_cmd exe

As you can see creating the delegate is expensive but once you have it its alot faster than `MethodInfo.Invoke` and comes within the same order of magnitude as a interface call.

## What is this not?
A complete reflection framework. Iam trying to keep this as simple as possible and purely focusing on invoking a method using reflection as fast as possible. The main reason this repo exists is for other ppl to learn how to do this but feel free to use the code. I have tried to unit test as many cases as possible to eliminate any bugs.

## Quickstart
The code that does the heavy lifting can be found [here](https://github.com/Barsonax/Mirror/blob/master/Mirror/DelegateFactory.cs). To find a example of how to use this you can check [this](https://github.com/Barsonax/Mirror/blob/master/Mirror.Example/Program.cs).