Skip to content

Code style analyzers package doesn't load global config files on Linux #58948

@ArturDorochowicz

Description

@ArturDorochowicz

Version Used: Microsoft.CodeAnalysis.CSharp.CodeStyle 4.0.1

The package doesn't load its own predefined globalconfig files on case sensitive file systems.

The package contains the following relevant files:

build
   config
      AnalysisLevelStyle_None.editorconfig
      AnalysisLevelStyle_Recommended.editorconfig
      AnalysisLevelStyle_All.editorconfig
      AnalysisLevelStyle_Default.editorconfig 
      AnalysisLevelStyle_Minimum.editorconfig
   Microsoft.CodeAnalysis.CSharp.CodeStyle.targets
   Microsoft.CodeAnalysis.CSharp.CodeStyle.props"

The code in Microsoft.CodeAnalysis.CSharp.CodeStyle.targets that loads the config file, builds the path with ToLowerInvariant() and therefore doesn't load anything on case sensitive file systems, e.g. on Linux:

<_GlobalAnalyzerConfigFileName_MicrosoftCodeAnalysisCSharpCodeStyle>AnalysisLevelStyle_$(_GlobalAnalyzerConfigAnalysisMode_MicrosoftCodeAnalysisCSharpCodeStyle).editorconfig</_GlobalAnalyzerConfigFileName_MicrosoftCodeAnalysisCSharpCodeStyle>
<_GlobalAnalyzerConfigFileName_MicrosoftCodeAnalysisCSharpCodeStyle>$(_GlobalAnalyzerConfigFileName_MicrosoftCodeAnalysisCSharpCodeStyle.ToLowerInvariant())</_GlobalAnalyzerConfigFileName_MicrosoftCodeAnalysisCSharpCodeStyle> 

Steps to Reproduce:

  1. dotnet new globaljson --sdk-version 6.0.101
  2. dotnet new web
  3. dotnet add package Microsoft.CodeAnalysis.CSharp.CodeStyle --version 4.0.1
  4. dotnet build -p:AnalysisLevelStyle=Recommended -p:AnalysisLevelSuffixStyle=Recommended

On Linux this incorrectly runs with no warnings:

dotnet build -p:AnalysisLevelStyle=Recommended -p:AnalysisLevelSuffixStyle=Recommended
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /home/ubuntu/bug1/bug1.csproj (in 222 ms).
  bug1 -> /home/ubuntu/bug1/bin/Debug/net6.0/bug1.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.42

On Windows the build has warnings, as expected:

Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
 
  Determining projects to restore...
  Restored [...]\bug1\bug1.csproj (in 298 ms).
[...]\bug1\Program.cs(1,1): warning IDE0008: Use explicit type instead of 'var' [[...]\bug1\bug1.csproj]
[...]\bug1\Program.cs(2,1): warning IDE0008: Use explicit type instead of 'var' [[...]\bug1\bug1.csproj]
  bug1 -> [...]\bin\Debug\net6.0\bug1.dll

Build succeeded.
[...]\bug1\Program.cs(1,1): warning IDE0008: Use explicit type instead of 'var' [[...]\bug1\bug1.csproj]
[...]\bug1\Program.cs(2,1): warning IDE0008: Use explicit type instead of 'var' [[...]\bug1\bug1.csproj]
    2 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.41

Expected Behavior:
The package should correctly load the specified config file under Linux. Just like it does on Windows.

Actual Behavior:
The package does not load the config file under Linux.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions