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

Update filenames in file banners when moving a type to a new file. #76270

Merged
merged 3 commits into from
Dec 4, 2024

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #74703

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner December 4, 2024 21:42
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 4, 2024
@@ -125,38 +119,6 @@ private static ImmutableArray<SyntaxTrivia> GetBannerFromEquivalenceKey(string e
return bannerService.GetFileBanner(token);
}

private Task<Document> AddBannerAsync(
Copy link
Member Author

Choose a reason for hiding this comment

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

moved to a common location so it can be used in MoveType.

ImmutableArray<SyntaxTrivia> banner,
Func<SyntaxTrivia, string, SyntaxTrivia> createTrivia)
{
var sourceName = IOUtilities.PerformIO(() => Path.GetFileName(sourceDocument.FilePath));
Copy link
Contributor

Choose a reason for hiding this comment

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

Path.GetFileName

didn't change in this PR, but I think Path.GetFileName doesn't do any IO, and won't throw those exceptions.

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'll do a pass later to address these

@@ -146,7 +145,10 @@ private async Task<Document> AddNewDocumentWithSingleTypeDeclarationAsync(Docume
// get the updated document, give it the minimal set of imports that the type
// inside it needs.
Copy link
Contributor

Choose a reason for hiding this comment

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

this comment confuses me, it doesn't look like imports are handled in this method

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. Seems incorrect. Was already like that, so I'll move to another pr in this space to cleanup.


/// <summary>
/// Looks at <paramref name="banner"/> to see if it contains the name of <paramref name="sourceDocument"/>
/// in it. If so, those names will be replaced with <paramref name="destinationFilePath"/>.
Copy link
Contributor

Choose a reason for hiding this comment

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

with

nit: with -> "with the file name from "

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor "Move type to file" should re-evaluate file header template
3 participants