dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.1k stars 4.04k forks source link

Source Generators: suppress inconsistent line ending popup dialog #54633

Open AArnott opened 3 years ago

AArnott commented 3 years ago

Version Used: Dev17 preview 2 (31502.19.main)

Steps to Reproduce:

  1. Create a C# project.
  2. Add <PackageReference Include="Microsoft.Windows.CsWin32" Version="0.1.506-beta" PrivateAssets="all" /> to the project file.
  3. Add a NativeMethods.txt file to the project directory with CreateFile as its entire content.
  4. Open the generated code file, either using Go To All with CreateFile as the search term or through Solution Explorer's Analyzers node.

Expected Behavior:

Generated code file opens.

Actual Behavior:

The file opens, but also asks the user if they want to normalize line endings: image

Inconsistent line endings should have no impact on the user, and in fact on the same screen, you can see in the screenshot that VS is asking the user to change the file in the modal dialog and also advising them that they cannot change the generated file via the infobar across the top of that document.

sharwell commented 3 years ago

This is unbelievably agonizingly horrible. Definitely needs to be fixed somehow.

olegtk commented 3 years ago

The file is not readonly as far as the editor is concerned (I see no lock icon on the tab) so we go ahead with this dialog. Can Roslyn set BSF_USER_READONLY on the text buffer for such documents perhaps?

Eli-Black-Work commented 2 years ago

Just ran into this today and was surprised. Would love to see it fixed 🙂

CyrusNajmabadi commented 1 month ago

Moving to 17.13. @sharwell can you pleease make sure the document is marked as readonly when we open it?