Skip to content
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

Merged
merged 8 commits into from
Oct 14, 2020
Merged

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Sep 28, 2020

Prefer squash/merge.

@Youssef1313 Youssef1313 requested a review from a team as a code owner September 28, 2020 23:10
@jinujoseph jinujoseph added Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Sep 29, 2020
Copy link
Contributor

@davidwengier davidwengier left a 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!).

@Youssef1313
Copy link
Member Author

@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.

@CyrusNajmabadi
Copy link
Member

and it ends up being used for the public API SyntaxGenerator.WithAccessibility.

THis is a testable scenario :) Plz add test.

@davidwengier
Copy link
Contributor

It may not be needed internally for roslyn currently. But consumers of this API should get the desired behavior.

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 :)

@Youssef1313
Copy link
Member Author

@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:
Copy link
Member Author

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:
Copy link
Member Author

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.

@Youssef1313
Copy link
Member Author

@CyrusNajmabadi @davidwengier Is this ready to merge?

@davidwengier
Copy link
Contributor

@sharwell

@sharwell sharwell merged commit a09a5a2 into dotnet:master Oct 14, 2020
@ghost ghost added this to the Next milestone Oct 14, 2020
@Youssef1313 Youssef1313 deleted the patch-40 branch October 14, 2020 13:17
@allisonchou allisonchou modified the milestones: Next, 16.9.P2 Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants