SyringeBundleExtensions
NexusLabs.Needlr.Injection.Bundle¶
SyringeBundleExtensions Class¶
Extension methods that provide automatic fallback between source-generated and reflection-based components.
Inheritance System.Object 🡒 SyringeBundleExtensions
Remarks¶
When using the Bundle package, Needlr will automatically: 1. Try to use source-generated components if available (via NeedlrSourceGenBootstrap) 2. Fall back to reflection-based components if source generation is not configured
Use WithFallbackBehavior(this Syringe, Action<ReflectionFallbackContext>) to configure the fallback behavior, or WithFastFailOnReflection(this Syringe) to throw if reflection is used.
Methods¶
SyringeBundleExtensions.UsingAutoConfiguration(this Syringe) Method¶
Configures the syringe with automatic fallback from source-gen to reflection.
public static NexusLabs.Needlr.Injection.ConfiguredSyringe UsingAutoConfiguration(this NexusLabs.Needlr.Injection.Syringe syringe);
Parameters¶
syringe NexusLabs.Needlr.Injection.Syringe
The syringe to configure.
Returns¶
NexusLabs.Needlr.Injection.ConfiguredSyringe
A configured syringe ready for further configuration and building.
Remarks¶
This method automatically detects whether source generation is available and configures the appropriate components. If source-generated providers are registered via NeedlrSourceGenBootstrap, they will be used. Otherwise, reflection-based components are used as fallback.
SyringeBundleExtensions.WithFallbackBehavior(this Syringe, Action<ReflectionFallbackContext>) Method¶
Configures the syringe with automatic fallback and a custom fallback handler.
public static NexusLabs.Needlr.Injection.ConfiguredSyringe WithFallbackBehavior(this NexusLabs.Needlr.Injection.Syringe syringe, System.Action<NexusLabs.Needlr.Injection.Reflection.ReflectionFallbackContext>? onFallback);
Parameters¶
syringe NexusLabs.Needlr.Injection.Syringe
The syringe to configure.
onFallback System.Action<NexusLabs.Needlr.Injection.Reflection.ReflectionFallbackContext>
Called when reflection fallback occurs. Can be used for logging or to throw.
Returns¶
NexusLabs.Needlr.Injection.ConfiguredSyringe
A configured syringe ready for further configuration and building.
SyringeBundleExtensions.WithFallbackLogging(this Syringe) Method¶
Configures the syringe to log warnings when reflection fallback occurs.
public static NexusLabs.Needlr.Injection.ConfiguredSyringe WithFallbackLogging(this NexusLabs.Needlr.Injection.Syringe syringe);
Parameters¶
syringe NexusLabs.Needlr.Injection.Syringe
The syringe to configure.
Returns¶
NexusLabs.Needlr.Injection.ConfiguredSyringe
A configured syringe ready for further configuration and building.
SyringeBundleExtensions.WithFastFailOnReflection(this Syringe) Method¶
Configures the syringe to throw an exception if reflection fallback would occur.
public static NexusLabs.Needlr.Injection.ConfiguredSyringe WithFastFailOnReflection(this NexusLabs.Needlr.Injection.Syringe syringe);
Parameters¶
syringe NexusLabs.Needlr.Injection.Syringe
The syringe to configure.
Returns¶
NexusLabs.Needlr.Injection.ConfiguredSyringe
A configured syringe ready for further configuration and building.
Remarks¶
Use this in AOT/trimming scenarios to ensure that source-generated components are always used. If no source-generated providers are registered, an System.InvalidOperationException is thrown.