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

Fix 'sync namespace' with file scoped namespaces #55022

Merged

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Jul 21, 2021

Fixes #54749
Relates to test plan: #49000

}
else if (baseNamespace is FileScopedNamespaceDeclarationSyntax fileScopedNamespace)
{
openingBuilder.AddRange(fileScopedNamespace.SemicolonToken.TrailingTrivia);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the semicolon have leading trivia here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, though that's a 1:10000 case :) i'm writing for the 99.9% cases :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CyrusNajmabadi To me personally, I agree this case is very very rare. But since it's a simple change, I'd handle it. Users put comments in weird places 😄
I'd expect someone later reporting the following trivia being lost:

namespace    R
    /*trivia*/;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to me it's that i can map where i expect teh trailing trivia to go. Leading trivia is something else entirely.

Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had already made most of these changes in #54755 😄
But since you're doing a bit more than I did (more tests and fixing move type service), I'll close my PR.

@Youssef1313
Copy link
Member

Can you mark the PR as "Fixes #54749"

@CyrusNajmabadi
Copy link
Member Author

Will do!

@CyrusNajmabadi
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@CyrusNajmabadi
Copy link
Member Author

ping @ryzngard

@ryzngard
Copy link
Contributor

I was waiting on #55020 to give this a final pass, since some of the changes overlapped. Will take a look later today

@@ -83,7 +83,7 @@ void Method()
{
}$$
}
", "Class.Method()", 2);
", "Namespace.Class.Method()", 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct. The namepace name shoudl be appended. but it wasn't because the walker wasn't seeing the file-scoped-namespace and was only checking for normal namespaces.

@CyrusNajmabadi CyrusNajmabadi merged commit 5e95672 into dotnet:main Jul 26, 2021
@ghost ghost added this to the Next milestone Jul 26, 2021
@CyrusNajmabadi CyrusNajmabadi deleted the fileScopedNamespaceSyncNamespace branch July 26, 2021 23:19
@allisonchou allisonchou modified the milestones: Next, 17.0.P3 Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle file-scoped namespaces in IDE0130 (match folder with namespace)
5 participants