-
Notifications
You must be signed in to change notification settings - Fork 83
Refactor UNT0022 expression comparison to use recursive semantic analysis #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: sailro <638167+sailro@users.noreply.github.com>
Co-authored-by: sailro <638167+sailro@users.noreply.github.com>
Co-authored-by: sailro <638167+sailro@users.noreply.github.com>
|
@copilot this is incomplete, because only checking symbols is not enough. Like for any GameObject Foo, Foo.transform.position and this.transform.position (inside a MonoBehaviour) are the same symbol: the property name Like |
Co-authored-by: sailro <638167+sailro@users.noreply.github.com>
Fixed in commit f3988c7. The comparison now recursively checks the entire expression chain:
|
* Fixes #428 * Refactor UNT0022 expression comparison to use recursive semantic analysis (#430) * Initial plan * Refactor string comparisons to use semantic analysis with SemanticModel Co-authored-by: sailro <638167+sailro@users.noreply.github.com> * Add test cases for semantic equivalence detection Co-authored-by: sailro <638167+sailro@users.noreply.github.com> * Add comments clarifying null symbol handling for ambiguous cases Co-authored-by: sailro <638167+sailro@users.noreply.github.com> * Fix semantic equivalence to compare entire expression chains recursively Co-authored-by: sailro <638167+sailro@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sailro <638167+sailro@users.noreply.github.com> * fixups --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: sailro <638167+sailro@users.noreply.github.com>
Checklist
Short description of what this resolves:
Replaces string-based expression comparison with recursive semantic analysis using Roslyn's SemanticModel to correctly identify semantically equivalent expressions while distinguishing between different object instances.
Changes proposed in this pull request:
AreExpressionsEquivalent()helper - UsesIsEquivalentTo()for syntactic equivalence and recursively compares member access chains usingGetSymbolInfo()andSymbolEqualityComparerto ensure entire expression chains match semanticallyinstance.transform), compares both the member symbol AND recursively validates the base expression, preventing false matches between different object instancesDetectExpressionReuse()method - Now uses the improved semantic comparison to detect when expressions are reused in subsequent statements, regardless of syntax variationstransform.positionvsthis.transform.positioncorrectly while properly distinguishinginstance.transformfromgo.transformExample scenarios now handled correctly:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.