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

EditorConfig is not used for files included as content #25888

Closed
mikkelbu opened this issue Apr 2, 2018 · 1 comment
Closed

EditorConfig is not used for files included as content #25888

mikkelbu opened this issue Apr 2, 2018 · 1 comment

Comments

@mikkelbu
Copy link
Contributor

mikkelbu commented Apr 2, 2018

Version Used:
Visual Studio Version 15.3.5

Steps to Reproduce:

  1. Have a project file - in the new format - that includes a file (ClassB.cs) as content
<Project Sdk="Microsoft.NET.Sdk">

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

  <ItemGroup>
    <Compile Remove="ClassB.cs" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="ClassB.cs" />
  </ItemGroup>

</Project>
  1. And have a .editorconfig file that the class does not follow (e.g. ClassB.cs is written using TABs). Note that the .editorconfig should also be different from the default settings in VS.
root = true

[*]
indent_style = space
indent_size = 7
  1. When opening ClassB.cs it is noted "user preferences for this file type are overridden by this project's coding conventions". However, when manipulating the file (e.g. removing and readding the last } or using "Format Document") the settings used are not taken from the .editorconfig file, but from the settings in VS.

I've uploaded a small example to https://github.com/mikkelbu/EditorConfig-and-ContentFiles. The example contains two C# files ClassA.cs and ClassB.cs that are identical except for the class name, and both files use TABs (thus not following the .editorconfig in the project). ClassA is compiled, whereas the content of ClassB is copied to the output.

When applying "Format Document" only ClassA make use of the .editorconfig-settings (ClassB "just" uses the standard settings in VS).

Expected Behavior:
That the configuration in .editorconfig is also used for files included as content.

Actual Behavior:
That the (default) VS configuration is used for files included as content.

mikkelbu added a commit to mikkelbu/nunit.analyzers that referenced this issue Apr 18, 2018
Only indention I think (tabs and 2 spaces => 4 spaces).

(By changing my VS defaults, as .editorconfig is not applied to
files included as content, see dotnet/roslyn#25888)
@jinujoseph jinujoseph added the Bug label Jun 19, 2018
@jinujoseph jinujoseph added this to the 16.0 milestone Jun 19, 2018
@jinujoseph jinujoseph modified the milestones: 16.0, 16.1.P1 Jan 18, 2019
@jinujoseph jinujoseph modified the milestones: 16.1.P1, Backlog Apr 24, 2019
@CyrusNajmabadi
Copy link
Member

Yes. This is by design. Content files are just content. THey are not treated as code that would be affected.

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants