Skip to content

Setup common Roslyn analyzer rules #9620

Closed
@JamesNK

Description

@JamesNK

Microsoft.CodeAnalysis.FxCopAnalyzers provides code analysis of rules ASP.NET Core code should always follow. For example, we should always consider culture when comparing strings, and converting values to and from strings. That would help avoid culture related bugs, e.g. #9537, #6059

And in aspnet/Extensions we should also always require ConfigureAwait to avoid sync over async deadlocks in apps that have a sync context, e.g. .NET Core WPF. e.g. dotnet/extensions#999 Related: https://github.com/aspnet/Extensions/issues/1440

I think the number of rules enabled should be small, and only be rules that should always be followed. We don't want source code covered with suppressions.

I've just enabled the FxCop analyzers on Newtonsoft.Json and I think this ruleset is a good starting point - https://github.com/JamesNK/Newtonsoft.Json/blob/cc2ef36f5533d1ab21518a8e9ec5c2f74eb2fecc/Src/Newtonsoft.Json/Newtonsoft.Json.ruleset

Metadata

Metadata

Assignees

Labels

area-infrastructureIncludes: MSBuild projects/targets, build scripts, CI, Installers and shared framework

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions