This is samples for the StoreKeeper which augments your DI container to make it work in Reflection-free mode.
You add Nuget package.
dotnet add package StoreKeeperThen you add custom Nuget feed for latest NativeAOT compiler with fixes.
dotnet new nugetoconfigAdd dotnet7 feed to nuget.config
<add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />And that's it unless you are using open generics as service registration.
// Build your DI container as usual.
var serviceCollection = new ServiceCollection();
serviceCollection.AddScoped<ConsoleWrapper>();
var provider = serviceCollection.BuildServiceProvider();
// Use your service provider as usual.
var wrapper = provider.GetRequiredService<ConsoleWrapper>();
wrapper.WriteLine("Bye Bye Reflection!");