Skip to main content

Questions tagged [stylecop]

StyleCop analyzes C# source code to enforce a set of style and consistency rules.

stylecop
0 votes
0 answers
42 views

How to Include and Apply stylecop.json and Custom Ruleset in a NuGet Analyzer Package

This post is a follow-up from this How to create nuget package with Stylecop Analyzer and custom ruleset? I am currently working on a nuget package with custom analyzers, a stylecop.json, and a Custom....
Ruwiwidi's user avatar
2 votes
1 answer
101 views

How to enforce file-scoped namespaces with StyleCop

I want this namespace SampleCode { public class MyClass { } } to become this namespace SampleCode; public class MyClass { } with the help of StyleCop. Is there any standard or custom ...
Ivan Bukashkin's user avatar
0 votes
0 answers
83 views

Stylecop rules gets ignored in the IDE?

I have a Stylecop ruleset that looks like this : <?xml version="1.0" encoding="utf-8"?> <RuleSet Name="CustomRules" Description="Custom StyleCop Ruleset&...
CHADTO's user avatar
  • 351
1 vote
1 answer
218 views

Ignore StyleCop rule in Visual Studio Code

I do my development in Visual Studio Code and have recently started using StyleCop to improve my coding style in C#. In my .csproj file, I added a PackageReference to StyleCop.Analyzers and can now ...
Brian Diggs's user avatar
  • 58.5k
1 vote
1 answer
872 views

Add custom rule to a C# project with StyleCop in VS 2022

I can't seem to find a good tutorial to add some custom styling rules that are not already customizable in StyleCop For example, creating a rule to check for N levels of nested blocks in loops or ...
Fernando Diaz Rojas's user avatar
0 votes
0 answers
36 views

StyleCop SA1649 rule not being honored

The rule SA1649 is under Documentation category but is not being honored when I add "dotnet_analyzer_diagnostic.category-Documentation.severity = error" in .editorconfig file. It's also not ...
Satashree Roy's user avatar
0 votes
0 answers
77 views

StyleCop on Azure Pipeline dotnet publish, The "StyleCopTask" task could not be loaded from the assembly

I keep getting the following error on the pipeline when trying to do "dotnet publish". I'm trying to run this on an ubuntu environment. Error from Azure pipeline This is the full error line: ...
Sam's user avatar
  • 1
0 votes
1 answer
389 views

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 ...
Jay's user avatar
  • 1,930
1 vote
1 answer
401 views

Change the severity of all StyleCop rules using .editorconfig

How can I change the severity of all StyleCop rules using .editorconfig? Configuring individual rules works: dotnet_diagnostic.SA1202.severity = error However, I'm looking for a global change that ...
user246392's user avatar
  • 2,863
1 vote
1 answer
402 views

How to Disable the StyleCop add project and header info from Intellisense Visual Studio

I use StyleCop with Visual Studio 2022. For my Solutions, I use an .editorconfig file to manage all of my StyleCop analyzer rules. I also have the rule 1633 File should have header disabled as I do ...
Jeremy's user avatar
  • 626
2 votes
0 answers
880 views

dotnet build --no-restore execute restore implicitly

I'm using dotnet build --no-restore command to don't execute the restore of nuget packages in my project. But what I see in the output is this anyway: PS C:\...> dotnet build --no-restore MSBuild ...
Daniele Tentoni's user avatar
0 votes
1 answer
140 views

Not getting error on changing the coding validation rule in stylecop.json

I made followinh changes to the stylecop.json file "orderingRules": {"usingDirectivesPlacement": "insideNamespace"} But i am only getting warning and not error in the cs ...
ASW's user avatar
  • 37
2 votes
1 answer
92 views

Stylecop is interfering with EfBundle creation in docker image in gitlab CI

I have stylecop configured in my project and when I run RUN dotnet ef migrations bundle --project {CSPROJ_PATH}.csproj -r alpine.3.7-x64 --self-contained --configuration Bundle -o /build/...
VyasKuldeep's user avatar
9 votes
0 answers
2k views

IDE0005 not reported as build failure even with GenerateDocumentationFile set to true

I want the build of my project to fail if there are unused usings. In csproj I have added: <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> <GenerateDocumentationFile>true</...
Satashree Roy's user avatar
2 votes
0 answers
43 views

How to make StyleCop allow "_" discard in LINQ query syntax?

StyleCop returns the warning Variable '_' should begin with lower-case letter when the '_' is used as a discard in a LINQ query-syntax block: Is there any way to globally configure StyleCop in a ...
Appetere's user avatar
  • 6,123

15 30 50 per page
1
2 3 4 5
44