-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
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
CompilationStartActionto register a syntax node action forClassDeclarationSyntax. - For each class, use semantic analysis to check if its base type is
EventBaseorStateBase(directly or indirectly). :contentReference[oaicite:0]{index=0} - If such a class lacks the
[GenerateSerializer]attribute, report a diagnostic with an error severity.
- Use the Roslyn
-
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.
- Provide a code-fix that adds the
-
Configuration & Suppression
- Allow users to suppress the diagnostic via
#pragmaor EditorConfig settings if there are valid exceptions. - Expose a rule ID (e.g.,
AGENT001) and description in the analyzer’s descriptor for easy configuration.
- Allow users to suppress the diagnostic via
-
Testing & Integration
- Create unit tests using the Roslyn test framework to verify detection on classes inheriting from
EventBase/StateBasewith and without the attribute. - Include integration tests to ensure the analyzer and code-fix work in real projects under the CI pipeline.
- Create unit tests using the Roslyn test framework to verify detection on classes inheriting from
-
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
EventBaseorStateBasethat does not have[GenerateSerializer]. - The provided code fix correctly adds the attribute and required
usingdirective. - Tests cover direct and indirect inheritance scenarios, as well as suppression cases.
- Documentation is available detailing rule ID, configuration options, and usage examples.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels