Class DefaultMetadataResolver
- Assembly
- McMaster.Extensions.CommandLineUtils.dll
Default implementation that checks the registry first, falls back to reflection.
public sealed class DefaultMetadataResolver : IMetadataResolver
- Inheritance
-
objectDefaultMetadataResolver
- Implements
Fields
Instance
Gets the singleton instance of the default metadata resolver.
public static readonly DefaultMetadataResolver Instance
Field Value
Methods
GetProvider(Type)
Gets the metadata provider for a type. Returns generated metadata if available, otherwise uses reflection.
[RequiresUnreferencedCode("Falls back to reflection when no generated metadata is available. Use the source generator for AOT compatibility.")]
public ICommandMetadataProvider GetProvider(Type modelType)
Parameters
modelTypeTypeThe model type.
Returns
- ICommandMetadataProvider
A metadata provider for the type.
Remarks
This method first checks for source-generated metadata (AOT-friendly). If no generated metadata exists, it falls back to reflection-based metadata extraction. For full AOT compatibility, ensure the CommandLineUtils.Generators package is referenced and the source generator runs during compilation.
GetProvider<TModel>()
Gets the metadata provider for a type. Returns generated metadata if available, otherwise uses reflection.
[RequiresUnreferencedCode("Falls back to reflection when no generated metadata is available. Use the source generator for AOT compatibility.")]
public ICommandMetadataProvider<TModel> GetProvider<TModel>() where TModel : class
Returns
- ICommandMetadataProvider<TModel>
A metadata provider for the type.
Type Parameters
TModelThe model type.
Remarks
This method first checks for source-generated metadata (AOT-friendly). If no generated metadata exists, it falls back to reflection-based metadata extraction. For full AOT compatibility, ensure the CommandLineUtils.Generators package is referenced and the source generator runs during compilation.
HasGeneratedMetadata(Type)
Checks if generated metadata is available for a type.
public bool HasGeneratedMetadata(Type modelType)
Parameters
modelTypeTypeThe model type.
Returns
- bool
True if generated metadata is available; otherwise, false.