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

Warning: Filename was not formatted - The file contained different line endings than formatting it would result in #757

Closed
GavinRay97 opened this issue Nov 12, 2022 · 7 comments

Comments

@GavinRay97
Copy link

GavinRay97 commented Nov 12, 2022

I installed csharpier originally through the Rider extension, and let it auto-install the dotnet tool for me.
It works perfectly in Rider. However the VS Code extension does not work, it fails to format on save.

I tried manually re-installing with:

PS C:\Users\rayga\WindowsProjects\bustub-dotnet-new> dotnet tool uninstall -g csharpier
Tool 'csharpier' (version '0.20.0') was successfully uninstalled.

PS C:\Users\rayga\WindowsProjects\bustub-dotnet-new> dotnet tool install -g csharpier
>> 
You can invoke the tool using the following command: dotnet-csharpier
Tool 'csharpier' (version '0.20.0') was successfully installed.

But running it gives this:

PS C:\Users\rayga\WindowsProjects\bustub-dotnet-new> dotnet-csharpier . --check
Warning ./Database.Test/Usings.cs - Was not formatted.
  The file contained different line endings than formatting it would result in.
Warning ./Database.Test/UnitTest1.cs - Was not formatted.
  ----------------------------- Expected: Around Line 9 -----------------------------
  ····[SetUp]
  ····public·void·Setup()·{·}

  ----------------------------- Actual: Around Line 9 -----------------------------
  ····[SetUp]
  ········public·void·Setup()
  ····{···
Warning ./Database/Program.cs - Was not formatted.
  The file contained different line endings than formatting it would result in.
Total time:                                                                          611ms
Total files:                                                                           7
Files that were not formatted:                                                         3

The output with debug enabled from VS Code extension is below:

  • (It seems there may actually be two issues here, one about the line endings, and one with this NullCSharpierProcess )
["INFO" - 3:32:19 PM] Initializing csharpier-vscode
["INFO" - 3:32:31 PM] Formatting started for c:\Users\rayga\WindowsProjects\bustub-dotnet-new\Database.Test\UnitTest1.cs.
["DEBUG" - 3:32:31 PM] Ensure there is a csharpier process for c:\Users\rayga\WindowsProjects\bustub-dotnet-new\Database.Test
["DEBUG" - 3:32:31 PM] Looking for c:\Users\rayga\WindowsProjects\bustub-dotnet-new\Database.Test/*.csproj
["DEBUG" - 3:32:31 PM] Looking at c:\Users\rayga\WindowsProjects\bustub-dotnet-new\Database.Test\Database.Test.csproj
["DEBUG" - 3:32:31 PM] Looking for c:\Users\rayga\WindowsProjects\bustub-dotnet-new\Database.Test\.config\dotnet-tools.json
["DEBUG" - 3:32:31 PM] Looking for c:\Users\rayga\WindowsProjects\bustub-dotnet-new/*.csproj
["DEBUG" - 3:32:31 PM] Looking for c:\Users\rayga\WindowsProjects\bustub-dotnet-new\.config\dotnet-tools.json
["DEBUG" - 3:32:31 PM] Looking for c:\Users\rayga\WindowsProjects/*.csproj
["DEBUG" - 3:32:31 PM] Looking for c:\Users\rayga\WindowsProjects\.config\dotnet-tools.json
["DEBUG" - 3:32:31 PM] Looking for c:\Users\rayga/*.csproj
["DEBUG" - 3:32:31 PM] Looking for c:\Users\rayga\.config\dotnet-tools.json
["DEBUG" - 3:32:31 PM] Looking for c:\Users/*.csproj
["DEBUG" - 3:32:31 PM] Looking for c:\Users\.config\dotnet-tools.json
["DEBUG" - 3:32:31 PM] Looking for c:\/*.csproj
["DEBUG" - 3:32:31 PM] Looking for c:\.config\dotnet-tools.json
["DEBUG" - 3:32:31 PM] Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
["DEBUG" - 3:32:31 PM] dotnet csharpier --version output 0.20.0

["WARN" - 3:32:31 PM] Exception while running 'dotnet csharpier --version' in C:\Users\rayga\AppData\Local\CSharpier\0.20.0
"A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\\Program Files\\dotnet\\'.\r\nFailed to run as a self-contained app.\r\n  - The application was run as a self-contained app because 'C:\\Users\\rayga\\AppData\\Local\\CSharpier\\0.20.0\\.store\\csharpier\\0.20.0\\csharpier\\0.20.0\\tools\\net6.0\\any\\dotnet-csharpier.runtimeconfig.json' was not found.\r\n  - If this should be a framework-dependent app, add the 'C:\\Users\\rayga\\AppData\\Local\\CSharpier\\0.20.0\\.store\\csharpier\\0.20.0\\csharpier\\0.20.0\\tools\\net6.0\\any\\dotnet-csharpier.runtimeconfig.json' file and specify the appropriate framework.\r\n"
["ERROR" - 3:32:31 PM] ,,Tool 'csharpier' is already installed.

["DEBUG" - 3:32:31 PM] returning NullCSharpierProcess because of the previous error when trying to set up a csharpier process
["INFO" - 3:32:31 PM] Formatted in 755.9142000079155ms
["DEBUG" - 3:32:31 PM] result is empty
["INFO" - 3:32:37 PM] Formatting started for c:\Users\rayga\WindowsProjects\bustub-dotnet-new\Database.Test\UnitTest1.cs.
["INFO" - 3:32:37 PM] Formatted in 0.10899999737739563ms
["DEBUG" - 3:32:37 PM] result is empty

Running that command myself works fine though (I am using .NET 7.0.100 SDK)

PS C:\Users\rayga\WindowsProjects\bustub-dotnet-new> dotnet csharpier --version
0.20.0
@belav
Copy link
Owner

belav commented Nov 14, 2022

@GavinRay97 I believe you are running into the same as #749 - see the fix for it here #749 (comment)

I think I can modify the extension to detect this condition and recover from it, I created #758 to look into that. It is weird that it works in Rider and not VSCode. If possible, could you try zipping up the folder before deleting it? That will help me with trying to recreate this exact situation so I can detect it properly.

@GavinRay97
Copy link
Author

GavinRay97 commented Nov 14, 2022

Sure, no problem.

You want the project folder and the C:\\Users\\rayga\\AppData\\Local\\CSharpier\\0.20.0\\.store\\csharpier\\0.20.0\\csharpier\\0.20.0\\tools\\net6.0\\any\\dotnet-csharpier.runtimeconfig.json folder, or which ones would you like?

(Fantastic tool you've written, by the way)

@belav
Copy link
Owner

belav commented Nov 15, 2022

Just the folder C:\Users\rayga\AppData\Local\CSharpier\0.20.0 will do it, thanks!

(you're welcome!)

@GavinRay97
Copy link
Author

Sure, here you are:

0.20.0.zip

@belav
Copy link
Owner

belav commented Nov 16, 2022

Thanks! I just took a quick peek, and this is quite a bit different from my 0.20.0 and 0.19.0 folders. Hopefully I can use this to detect this condition and have the extension recover from it

image

@GavinRay97
Copy link
Author

I don't know if you did anything, but suddenly it started working. Is there auto-update on the tool?

@belav
Copy link
Owner

belav commented Nov 27, 2022

I think that the vscode plugins do auto update, but I haven't made any changes. If you deleted the folder yourself that would have fixed the issue.

@belav belav closed this as completed Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants