-
Notifications
You must be signed in to change notification settings - Fork 4k
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
'RegisterSymbolAction' for 'Property' doesn't run at all on partial properties with attributes on both definition and implementation parts #76166
Comments
cc. @RikkiGibson. I found this in CommunityToolkit/dotnet#1010. |
Somewhat overlaps with #69543 |
It might not be exactly #69543. I didn't debug, but just looking around in the code. roslyn/src/Compilers/Core/Portable/SourceGeneration/GeneratedCodeUtilities.cs Lines 29 to 43 in f614346
This should not be considering GeneratedCodeAttribute if the symbol has multiple syntax refs. However, I see this in property symbol: roslyn/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbolBase.cs Lines 534 to 540 in f614346
This may be outdated code? |
I think DeclaringSyntaxReferences is implemented as expected. It is consistent with methods. Each part symbol has a single DeclaringSyntaxReference, and you need to get that part symbol to get the appropriate SyntaxReference for it. The |
Makes sense. Thanks @RikkiGibson |
As a temporary workaround I ended up enabling the analyzer to run on generated code too, seems to do the trick 😅 |
Version Used: 4.12.0-3.24558.5 (21192bf)
Steps to Reproduce:
dev/more-analyzers
(or Add more analyzers, enable unit tests for partial properties CommunityToolkit/dotnet#1010)[Ignore]
fromInvalidPartialPropertyLevelObservablePropertyAttributeAnalyzer_OnImplementedProperty_GeneratedByAnotherGenerator_Warns
RegisterSymbolAction
callback inInvalidPartialPropertyLevelObservablePropertyAttributeAnalyzer
[GeneratedCode]
attribute on the partial property implementation in that testExpected Behavior:
The
RegisterSymbolAction
callback should work as expected in both cases.Actual Behavior:
The
RegisterSymbolAction
callback is apparently not called at all if you leave the attribute on the implementation part.The text was updated successfully, but these errors were encountered: