Skip to content

PluginTypeInfo

NexusLabs.Needlr.Generators

PluginTypeInfo Struct

Represents metadata about a plugin type discovered at compile time.

public readonly struct PluginTypeInfo

Remarks

This struct is used by the generated TypeRegistry to provide plugin factory methods without requiring reflection or Activator.CreateInstance at runtime.

Constructors

PluginTypeInfo(Type, IReadOnlyList<Type>, Func<object>) Constructor

Initializes a new instance of PluginTypeInfo.

public PluginTypeInfo(System.Type pluginType, System.Collections.Generic.IReadOnlyList<System.Type> pluginInterfaces, System.Func<object> factory);

Parameters

pluginType System.Type

The concrete plugin type.

pluginInterfaces System.Collections.Generic.IReadOnlyList<System.Type>

The plugin interfaces implemented by the type.

factory System.Func<System.Object>

A factory delegate that creates an instance of the plugin.

PluginTypeInfo(Type, IReadOnlyList<Type>, Func<object>, IReadOnlyList<Type>) Constructor

Initializes a new instance of PluginTypeInfo.

public PluginTypeInfo(System.Type pluginType, System.Collections.Generic.IReadOnlyList<System.Type> pluginInterfaces, System.Func<object> factory, System.Collections.Generic.IReadOnlyList<System.Type> attributes);

Parameters

pluginType System.Type

The concrete plugin type.

pluginInterfaces System.Collections.Generic.IReadOnlyList<System.Type>

The plugin interfaces implemented by the type.

factory System.Func<System.Object>

A factory delegate that creates an instance of the plugin.

attributes System.Collections.Generic.IReadOnlyList<System.Type>

The attribute types applied to the plugin type.

PluginTypeInfo(Type, IReadOnlyList<Type>, Func<object>, IReadOnlyList<Type>, int) Constructor

Initializes a new instance of PluginTypeInfo with execution order.

public PluginTypeInfo(System.Type pluginType, System.Collections.Generic.IReadOnlyList<System.Type> pluginInterfaces, System.Func<object> factory, System.Collections.Generic.IReadOnlyList<System.Type> attributes, int order);

Parameters

pluginType System.Type

The concrete plugin type.

pluginInterfaces System.Collections.Generic.IReadOnlyList<System.Type>

The plugin interfaces implemented by the type.

factory System.Func<System.Object>

A factory delegate that creates an instance of the plugin.

attributes System.Collections.Generic.IReadOnlyList<System.Type>

The attribute types applied to the plugin type.

order System.Int32

The execution order. Lower values execute first.

Properties

PluginTypeInfo.Attributes Property

Gets the attribute types applied to the plugin type.

public System.Collections.Generic.IReadOnlyList<System.Type> Attributes { get; }

Property Value

System.Collections.Generic.IReadOnlyList<System.Type>

Remarks

This enables attribute-based plugin filtering without requiring reflection via GetCustomAttribute at runtime.

PluginTypeInfo.Factory Property

Gets a factory delegate that creates an instance of the plugin without using Activator.CreateInstance.

public System.Func<object> Factory { get; }

Property Value

System.Func<System.Object>

PluginTypeInfo.Order Property

Gets the execution order for this plugin. Lower values execute first.

public int Order { get; }

Property Value

System.Int32

Remarks

Plugins with lower order values are executed before those with higher values. The default order is 0. Use negative values for plugins that must run early (e.g., infrastructure setup) and positive values for plugins that must run late (e.g., validation, cleanup).

When multiple plugins have the same order, they are sorted alphabetically by their fully qualified type name for deterministic execution.

PluginTypeInfo.PluginInterfaces Property

Gets the plugin interfaces implemented by the type.

public System.Collections.Generic.IReadOnlyList<System.Type> PluginInterfaces { get; }

Property Value

System.Collections.Generic.IReadOnlyList<System.Type>

PluginTypeInfo.PluginType Property

Gets the concrete plugin type.

public System.Type PluginType { get; }

Property Value

System.Type

Methods

PluginTypeInfo.HasAttribute(Type) Method

Checks if the plugin has an attribute of the specified type.

public bool HasAttribute(System.Type attributeType);

Parameters

attributeType System.Type

The attribute type to check for.

Returns

System.Boolean
True if the plugin has the attribute; otherwise, false.

PluginTypeInfo.HasAttribute<TAttribute>() Method

Checks if the plugin has an attribute of the specified type.

public bool HasAttribute<TAttribute>()
    where TAttribute : System.Attribute;

Type parameters

TAttribute

The attribute type to check for.

Returns

System.Boolean
True if the plugin has the attribute; otherwise, false.