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

Generate code with consistent line endings #412

Merged
merged 1 commit into from
Sep 18, 2021
Merged

Generate code with consistent line endings #412

merged 1 commit into from
Sep 18, 2021

Conversation

AArnott
Copy link
Member

@AArnott AArnott commented Sep 18, 2021

This worksaround VS's annoying dialog when opening generated code that offers to normalize line endings (on the readonly file).

Fixes #369

This worksaround VS's annoying dialog when opening generated code that offers to normalize line endings (on the readonly file).

Fixes #369
@AArnott AArnott merged commit e0d1a27 into main Sep 18, 2021
@AArnott AArnott deleted the fix369 branch September 18, 2021 22:29
}
}

private static void AssertConsistentLineEndings(SyntaxTree syntaxTree)
Copy link
Member

Choose a reason for hiding this comment

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

💡 You could use the new EqualOrDiff functionality from dotnet/roslyn-sdk for this assertion by asserting the syntaxTree.GetText() is the same as syntaxTree.GetText().Replace("\r\n", "\n").

dotnet/roslyn-sdk#886

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooh, that's nice. Thanks for the tip. Where is this EqualOrDiff method exposed, or would I need to copy its source?

Copy link
Member

Choose a reason for hiding this comment

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

If you already reference MS.CA.Testing, you can use DefaultVerifier with this extension method. Otherwise the source is reasonably easy to copy.

Copy link
Member

Choose a reason for hiding this comment

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

Note that EqualOrDiff was originally implemented by you, but we modified it in dotnet/roslyn-sdk#878 and dotnet/roslyn-sdk#886 to specifically support cases where only the line endings changed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya, I thought I remembered that I had shared it. We developed it for vs-mef.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VS editor constantly warns about inconsistent line endings
2 participants