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

dotnet_sort_system_directives_first = true does not show in VS error list or cause build error #77024

Closed
golddove opened this issue Feb 4, 2025 · 2 comments

Comments

@golddove
Copy link

golddove commented Feb 4, 2025

Version Used: VS 17.12.4, .NET Core 8

Steps to Reproduce:

  1. Start with:

Directory.Build.props

<Project>
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <AnalysisLevel>latest-all</AnalysisLevel>
    <AnalysisMode>All</AnalysisMode>
    <EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <EnableNETAnalyzers>true</EnableNETAnalyzers>

.editorconfig

[*.{cs,vb}]
# Organize usings
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = true
dotnet_diagnostic.IDE0055.severity = error
dotnet_diagnostic.IDE0065.severity = error

Sample class:

using Microsoft.Extensions.Logging;
using System;

namespace MyNamespace;

public class MyClass {
  1. Observe that VS now shows an error line w/ rule IDE0055 due to the missing extra line between groups. Attempt dotnet build and observe the same error on build.
  2. Removing the dotnet_separate_import_directive_groups = true from editorconfig resolves all errors in both VS and dotnet build. Alternatively, adding an extra line resolves all errors in both VS and dotnet build. So, .editorconfig and error severity are working correctly. However, there are no errors for the System using not being first.
  3. Run Remove and Sort Usings in VS, or dotnet format. Note that the System using is moved to the top.

Diagnostic Id: IDE0055

If this is a report about a bug in an analyzer, please include the diagnostic ID and message if possible (e.g. "IDE0030: Use coalesce expression").

Expected Behavior: Expected to see a VS error and dotnet build error because System using is not first.

Actual Behavior: Usings of any order are allowed without any complains.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 4, 2025
@CyrusNajmabadi
Copy link
Member

Closing out as by design. There is no analyzer here. This is just a config knob controlling the 'organize usings' feature.

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Feb 4, 2025
@dotnet-policy-service dotnet-policy-service bot removed the untriaged Issues and PRs which have not yet been triaged by a lead label Feb 4, 2025
@CyrusNajmabadi
Copy link
Member

IDE0055 due to the missing extra line between groups.

NOte: IDE0055 is about formatting, which is about incorrect whitespace in a file. Things like order of code elements is not a formatting concern.

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

2 participants