TypeDiscoveryHelper
NexusLabs.Needlr.Generators¶
NexusLabs.Needlr.Roslyn.Shared¶
TypeDiscoveryHelper Class¶
Shared helper utilities for discovering injectable types from Roslyn symbols. Used by both Generators and Analyzers to ensure consistent type discovery logic.
Inheritance System.Object 🡒 TypeDiscoveryHelper
Methods¶
TypeDiscoveryHelper.HasDoNotAutoRegisterAttribute(INamedTypeSymbol) Method¶
Checks if a type has the [DoNotAutoRegister] attribute (directly or on interfaces).
Parameters¶
typeSymbol Microsoft.CodeAnalysis.INamedTypeSymbol
Returns¶
TypeDiscoveryHelper.HasDoNotAutoRegisterAttributeDirect(INamedTypeSymbol) Method¶
Checks if a type has the [DoNotAutoRegister] or [DoNotInject] attribute directly applied.
Parameters¶
typeSymbol Microsoft.CodeAnalysis.INamedTypeSymbol
Returns¶
TypeDiscoveryHelper.HasUnsatisfiedRequiredMembers(INamedTypeSymbol) Method¶
Checks if a type has required members that aren't satisfied by any constructor with [SetsRequiredMembers] attribute.
Parameters¶
typeSymbol Microsoft.CodeAnalysis.INamedTypeSymbol
Returns¶
TypeDiscoveryHelper.InheritsFrom(INamedTypeSymbol, string) Method¶
Checks if a type inherits from a base type by name.
Parameters¶
typeSymbol Microsoft.CodeAnalysis.INamedTypeSymbol
baseTypeName System.String
Returns¶
TypeDiscoveryHelper.IsAccessibleFromGeneratedCode(INamedTypeSymbol, bool) Method¶
Checks if a type is accessible from generated code. For types in the current assembly, internal and public types are accessible. For types in referenced assemblies, only public types are accessible.
public static bool IsAccessibleFromGeneratedCode(INamedTypeSymbol typeSymbol, bool isCurrentAssembly);
Parameters¶
typeSymbol Microsoft.CodeAnalysis.INamedTypeSymbol
isCurrentAssembly System.Boolean
Returns¶
TypeDiscoveryHelper.IsCompilerGenerated(INamedTypeSymbol) Method¶
Checks if a type is compiler-generated.
Parameters¶
typeSymbol Microsoft.CodeAnalysis.INamedTypeSymbol
Returns¶
TypeDiscoveryHelper.IsInjectableType(INamedTypeSymbol, bool) Method¶
Determines whether a type symbol represents a concrete injectable type.
Parameters¶
typeSymbol Microsoft.CodeAnalysis.INamedTypeSymbol
The type symbol to check.
isCurrentAssembly System.Boolean
True if the type is from the current compilation's assembly (allows internal types).
Returns¶
System.Boolean
True if the type is a valid injectable type; otherwise, false.
TypeDiscoveryHelper.IsSystemType(INamedTypeSymbol) Method¶
Checks if a type is from the System namespace or system assemblies.
Parameters¶
typeSymbol Microsoft.CodeAnalysis.INamedTypeSymbol