User Story
As a developer, I want a Roslyn analyzer that ensures every class inheriting from EventBase or StateBase is decorated with the [GenerateSerializer] attribute, so that serialization code is always generated correctly and missing attributes are caught at compile time.
Details & Requirements
-
Analyzer Implementation
- Use the Roslyn
CompilationStartAction to register a syntax node action for ClassDeclarationSyntax.
- For each class, use semantic analysis to check if its base type is
EventBase or StateBase (directly or indirectly). :contentReference[oaicite:0]{index=0}
- If such a class lacks the
[GenerateSerializer] attribute, report a diagnostic with an error severity.
-
Code Fix Provider
- Provide a code-fix that adds the
[GenerateSerializer] attribute to the class declaration when the diagnostic is triggered.
- Ensure the fix respects existing using directives or adds
using Orleans.CodeGeneration; as needed.
-
Configuration & Suppression
- Allow users to suppress the diagnostic via
#pragma or EditorConfig settings if there are valid exceptions.
- Expose a rule ID (e.g.,
AGENT001) and description in the analyzer’s descriptor for easy configuration.
-
Testing & Integration
- Create unit tests using the Roslyn test framework to verify detection on classes inheriting from
EventBase/StateBase with and without the attribute.
- Include integration tests to ensure the analyzer and code-fix work in real projects under the CI pipeline.
-
Documentation & Adoption
- Document how to install and enable the analyzer in project files (e.g., via NuGet).
- Provide examples of classes that will pass or fail the check, and guide on how to apply the code fix.
Acceptance Criteria
- The analyzer reports an error for each class deriving from
EventBase or StateBase that does not have [GenerateSerializer].
- The provided code fix correctly adds the attribute and required
using directive.
- Tests cover direct and indirect inheritance scenarios, as well as suppression cases.
- Documentation is available detailing rule ID, configuration options, and usage examples.
User Story
As a developer, I want a Roslyn analyzer that ensures every class inheriting from
EventBaseorStateBaseis decorated with the[GenerateSerializer]attribute, so that serialization code is always generated correctly and missing attributes are caught at compile time.Details & Requirements
Analyzer Implementation
CompilationStartActionto register a syntax node action forClassDeclarationSyntax.EventBaseorStateBase(directly or indirectly). :contentReference[oaicite:0]{index=0}[GenerateSerializer]attribute, report a diagnostic with an error severity.Code Fix Provider
[GenerateSerializer]attribute to the class declaration when the diagnostic is triggered.using Orleans.CodeGeneration;as needed.Configuration & Suppression
#pragmaor EditorConfig settings if there are valid exceptions.AGENT001) and description in the analyzer’s descriptor for easy configuration.Testing & Integration
EventBase/StateBasewith and without the attribute.Documentation & Adoption
Acceptance Criteria
EventBaseorStateBasethat does not have[GenerateSerializer].usingdirective.