Once and For All: Mac Visual Studio - fix inconsistent line endings?

I’ve been through every discussion that I can find in this forum and on the Web, and yet no solution that works to fix this inconsistent line endings issue on Mac Visual Studio Community 2019.

  1. No, on Mac VS there is no Savebutton dropdown where you can choose the encoding.
  2. There are no line-ending-fixer addons/plugin tools that are compatible with Mac VS.
  3. Choosing Save As with UTF-8 or any of the other formats does not seem to fix it.
  4. None of the preferences encoding options seem to fix it.
  5. Nor those in the project settings option (which just mirror the prefs)

I am looking for a solution for existing files.

Maybe there is some combination I am missing? Does anyone have a solution for Mac VS that is working for you?

This is very ridiculous issue indeed, I’ve spent way more time fixing it than I should have. Solution that worked for me (LF encoding):

  1. In Visual Studio, go to Preferences → Text Editor → General and set Line ending conversion to Always Convert Line Endings

  2. Then back to Preferences → Source Code → Code Formatting → C# source code (or some other file types if you work with them) and change Line ending property to Unix/Mac. These two should prevent Visual Studio to generate Windows line endings in your files.

  3. About fixing the existing files, I couldn’t find any good way to do it in VS, but you can use other text editor/IDE to change line encoding. I’ve just formatted and saved all files with inconsistent line endings using VS Code.

I hope this helps!

Can’t find a way to fix it in Visual Studio Mac 8.6 (Unity 2019.3.14).

I use:

dos2unix file.cs

and the warning message is gone.