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

PublicAPIAnalyzer CodeFix does not respect existing newline style #4749

Closed
333fred opened this issue Jan 27, 2021 · 1 comment · Fixed by #4774
Closed

PublicAPIAnalyzer CodeFix does not respect existing newline style #4749

333fred opened this issue Jan 27, 2021 · 1 comment · Fixed by #4774
Labels
Area-Microsoft.CodeAnalysis.PublicApiAnalyzers Bug The product is not behaving according to its current intended design help wanted The issue is up-for-grabs, and can be claimed by commenting

Comments

@333fred
Copy link
Member

333fred commented Jan 27, 2021

var newText = string.Join(Environment.NewLine, lines) + GetEndOfFileText(sourceText);

Instead of reading the line endings that already exist in the file, the public API analyzers use the default from the environment. This is a problem on Windows when autocrlf is off, or when the source is shared with a Linux partition (such as WSL or when running Windows in a VM) and the line endings are set to just \n. Instead, it should be looking at the existing line endings in the file and, if they are just \n, only using that, instead of unconditionally using the environment-default newline.

@333fred 333fred added Area-Microsoft.CodeAnalysis.PublicApiAnalyzers Bug The product is not behaving according to its current intended design labels Jan 27, 2021
@mavasani mavasani added the help wanted The issue is up-for-grabs, and can be claimed by commenting label Feb 2, 2021
@mavasani mavasani added this to the vNext milestone Feb 2, 2021
@Youssef1313
Copy link
Member

The same should apply to AnnotatePublicApiFix and NullableEnablePublicApiFix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Microsoft.CodeAnalysis.PublicApiAnalyzers Bug The product is not behaving according to its current intended design help wanted The issue is up-for-grabs, and can be claimed by commenting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants