Skip to content

.Net type discovery and assembly scanning made simplified.

License

Notifications You must be signed in to change notification settings

eventstorage/tdiscover

Repository files navigation

tdiscover

A .Net library to help speed up and simplify type discovery.

Github follow Nuget Package Nuget Github follow

asynchandler

Overview

tdiscover simplifies type discovery overhead when searching through .Net assemblies with a bunch of helpful methods to speed up your development.

Prerequisities

My Skills

tdiscover runs on the stable release of .Net 8 and requires the SDK installed.

https://dotnet.microsoft.com/en-us/download/dotnet/8.0

Install the package

Iinstall TDiscover package.

dotnet add package TDiscover

Examples

Search for a derived type by its root.

using System.Reflection;
using TDiscover;

public record AggregateRoot;
public record OrderAggregate : AggregateRoot;

var assembly = Assembly.GetExecutingAssembly();
var type = Td.FindByAsse<AggregateRoot>(assembly);
// or typeof(AggregateRoot).FindByAsse(assembly);

Use FindByCallingAsse() to start from calling assembly all the way back to matching assembly, FindByCallingAsse() offers significant performance gains.

typeof(AggregateRoot).FindByCallingAsse(Assembly.GetCallingAssembly());

Search for a type through AppDomain, smart tricks and filters are applied to enhance the search.

public record DomainEvent;
public record OrderPlaced : DomainEvent;

Td.FindByType<DomainEvent>();

To further enhance the above search, use FindByTypeName to specify the type and name as well.

public record DomainEvent;
public record OrderPlaced : DomainEvent;
public record OrderConfirmed : DomainEvent;

Td.FindByTypeName<DomainEvent>("OrderPlaced");
// or typeof(DomainEvent).FindByTypeName("OrderPlaced");

Search for a type when all you have is the type name.

Td.FindByTypeName("OrderPlaced");

Give us a ⭐

If you are an assembly and typing guru, give tdiscover a star. 💜

License

This project is licensed under the terms of MIT license.