-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Support init accessor in CSharpSyntaxFacts #48137
Conversation
...paces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs
Outdated
Show resolved
Hide resolved
…rvices/SyntaxFacts/CSharpSyntaxFacts.cs
...paces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs
Outdated
Show resolved
Hide resolved
...paces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes sense, but I don't see too much value in aggressively updating all of these APIs without known consuming use cases, or tests (or both!).
@davidwengier I looked at the usages of one of these changes, and it ends up being used for the public API SyntaxGenerator.WithAccessibility. It may not be needed internally for roslyn currently. But consumers of this API should get the desired behavior. I haven't confirmed whether the other change ends up being used in a public API or not. |
THis is a testable scenario :) Plz add test. |
I don't disagree, but there could also be issues if things light up in areas that they were never intended to, or otherwise don't support. Hopefully, of course, the existing test coverage validates that :) |
@davidwengier Got it. Let me check what tests will fail in #48158 and update these tests for init accessor in this PR. |
@@ -1315,6 +1315,7 @@ private static bool IsMemberDeclaration(SyntaxNode node) | |||
case SyntaxKind.PropertyDeclaration: | |||
case SyntaxKind.GetAccessorDeclaration: | |||
case SyntaxKind.SetAccessorDeclaration: | |||
case SyntaxKind.InitAccessorDeclaration: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidwengier I removed both GetAccessorDeclaration and InitAccessorDeclaration in a draft. There are no test failures. So the current tests, unfortunately, doesn't cover those.
The usages that depend on this method are in:
- CodeLens\CodeLensReferencesService.cs (there is a call to
syntaxFactsService.IsDeclaration(node)
) - CodeRefactorings\SyncNamespace\AbstractChangeNamespaceService.cs (there is a call to
.DescendantNodes(n => !syntaxFacts.IsDeclaration(n))
)
Unlike the other change, I'm not able to guess the effect of this change.
I'll try to change the method to only return false
in the draft in a hope to see test failures (i.e. other switch arms are tested).
@@ -1315,6 +1315,7 @@ private static bool IsMemberDeclaration(SyntaxNode node) | |||
case SyntaxKind.PropertyDeclaration: | |||
case SyntaxKind.GetAccessorDeclaration: | |||
case SyntaxKind.SetAccessorDeclaration: | |||
case SyntaxKind.InitAccessorDeclaration: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's a good idea to update this one without knowing the change it introduce.
This whole method isn't covered in the tests. See how #48158 is green.
...paces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs
Outdated
Show resolved
Hide resolved
@CyrusNajmabadi @davidwengier Is this ready to merge? |
Prefer squash/merge.