-
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
Add IDE tests for "file-scoped namespaces" #54374
Add IDE tests for "file-scoped namespaces" #54374
Conversation
Do you have the stack trace available? Could help find a good test for this with more information |
Just a hunch, but a test here for file scoped namespaces might repro it: |
Stack trace
|
|
||
class C { }", | ||
testHost, | ||
Namespace("NS")); |
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.
would be good to put this (or a copy) in the TotalClassifierTests. Then we can validate that the rest of hte tokens classify properly.
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.
Done
AssertSmartIndent( | ||
code, | ||
indentationLine: 4, | ||
expectedIndentation: 0); |
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.
can you also add an assert for the lines Above the namespace? and can we have a test that just tests teh behavior of indentation if the semicolon is missing (i'm fine with any behavior, i just want it tested).
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.
Done
public async Task TestAfterFileScopedNamespace() | ||
{ | ||
await VerifyKeywordAsync( | ||
@"namespace NS; $$"); |
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.
ideally a test of namespace keywords that shows it does not appear here. Note: if it does, that's not a big deal, just would be something nice to clean up later.
We should also have tests for using
appearing after and before single-line ns.
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.
Done
@@ -857,7 +857,8 @@ public string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, strin | |||
case SyntaxKind.IncompleteMember: | |||
return missingTokenPlaceholder; | |||
case SyntaxKind.NamespaceDeclaration: | |||
return GetName(((NamespaceDeclarationSyntax)node).Name, options); | |||
case SyntaxKind.FileScopedNamespaceDeclaration: | |||
return GetName(((BaseNamespaceDeclarationSyntax)node).Name, options); |
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.
👍
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.
LGTM. but see comment about the broken formatting. it's likely a very simple fix somewhere, but it can be annoying to track down where tehse rules get inserted. LMK if you'd like help on that.
I tried reverting the implementation change and adding the test. It doesn't look like it ended up revealing the bad behavior. @davidwengier |
Test plan: #49000