Add IDE tests for "file-scoped namespaces"#54374
Add IDE tests for "file-scoped namespaces"#54374RikkiGibson merged 7 commits intodotnet:features/FileScopedNamespacesfrom
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.
would be good to put this (or a copy) in the TotalClassifierTests. Then we can validate that the rest of hte tokens classify properly.
| AssertSmartIndent( | ||
| code, | ||
| indentationLine: 4, | ||
| expectedIndentation: 0); |
There was a problem hiding this comment.
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).
| public async Task TestAfterFileScopedNamespace() | ||
| { | ||
| await VerifyKeywordAsync( | ||
| @"namespace NS; $$"); |
There was a problem hiding this comment.
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.
| case SyntaxKind.NamespaceDeclaration: | ||
| return GetName(((NamespaceDeclarationSyntax)node).Name, options); | ||
| case SyntaxKind.FileScopedNamespaceDeclaration: | ||
| return GetName(((BaseNamespaceDeclarationSyntax)node).Name, options); |
CyrusNajmabadi
left a comment
There was a problem hiding this comment.
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