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

Wrong whitespace added to csproj #113

Closed
viceice opened this issue Aug 19, 2020 · 4 comments
Closed

Wrong whitespace added to csproj #113

viceice opened this issue Aug 19, 2020 · 4 comments

Comments

@viceice
Copy link
Contributor

viceice commented Aug 19, 2020

editorconfig:

  • max_line_length = 120

current:

<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ProjectTypeGuids>
      {C1CDDADD-2546-481F-9697-4EA41081F2FC};{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
    </ProjectTypeGuids>
</Project>

expected

<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ProjectTypeGuids
        >{C1CDDADD-2546-481F-9697-4EA41081F2FC};{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</Project>

msbuild tooling has problems with the added whitespaces. 😢 Current workaround is to extend max_line_length = 160

@viceice
Copy link
Contributor Author

viceice commented Aug 19, 2020

also this doesn't work because VSToolsPath now has whitespaces.

  <PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">
      $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
    </VSToolsPath>
  </PropertyGroup>
  <Import
    Project="$(VSToolsPath)\SharePointTools\Microsoft.VisualStudio.SharePoint.targets"
    Condition="'$(VSToolsPath)' != ''"

@kddnewton
Copy link
Member

In your configuration do you have it so that it's ignoring whitespace?

@viceice
Copy link
Contributor Author

viceice commented Aug 31, 2020

Yes, otherwise it wouldn't align xml elements

@kddnewton
Copy link
Member

kddnewton commented Aug 31, 2020

So that's the problem. In XML every tag is by default whitespace-sensitive unless the schema otherwise specifies, which is why by default we do our best to preserve whitespace under whitespaceSensitivity=strict. If you switch it to ignore, it's going to ignore whitespace sensitivity entirely. What it seems like you want in this case is some elements to have whitespace sensitivity and some not, which we don't currently support.

The best advice I can offer you is to keep it so that it's ignoring whitespace sensitivity, but then to wrap anything that you explicitly need it to respect whitespace with a prettier ignore comment, as in:

<PropertyGroup>
  <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
  <!-- prettier-ignore-start -->
  <VSToolsPath Condition="'$(VSToolsPath)' == ">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
  <!-- prettier-ignore-end -->
</PropertyGroup>

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