Skip to content

Some code fixes/refactorings do not respect document EOL settings #25927

@Therzok

Description

@Therzok

Version Used:
2.8.0-beta3-62728-05

Steps to Reproduce:

  1. See Mixed new lines after adding using statement mono/monodevelop#4409 for repro case

Expected Behavior:
EOL settings should be respected

Actual Behavior:
In some cases, CRLF or LF are inserted regardless of document options.

Analysis:
From what I've seen, the offending code is using SyntaxFactory.CarriageReturnLineFeed directly: http://source.roslyn.io/#Microsoft.CodeAnalysis.CSharp.Workspaces/Utilities/UsingsAndExternAliasesOrganizer.cs,14

From what I understand, maybe SyntaxFactory.ElasticCarriageReturnLineFeed should be used instead, so the formatter call from here uses the right EOL endings:
http://source.roslyn.io/#Microsoft.CodeAnalysis.Features/AddImport/References/Reference.cs,134
http://source.roslyn.io/#Microsoft.CodeAnalysis.Workspaces/CodeActions/CodeAction.cs,275

As an afterthought, maybe all occurences of non-elastic should be looked at and fixed if needed. I only saw these being used:
CarriageReturnLineFeed
Space
Whitespace

Metadata

Metadata

Labels

Area-IDEBugResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions