SyringeSourceGenExtensions
NexusLabs.Needlr.Injection.SourceGen¶
NexusLabs.Needlr.Injection.SourceGen¶
SyringeSourceGenExtensions Class¶
Extension methods for configuring NexusLabs.Needlr.Injection.Syringe with source-generated components.
Inheritance System.Object 🡒 SyringeSourceGenExtensions
Remarks¶
These extensions enable AOT-compatible, zero-reflection type discovery and registration using compile-time generated type registries.
To use these extensions, your assembly must have:
- A reference to NexusLabs.Needlr.Generators
- The [assembly: GenerateTypeRegistry(...)] attribute
For assembly ordering, use SyringeExtensions.OrderAssemblies after calling UsingSourceGen().
Methods¶
SyringeSourceGenExtensions.UsingGeneratedAssemblyProvider(this ConfiguredSyringe, Func<IReadOnlyList<InjectableTypeInfo>>, Func<IReadOnlyList<PluginTypeInfo>>) Method¶
Configures the syringe to use the generated assembly provider.
public static NexusLabs.Needlr.Injection.ConfiguredSyringe UsingGeneratedAssemblyProvider(this NexusLabs.Needlr.Injection.ConfiguredSyringe syringe, System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.InjectableTypeInfo>> injectableTypeProvider, System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.PluginTypeInfo>> pluginTypeProvider);
Parameters¶
syringe NexusLabs.Needlr.Injection.ConfiguredSyringe
The configured syringe to update.
injectableTypeProvider System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.InjectableTypeInfo>>
A function that returns the injectable types.
pluginTypeProvider System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.PluginTypeInfo>>
A function that returns the plugin types.
Returns¶
NexusLabs.Needlr.Injection.ConfiguredSyringe
A new configured syringe instance.
SyringeSourceGenExtensions.UsingGeneratedComponents(this ConfiguredSyringe, Func<IReadOnlyList<InjectableTypeInfo>>, Func<IReadOnlyList<PluginTypeInfo>>) Method¶
Configures the syringe with all generated components for zero-reflection operation.
public static NexusLabs.Needlr.Injection.ConfiguredSyringe UsingGeneratedComponents(this NexusLabs.Needlr.Injection.ConfiguredSyringe syringe, System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.InjectableTypeInfo>> injectableTypeProvider, System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.PluginTypeInfo>> pluginTypeProvider);
Parameters¶
syringe NexusLabs.Needlr.Injection.ConfiguredSyringe
The configured syringe to update.
injectableTypeProvider System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.InjectableTypeInfo>>
A function that returns the injectable types.
pluginTypeProvider System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.PluginTypeInfo>>
A function that returns the plugin types.
Returns¶
NexusLabs.Needlr.Injection.ConfiguredSyringe
A configured syringe with all source-generated components.
SyringeSourceGenExtensions.UsingGeneratedComponents(this Syringe, Func<IReadOnlyList<InjectableTypeInfo>>, Func<IReadOnlyList<PluginTypeInfo>>) Method¶
Configures the syringe with all generated components for zero-reflection operation.
public static NexusLabs.Needlr.Injection.ConfiguredSyringe UsingGeneratedComponents(this NexusLabs.Needlr.Injection.Syringe syringe, System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.InjectableTypeInfo>> injectableTypeProvider, System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.PluginTypeInfo>> pluginTypeProvider);
Parameters¶
syringe NexusLabs.Needlr.Injection.Syringe
The base syringe to configure.
injectableTypeProvider System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.InjectableTypeInfo>>
A function that returns the injectable types.
pluginTypeProvider System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.PluginTypeInfo>>
A function that returns the plugin types.
Returns¶
NexusLabs.Needlr.Injection.ConfiguredSyringe
A configured syringe with all source-generated components.
Remarks¶
This is a strategy method that creates a ConfiguredSyringe. Use this when you have explicit type providers (e.g., from generated code) rather than using the bootstrap.
SyringeSourceGenExtensions.UsingGeneratedPluginFactory(this ConfiguredSyringe, Func<IReadOnlyList<PluginTypeInfo>>) Method¶
Configures the syringe to use the generated plugin factory.
public static NexusLabs.Needlr.Injection.ConfiguredSyringe UsingGeneratedPluginFactory(this NexusLabs.Needlr.Injection.ConfiguredSyringe syringe, System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.PluginTypeInfo>> pluginProvider);
Parameters¶
syringe NexusLabs.Needlr.Injection.ConfiguredSyringe
The configured syringe to update.
pluginProvider System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.PluginTypeInfo>>
A function that returns the plugin types.
Returns¶
NexusLabs.Needlr.Injection.ConfiguredSyringe
A new configured syringe instance.
SyringeSourceGenExtensions.UsingGeneratedTypeFilterer(this ConfiguredSyringe, Func<IReadOnlyList<InjectableTypeInfo>>) Method¶
Configures the syringe to use the generated type filterer.
public static NexusLabs.Needlr.Injection.ConfiguredSyringe UsingGeneratedTypeFilterer(this NexusLabs.Needlr.Injection.ConfiguredSyringe syringe, System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.InjectableTypeInfo>> typeProvider);
Parameters¶
syringe NexusLabs.Needlr.Injection.ConfiguredSyringe
The configured syringe to update.
typeProvider System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.InjectableTypeInfo>>
A function that returns the injectable types.
Returns¶
NexusLabs.Needlr.Injection.ConfiguredSyringe
A new configured syringe instance.
SyringeSourceGenExtensions.UsingGeneratedTypeRegistrar(this ConfiguredSyringe, Func<IReadOnlyList<InjectableTypeInfo>>) Method¶
Configures the syringe to use the generated type registrar.
public static NexusLabs.Needlr.Injection.ConfiguredSyringe UsingGeneratedTypeRegistrar(this NexusLabs.Needlr.Injection.ConfiguredSyringe syringe, System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.InjectableTypeInfo>> typeProvider);
Parameters¶
syringe NexusLabs.Needlr.Injection.ConfiguredSyringe
The configured syringe to update.
typeProvider System.Func<System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Generators.InjectableTypeInfo>>
A function that returns the injectable types.
Returns¶
NexusLabs.Needlr.Injection.ConfiguredSyringe
A new configured syringe instance.
SyringeSourceGenExtensions.UsingSourceGen(this Syringe) Method¶
Configures the syringe to use source-generated components from the module initializer bootstrap.
public static NexusLabs.Needlr.Injection.ConfiguredSyringe UsingSourceGen(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.
Exceptions¶
System.InvalidOperationException
Thrown if no source-generated type providers are registered via NeedlrSourceGenBootstrap.
Remarks¶
This method uses the type providers registered via NexusLabs.Needlr.Generators.NeedlrSourceGenBootstrap.
The bootstrap is automatically registered by the generated module initializer when you use
[assembly: GenerateTypeRegistry(...)].