Context
Child issue of #956 (Epic: Model Metadata Attributes & Source Generator Infrastructure)
Depends on: #957 (attributes must exist first)
Task
Create a Roslyn incremental source generator in AiDotNet.Generators that validates all model classes have proper metadata attributes and documentation at compile time.
Validations to Implement
Required Attributes (Compile Error)
For every non-abstract class that inherits from a model base type or implements a model interface:
[ModelDomain] - at least one domain must be specified
[ModelCategory] - exactly one category
[ModelTask] - at least one task
[ModelComplexity] - exactly one complexity level
[ModelInput] - exactly one input/output type declaration
Emit diagnostic: AIDN001: Model class '{ClassName}' is missing required attribute '[{AttributeName}]'
XML Documentation (Compile Warning)
- Missing
<summary> tag: AIDN010: Model class '{ClassName}' is missing XML doc summary
- Missing
<remarks> with "For Beginners" content: AIDN011: Model class '{ClassName}' is missing beginner-friendly remarks
- Missing
<example> block: AIDN012: Model class '{ClassName}' is missing usage example
- Public methods without
<summary>: AIDN013: Public method '{MethodName}' on '{ClassName}' is missing XML doc
- Constructor parameters without
<param>: AIDN014: Parameter '{ParamName}' on '{ClassName}' constructor is missing doc
Semantic Validation (Compile Warning)
[ModelPaper] URL validation: AIDN020: ModelPaper URL '{Url}' is not well-formed (must start with https://)
- Domain/Task consistency:
AIDN021: Model '{ClassName}' has domain '{Domain}' but no related task
Model Base Types to Scan For
The generator should detect classes that inherit from or implement:
NeuralNetworkBase<T>
IFullModel<T, TInput, TOutput>
IModel<TInput, TOutput, TMetadata>
IClassifier<T>
ISyntheticTabularGenerator<T>
AgentBase<T>
SyntheticTabularGeneratorBase<T>
CausalModelBase<T>
GaussianProcessBase<T>
- Other model base types discovered during implementation
Technical Requirements
- Use
IIncrementalGenerator (not ISourceGenerator) for performance
- Use syntax-first filtering (check for class declarations with base types) before semantic analysis
- Diagnostics should have proper severity (Error for missing attributes, Warning for missing docs)
- Must work with both net10.0 and net471 targets
- Should not significantly increase build time (< 2 seconds added)
Acceptance Criteria
Context
Child issue of #956 (Epic: Model Metadata Attributes & Source Generator Infrastructure)
Depends on: #957 (attributes must exist first)
Task
Create a Roslyn incremental source generator in
AiDotNet.Generatorsthat validates all model classes have proper metadata attributes and documentation at compile time.Validations to Implement
Required Attributes (Compile Error)
For every non-abstract class that inherits from a model base type or implements a model interface:
[ModelDomain]- at least one domain must be specified[ModelCategory]- exactly one category[ModelTask]- at least one task[ModelComplexity]- exactly one complexity level[ModelInput]- exactly one input/output type declarationEmit diagnostic:
AIDN001: Model class '{ClassName}' is missing required attribute '[{AttributeName}]'XML Documentation (Compile Warning)
<summary>tag:AIDN010: Model class '{ClassName}' is missing XML doc summary<remarks>with "For Beginners" content:AIDN011: Model class '{ClassName}' is missing beginner-friendly remarks<example>block:AIDN012: Model class '{ClassName}' is missing usage example<summary>:AIDN013: Public method '{MethodName}' on '{ClassName}' is missing XML doc<param>:AIDN014: Parameter '{ParamName}' on '{ClassName}' constructor is missing docSemantic Validation (Compile Warning)
[ModelPaper]URL validation:AIDN020: ModelPaper URL '{Url}' is not well-formed (must start with https://)AIDN021: Model '{ClassName}' has domain '{Domain}' but no related taskModel Base Types to Scan For
The generator should detect classes that inherit from or implement:
NeuralNetworkBase<T>IFullModel<T, TInput, TOutput>IModel<TInput, TOutput, TMetadata>IClassifier<T>ISyntheticTabularGenerator<T>AgentBase<T>SyntheticTabularGeneratorBase<T>CausalModelBase<T>GaussianProcessBase<T>Technical Requirements
IIncrementalGenerator(notISourceGenerator) for performanceAcceptance Criteria