Skip to content

Harden analyzer symbol handling#9666

Merged
ReubenBond merged 16 commits into
dotnet:mainfrom
Youssef1313:dev/ygerges/analyzers
Feb 15, 2026
Merged

Harden analyzer symbol handling#9666
ReubenBond merged 16 commits into
dotnet:mainfrom
Youssef1313:dev/ygerges/analyzers

Conversation

@Youssef1313

@Youssef1313 Youssef1313 commented Aug 30, 2025

Copy link
Copy Markdown
Member

Current implementation of analyzers relies on syntax when it really needs semantics. This is a bad practice and is very error prone.

This PR modernizes few analyzer implementations to follow better practices and be more solid. There is much more to cleanup, but it's a good step so far.

@ReubenBond ReubenBond requested a review from Copilot October 1, 2025 17:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes Orleans analyzer implementations by migrating from syntax-based analysis to semantic-based analysis using symbols. This improves reliability and follows analyzer best practices by avoiding error-prone syntax parsing.

Key changes:

  • Migration from SyntaxNodeAnalysisContext to SymbolAnalysisContext across multiple analyzers
  • Introduction of new SymbolHelpers utility class for semantic operations
  • Removal of unused syntax-based helper methods from SyntaxHelpers

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/Analyzers.Tests/AbstractPropertiesCannotBeSerializedAnalyzerTest.cs Removed UTF-8 BOM character
src/Orleans.Analyzers/SyntaxHelpers.cs Removed unused syntax-based helper methods and made remaining methods private
src/Orleans.Analyzers/SymbolHelpers.cs New utility class with semantic-based helper methods
src/Orleans.Analyzers/SerializationAttributesHelper.cs Updated to use symbol-based analysis and removed unused properties
src/Orleans.Analyzers/NoRefParamsDiagnosticAnalyzer.cs Migrated from syntax to symbol analysis
src/Orleans.Analyzers/IncorrectAttributeUseAnalyzer.cs Migrated from syntax to symbol analysis
src/Orleans.Analyzers/IdClashAttributeAnalyzer.cs Migrated from syntax to symbol analysis with improved type safety
src/Orleans.Analyzers/GrainInterfaceMethodReturnTypeDiagnosticAnalyzer.cs Migrated from syntax to symbol analysis and simplified type checking
src/Orleans.Analyzers/GenerateGenerateSerializerAttributeAnalyzer.cs Migrated from syntax to symbol analysis
src/Orleans.Analyzers/GenerateAliasAttributesAnalyzer.cs Migrated from syntax to symbol analysis
src/Orleans.Analyzers/AtMostOneOrleansConstructorAnalyzer.cs Migrated from syntax to symbol analysis with improved constructor counting
src/Orleans.Analyzers/AlwaysInterleaveDiagnosticAnalyzer.cs Migrated from syntax to symbol analysis
src/Orleans.Analyzers/AliasClashAttributeAnalyzer.cs Migrated from syntax to symbol analysis
src/Orleans.Analyzers/AbstractPropertiesCannotBeSerializedAnalyzer.cs Migrated to operation-based analysis

Comment thread src/Orleans.Analyzers/IdClashAttributeAnalyzer.cs
@ReubenBond ReubenBond force-pushed the dev/ygerges/analyzers branch from 9128e39 to 592a2ce Compare January 21, 2026 00:13
@ReubenBond ReubenBond force-pushed the dev/ygerges/analyzers branch from 923a420 to d2b232b Compare February 15, 2026 00:14
@ReubenBond ReubenBond enabled auto-merge February 15, 2026 00:21
@ReubenBond ReubenBond disabled auto-merge February 15, 2026 00:21
Add a dedicated test suite for AtMostOneOrleansConstructorAnalyzer and expand GenerateGenerateSerializerAttributeAnalyzer edge-case coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ReubenBond ReubenBond enabled auto-merge February 15, 2026 00:33
@ReubenBond ReubenBond changed the title Cleanup analyzers Harden analyzer symbol handling Feb 15, 2026
@ReubenBond ReubenBond disabled auto-merge February 15, 2026 00:39
@ReubenBond ReubenBond enabled auto-merge February 15, 2026 00:39
@ReubenBond ReubenBond added this pull request to the merge queue Feb 15, 2026
Merged via the queue into dotnet:main with commit e7b6103 Feb 15, 2026
59 checks passed
rkargMsft pushed a commit to rkargMsft/orleans that referenced this pull request Feb 27, 2026
* Cleanup AbstractPropertiesCannotBeSerializedAnalyzer

* More cleanup

* Cleanup AlwaysInterleaveDiagnosticAnalyzer

* Cleanup AtMostOneOrleansConstructorAnalyzer

* Cleanup GenerateAliasAttributesAnalyzer

* Cleanup no longer used helper

* Cleanup GenerateGenerateSerializerAttributeAnalyzer

* Cleanup GrainInterfaceMethodReturnTypeDiagnosticAnalyzer

* Cleanup dead code

* Cleanup IncorrectAttributeUseAnalyzer

* Cleanup SyntaxHelpers

* Cleanup IdClashAttributeAnalyzer

* Cleanup NoRefParamsDiagnosticAnalyzer

* Apply suggestion from @ReubenBond

* Guard GenerateAlias analyzer syntax access

Avoid indexing DeclaringSyntaxReferences for symbols without source declarations and add a regression test for referenced grain interfaces.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add missing analyzer test coverage

Add a dedicated test suite for AtMostOneOrleansConstructorAnalyzer and expand GenerateGenerateSerializerAttributeAnalyzer edge-case coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Reuben Bond <203839+ReubenBond@users.noreply.github.com>
Co-authored-by: Reuben Bond <reuben.bond@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants