Questions tagged [dotnet-format]
12 questions
10
votes
2 answers
Apply dotnet-format on save in Visual Studio?
I just discovered dotnet-format, but as far as I understand it's a command line tool that has to be called manually. How can I apply dotnet-format on saving a file in Visual Studio 2019? (not Visual Studio Code!)

stefan.at.kotlin
- 15,347
- 38
- 147
- 270
3
votes
1 answer
How to use dotnet format to format the whole project inside a subfolder?
I have a .Net 5 app and want to use dotnet format. First I added commitlint, husky and lint-staged to the repository. The folder structure looks like
.
├── package.json
└── MyCsharpProject
├── MyCsharpProject.sln
└── Assembly1
The…

Question3r
- 2,166
- 19
- 100
- 200
2
votes
1 answer
Dotnet-format not running in Github Action due to missing assembly
I've created a Github action to run dotnet format --verify-no-changes as part of our CI to check for formatting errors. Since to latest update of the Windows server from
OS Version: 10.0.20348 Build 1668
Image Version: 20230508.3
to
OS Version:…

ftramnitzke
- 151
- 9
2
votes
0 answers
Why is my editorconfig not throwing a naming error?
Applying a dotnet_naming_rule is not triggering a warning via dotnet format.
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
#### Naming rules ####
#…

Ryan
- 6,432
- 7
- 40
- 54
1
vote
0 answers
How can I convince the architect to allow me to format code?
In our team there is a refactoring sprint where we are allowed to refractor the code base. Now I discovered formatting with 'dotnet format' which automatically formats the whole solution.
The architect in our team has a pretty strong opinion about…

max
- 21
- 2
1
vote
0 answers
Use dotnet-format to change to file-scoped namespaces in C#10
I want to format a file to "file-scoped namespaces". I want to make that change only.
My .editorconfig contains this only:
[*.cs]
csharp_style_namespace_declarations = file_scoped:warning # config for IDE0161
A test file Foo.cs:
namespace…

lonix
- 14,255
- 23
- 85
- 176
0
votes
2 answers
How to make `dotnet-format` ignoring certain directory?
I have the following lines defined in my .editorconfig file:
# Ignore paths
[Assets/NRSDK/*]
[Assets/VLCUnity/*]
generated_code = true
But they are ineffective, every time I run dotnet-format it still format everything under them. Is it feature…

tribbloid
- 4,026
- 14
- 64
- 103
0
votes
0 answers
How to use `dotnet format` to apply specific StyleCop rule globally?
I have installed StyleCop.Analyzers on my project that is written using C#. The rules severity are set to suggestion.
How can I apply specific rules on the entire project using dotnet format?
I tried executing dotnet format --diagnostics SA1122 to…

Jay
- 1,168
- 13
- 41
0
votes
0 answers
Github Super Linter - C# Linter is not doing any style checks
I have set up Github super linter to lint C# files in my project. I added the rules in a .editorconfig file. But when I run the linter, I only get a bunch of whitespace errors and none of the styling or other errors. For e.g., I added a rule for…

bitsandgates
- 315
- 1
- 3
- 7
0
votes
1 answer
C# formatting with .editorconfig: can I use a different naming style for unit tests?
Is there a way to specify in an .editorconfig file that I want to use a different naming style for my Unit tests?
Currently we're using something like this: GetAll_GivenNoCustomers_ReturnsEmptyList but I get the suggestion to remove the underscores…

Thomas Mulder
- 740
- 10
- 26
0
votes
1 answer
How to ignore all whitespace issues when using dotnet format?
How to ignore all whitespace issues when using dotnet format?
I've generated an .editorconfig with mostly default options using these docs.
When I run this command...
dotnet format .\.sln --verify-no-changes
...I see errors like:…

derekbaker783
- 8,109
- 4
- 36
- 50
-1
votes
1 answer
dotnet format validation throws dll not found
I want to validate the code style of my application according to the .editorconfig. For this task I use a local hosted agent in an azure (2019) ci pipeline. I'm only allowed to use local feeds. So I downloaded dotnet-format in version 5.1.225507 and…

finder2
- 842
- 1
- 11
- 30