Skip to content

ReflectionFallbackHandlers

NexusLabs.Needlr.Injection.Reflection

NexusLabs.Needlr.Injection.Reflection

ReflectionFallbackHandlers Class

Provides built-in handlers for reflection fallback scenarios. Use these with WithReflectionFallbackHandler(this ConfiguredSyringe, Action<ReflectionFallbackContext>) to control what happens when source-generated components are not available.

public static class ReflectionFallbackHandlers

Inheritance System.Object 🡒 ReflectionFallbackHandlers

Methods

ReflectionFallbackHandlers.CreateAssemblyProviderContext() Method

Creates context for AssemblyProvider fallback.

public static NexusLabs.Needlr.Injection.Reflection.ReflectionFallbackContext CreateAssemblyProviderContext();

Returns

ReflectionFallbackContext

ReflectionFallbackHandlers.CreatePluginFactoryContext() Method

Creates context for PluginFactory fallback.

public static NexusLabs.Needlr.Injection.Reflection.ReflectionFallbackContext CreatePluginFactoryContext();

Returns

ReflectionFallbackContext

ReflectionFallbackHandlers.CreateTypeFiltererContext() Method

Creates context for TypeFilterer fallback.

public static NexusLabs.Needlr.Injection.Reflection.ReflectionFallbackContext CreateTypeFiltererContext();

Returns

ReflectionFallbackContext

ReflectionFallbackHandlers.CreateTypeRegistrarContext() Method

Creates context for TypeRegistrar fallback.

public static NexusLabs.Needlr.Injection.Reflection.ReflectionFallbackContext CreateTypeRegistrarContext();

Returns

ReflectionFallbackContext

ReflectionFallbackHandlers.LogWarning(ReflectionFallbackContext) Method

A handler that writes a warning to System.Console.Error when reflection fallback occurs. Useful for development/debugging to identify missing source generation.

public static void LogWarning(NexusLabs.Needlr.Injection.Reflection.ReflectionFallbackContext context);

Parameters

context ReflectionFallbackContext

Example

var syringe = new Syringe()
    .WithReflectionFallbackHandler(ReflectionFallbackHandlers.LogWarning);

ReflectionFallbackHandlers.Silent(ReflectionFallbackContext) Method

A handler that does nothing when reflection fallback occurs. This is the default behavior - silent fallback to reflection.

public static void Silent(NexusLabs.Needlr.Injection.Reflection.ReflectionFallbackContext context);

Parameters

context ReflectionFallbackContext

ReflectionFallbackHandlers.ThrowException(ReflectionFallbackContext) Method

A handler that throws an System.InvalidOperationException when reflection fallback occurs. Use this to enforce source-generation in AOT/trimmed applications.

public static void ThrowException(NexusLabs.Needlr.Injection.Reflection.ReflectionFallbackContext context);

Parameters

context ReflectionFallbackContext

Example

var syringe = new Syringe()
    .WithReflectionFallbackHandler(ReflectionFallbackHandlers.ThrowException);