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

dotnet-format creates empty files if non-existant file is given with charset #671

Closed
legionaryu opened this issue May 11, 2020 · 5 comments · Fixed by #775
Closed

dotnet-format creates empty files if non-existant file is given with charset #671

legionaryu opened this issue May 11, 2020 · 5 comments · Fixed by #775
Labels
Bug This issue describes behavior that is not working as expected
Milestone

Comments

@legionaryu
Copy link

legionaryu commented May 11, 2020

I'm using dotnet-format with Unity3D and for some reason every time I try to format using the project files generated by Unity3D , the dotnet-format creates some empty files and it breaks the Unity3D c-sharp compilation and I have to manually remove the empty files to make it work again.

For now, I'm formatting folders instead of the .sln/.csproj files.

@legionaryu legionaryu changed the title dotnet-format is ignoring indent_style from editorconfig dotnet-format is creating empty files May 11, 2020
@legionaryu legionaryu reopened this May 11, 2020
@jmarolf
Copy link
Contributor

jmarolf commented May 11, 2020

@legionaryu what are the names of these empty files? Can you provide steps to reproduce the issue?

@legionaryu
Copy link
Author

legionaryu commented May 11, 2020

@jmarolf Just letting you know that I'm trying to isolate the issue because of the original project has sensitive information, so I cannot share it.
As soon as I'm able to reproduce it in another environment I'll upload it here.

@jmarolf jmarolf reopened this May 11, 2020
@jmarolf
Copy link
Contributor

jmarolf commented May 11, 2020

Thanks @legionaryu! I understand that it can sometime be hard to reduce these cases. If you could tell me the version of dotnet format you are using as well as the commandline args that would be a great start.

@legionaryu
Copy link
Author

Hi @jmarolf!
Good news, I was able to reproduce the issue with the attached project.
EmptyFile.zip

My version of dotnet-format is 3.3.111304+7c8f67a570f5fde6a247704733d6742f93c0fa48

From my tests, I was able to conclude that if a non-existant file is referenced in the csproj and the .editorconfig explicitly set a charset, the formatter creates an empty file with its name.

Here my csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Empty.cs" /> <!--This file DOESN'T exists-->
  </ItemGroup>

</Project>

And here is my .editorconfig:

root = true

[*.*]
charset = utf-8

@jmarolf jmarolf changed the title dotnet-format is creating empty files dotnet-format creates empty files if non-existant file is given with charset May 11, 2020
@jmarolf
Copy link
Contributor

jmarolf commented May 11, 2020

@legionaryu thanks! I've updated the title to reflect this.

@JoeRobich JoeRobich added the Bug This issue describes behavior that is not working as expected label Aug 9, 2020
@jmarolf jmarolf added this to the 5.0 milestone Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This issue describes behavior that is not working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants