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
IDE0130 is not reported correctly in 8.0.2xx #73261
Comments
I encountered the same problem. I tested with the following directory structure.
The contents of the file are as follows.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<RootNamespace>MyProgram</RootNamespace>
</PropertyGroup>
<Target Name="ShowCompilerVisibleProperties" BeforeTargets="Build">
<!--
Check if CompilerVisibleProperty contains RootNamespace and ProjectDir.
For IDE0130 to work, the CompilerVisibleProperty must contain RootNamespace and ProjectDir.
ref: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0130
-->
<Message Text="CompilerVisibleProperty: @(CompilerVisibleProperty)" Importance="high" />
<Message Text="RootNamespace: $(RootNamespace)" Importance="high" />
<Message Text="ProjectDir: $(ProjectDir)" Importance="high" />
</Target>
</Project>
namespace MyProgram;
class Program
{
public static void Main()
{
Console.WriteLine(GetHelloWorldString());
// Warning IDE0061 is expected here, and is reported as expected
static string GetHelloWorldString()
{
return "Hello, World!";
}
}
}
namespace MyProgram.MyLibrary;
class Class1 { }
// Warning IDE0130 is expected here, but is not reported on .NET SDK 8.0
namespace MyProgram.NamespaceNotMatch;
class Class2 { } .NET SDK 8.0.100
.NET SDK 8.0.202The expected
.NET SDK 6.0.418
|
Same problem here. I have set the |
I'm finding the same issue with what seems to be any analyzer warning that has a code fixer. For example, where IDE0057 is present it is not detected or fixed with the ❯ dotnet build
MSBuild version 17.9.6+a4ecab324 for .NET
Determining projects to restore...
All projects are up-to-date for restore.
C:\Coding\martincostello\_repro\Person.cs(14,62): error IDE0057: Substring can be simplified (https://learn.micros
oft.com/dotnet/fundamentals/code-analysis/style-rules/ide0057) [C:\Coding\martincostello\_repro\Project.csproj]
Build FAILED.
C:\Coding\martincostello\_repro\Person.cs(14,62): error IDE0057: Substring can be simplified (https://learn.micros
oft.com/dotnet/fundamentals/code-analysis/style-rules/ide0057) [C:\Coding\martincostello\_repro\Project.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.35
Coding\martincostello\_repro via .NET v8.0.203 🎯 net8.0
❯ dotnet format analyzers --verbosity diagnostic
The dotnet runtime version is '8.0.3'.
The dotnet CLI version is '8.0.203'.
Using MSBuild.exe located in 'C:\Program Files\dotnet\sdk\8.0.203\'.
Formatting code files in workspace 'C:\Coding\martincostello\_repro\Project.csproj'.
Loading workspace.
Determining projects to restore...
All projects are up-to-date for restore.
Project Project is using configuration from 'C:\Coding\martincostello\_repro\.editorconfig'.
Project Project is using configuration from 'C:\Coding\martincostello\_repro\obj\Debug\net8.0\Project.GeneratedMSBuildEditorConfig.editorconfig'.
Project Project is using configuration from 'C:\Program Files\dotnet\sdk\8.0.203\Sdks\Microsoft.NET.Sdk\analyzers\build\config\analysislevel_8_all.globalconfig'.
Complete in 3369ms.
Determining formattable files.
Complete in 189ms.
Running formatters.
Running Analyzer Reference analysis.
Determining diagnostics...
Running 146 analyzers on Project.
Complete in 2233ms.
Fixing diagnostics...
Complete in 3ms.
Analysis complete in 2236ms.
Complete in 2806ms.
Formatted 0 of 3 files.
Format complete in 6372ms. Downgrading to the ❯ dotnet format analyzers --verbosity diagnostic
The dotnet runtime version is '8.0.3'.
The dotnet CLI version is '7.0.407'.
Using MSBuild.exe located in 'C:\Program Files\dotnet\sdk\7.0.407\'.
Formatting code files in workspace 'C:\Coding\martincostello\_repro\Project.csproj'.
Loading workspace.
Determining projects to restore...
All projects are up-to-date for restore.
Project Project is using configuration from 'C:\Coding\martincostello\_repro\.editorconfig'.
Project Project is using configuration from 'C:\Coding\martincostello\_repro\obj\Debug\net7.0\Project.GeneratedMSBuildEditorConfig.editorconfig'.
Project Project is using configuration from 'C:\Program Files\dotnet\sdk\7.0.407\Sdks\Microsoft.NET.Sdk\analyzers\build\config\analysislevel_7_all.editorconfig'.
Complete in 4625ms.
Determining formattable files.
Complete in 206ms.
Running formatters.
Running Analyzer Reference analysis.
Determining diagnostics...
Running 225 analyzers on Project.
Complete in 2896ms.
Fixing diagnostics...
Running 1 analyzers on Project.
Complete in 1137ms.
Analysis complete in 4033ms.
Complete in 4736ms.
Formatted code file 'C:\Coding\martincostello\_repro\Person.cs'.
Formatted 1 of 3 files.
Format complete in 9611ms. Repro
|
I observe the same behaviour. dotnet format detects the issues and reports them. However, dotnet build does not report any errors, although I have enabled Used ProjectProject tree .
│ .editorconfig
│ AnalyzerDotNetSdkCheck.csproj
│ AnalyzerDotNetSdkCheck.sln
│ global.json
│
└───Test
AnalyzerTestHeader.cs
AnalyzerTestNamespace.cs .editorconfig
AnalyzerDotNetSdkCheck.csproj
AnalyzerTestHeader.cs The header is missing in this file. namespace AnalyzerDotNetSdkCheck.Test
{
/// <summary>
/// Lorem Ipsum
/// </summary>
public class AnalyzerTestHeader
{
}
} AnalyzerTestNamespace.cs The namespace does not match the folder structure in this file. // ---TestHeader---
namespace AnalyzerDotNetSdkCheck.Test.Analyzer
{
/// <summary>
/// Lorem Ipsum
/// </summary>
public class AnalyzerTestHeader
{
}
} Output with dotnet SDK 6.0.128global.json {
"sdk": {
"version": "6.0.100",
"rollForward": "latestFeature"
}
} dotnet version
dotnet build
dotnet format
Output with dotnet SDK 7.0.407global.json {
"sdk": {
"version": "7.0.100",
"rollForward": "latestFeature"
}
} dotnet version
dotnet build
dotnet format
Output with dotnet SDK 8.0.203global.json {
"sdk": {
"version": "8.0.100",
"rollForward": "latestFeature"
}
} dotnet version
dotnet build
dotnet format
|
@jaredpar can I get permissions to transfer things over to the Roslyn repos? |
@marcpopMSFT I'm not sure what permission you need. Do you know |
@ToddGrun, @arkalyanms looks to be another variation of the editor config regressions |
Describe the bug
Even though the corresponding dotnet style is set to produce a warning, the build doesn't produce the warning when an incorrect namespace is present.
To Reproduce
dotnet_style_namespace_match_folder = true
dotnet_diagnostic.IDE0130.severity = warning
Further technical details
dotnet build
The text was updated successfully, but these errors were encountered: