Resharper reformat is changing line endings
Asked Answered
P

3

10

Is there a setting to change it so ReSharper leaves my line endings alone? Nothing is jumping out at me.

Explanation of how I verified it below...

It looks like when I use ReSharper and do a complete code cleanup, it will change my line endings to CRLF, regardless of what they were before.

I've proven this to myself by having a file open in VS2010, doing File -> Advanced Save Options and changing line style to Unix (LF)

In Notepad++ I turn on viewing line endings and see only LF at the end of the lines.

Then, I do a ReSharper code cleanup, and CRLF shows up everywhere.

Platino answered 12/8, 2011 at 15:36 Comment(2)
Please file a bug report at youtrack.jetbrains.netBramble
Done: youtrack.jetbrains.net/issue/RSRP-274916?projectKey=RSRPPlatino
H
4

Under Resharper / Options / Code Editing / General Formatter Style / Default Line Ending Style you can select - Current OS | Windows | Mac | Unix

Hexagonal answered 7/6, 2019 at 11:6 Comment(1)
This didn't exist before the bug fix here: youtrack.jetbrains.com/issue/RSRP-274916 It is now, 100% the right answer (back in 2012 when I asked this, there was sadly no right answer :) )Platino
A
2

ReSharper configuration window

Do not forget to also ensure your git settings are accurate for line endings. If you're like me, you ended up here because you keep your source code on a Mac and run Visual Studio within windows. You need to ensure your git settings also include the right "core.autocrlf" setting.

https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration

Ambidexterity answered 3/8, 2020 at 20:15 Comment(1)
Those are excellent points, and if I could award dual correct answers I would, but the other answer was first.Platino
L
-4

CRLF line ending is hard-coded in ReSharper since version 1.0.

The main reason for this - VS running under Windows, where CRLF ending is standard. Your project must have been very special to not use Windows defaults for text files

Lydgate answered 5/7, 2012 at 16:43 Comment(1)
Nope, it's not so special :) We just interact with devs on OSX and Linux and I'd like everywhere to have the same line endings. Certain operations produce mixed EOL, and I happened to find ReSharper is one of them. I think they're addressing it in ReSharper 7.0 if I read that ticket right so it's all good.Platino

© 2022 - 2024 — McMap. All rights reserved.