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.07k stars 4.04k forks source link

Roslyn unable to load analyzer configs if disk letter in path of current directory is not matching file name in analyzerconfig option #50300

Open ghisguth opened 3 years ago

ghisguth commented 3 years ago

Version Used:

Microsoft (R) Visual C# Compiler version 3.8.0-5.20604.10 (9ed4b774)

Steps to Reproduce:

  1. Open command line. Go to directory with .editorconfig. Be sure to change directory using lowercase for drive. E.g. cd c:\Src\Foo\Bar\
  2. Create analyzer config in c:\Src\Foo.editorconfig
  3. Execute csc.exe with /analyzerconfig:C:\Src\Foo\.editorconfig (Note disk letter is upper case C:)

Expected Behavior:

Roslyn will load editor config and apply to all files in c:\Src\Foo\Bar\

Actual Behavior:

Roslyn ignores the config for analyzers.

Details:

Visual Studio impact:

if you open csproj via solution. Visual studio will lowercase disk in path of the csproj and while compile all paths will start from lowercase (e.g. c:\Src\Foo\Bar\Bar.csproj). analyzerconfig option will work as expected.

If you open csproj directly and try to compile. Visual studio will open it with disk as upper case (e.g. C:\Src\Foo\Bar\Bar.csproj). And analyzer config will be ignored.

ghisguth commented 3 years ago
jasonmalinowski commented 3 years ago

@ghisguth Thanks for the detailed analysis here; we'll have to process this one to figure out which layers will need a fix here!

jaredpar commented 3 years ago

I don't think this discussion is only limited to /analyzerConfig. Consider that for options like /pathMap we also treat the argument literally and do no normalization on it.

How we handle file path casing is an aspect of the compiler that I don't think we have an explicit documented plan on. This is likely a good time to do that and add a bit of consistency to how we do it. The general approach we've used to the best of my recollection is:

@chsienki @mavasani @tmat for feedback here as well.