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

https://github.com/lauanguermandi/fastreflections

FastReflections is a fast and lightweight .NET library that simplifies and speeds up access to methods, properties, and types using cached reflection and clean syntax.
https://github.com/lauanguermandi/fastreflections

dotnet reflections type-search

Last synced: 4 months ago
JSON representation

FastReflections is a fast and lightweight .NET library that simplifies and speeds up access to methods, properties, and types using cached reflection and clean syntax.

Awesome Lists containing this project

README

          

# FastReflections

**FastReflections** is a lightweight and high-performance utility library for .NET that provides fast, cached reflection-based access to methods, properties, using expressions, and types with clean and expressive syntax.

---

## Installation

```bash
dotnet add package FastReflections
```

---

## Usage

### Invoke Method

```csharp
var instance = new MyClass();
var method = typeof(MyClass).GetMethod("SayHello");

var result = FastReflections.Invoke(method, instance, "John");
// result => "Hello, John"
```

### Get Property

```csharp
var instance = new MyClass { Name = "FastReflections" };

var value = FastReflections.GetPropertyValue(instance, x => x.Name);
// value => "FastReflections"
```

### Set Property

```csharp
var instance = new MyClass();

FastReflections.SetPropertyValue(instance, x => x.Name, "Updated");
// instance.Name => "Updated"
```

### Find Type by Name

```csharp
var type = FastReflections.GetTypeByName("MyNamespace.MyClass");
// type => typeof(MyClass)
```

---

## When to Use

Use `FastReflections` when:

- You need dynamic access to methods and properties
- You want performance without writing boilerplate reflection code
- You’re building frameworks, tools, or extensible plugins

---

## Internals

- Uses `Expression Trees` for performance
- Thread-safe `ConcurrentDictionary` for caching
- Automatic type cache loading via `AssemblyLoad` event

---

## License

MIT License © LauanGuermandi