dotnet / dotnet/format

`dotnet format` command does not fix code when we use `WarningsNotAsErrors`

Open
#1,643 3 comments 1 reaction 0 assignees View on GitHub
Area-IDE untriaged
Dominant language
No language data
Stars
1.9k
Forks
173
Avg merge
10d 13h
Merged PRs (30d)
1

Description

**Version Used**:
.NET SDK 6.0.300
C# 10.0
StyleCop.Analyzers 1.2.0-beta.435
Visual Studio 2022 Ver. 17.2.1
**Steps to Reproduce**:
I think these are two different problems.
1. The rules that are in the .globalconfig only work for Visual Studio
For example, I use the rule `SA1210` only work for Visual Studio too.

1. I have created a console application. Where not sorted alphabetically by namespace.
` using System.Text;
using Newtonsoft.Json;
using Moq;
using System.Linq;
using AutoMapper;`

2. And the rule is added to `.globalconfig` `dotnet_diagnostic.SA1210.severity = warning`
Also added to `build.props` `SA1210`

Inside the studio, everything works and I get warnings about it.
![Screenshot 2022-06-14 091117](https://user-images.githubusercontent.com/17515244/173527726-6a6334a9-7fb9-4dd0-be47-1be4e4619898.png)

But when using the command `dotnet fornat` , the code is not formatted.
For the command `dotnet format` to work.
I need to move a rule from .globalconfig to .editorconfig
And remove the line `SA1210` from build.props
Then the code is formatted

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.