Skip to content

Commit 47ce69f

Browse files
Enforce code style in build and convert errors to suggestions (#1676)
Instead of using `silence` we now use `suggestion` which enables Roslynator and other tools to continue to show the warning, but not block the build. This allows us to set `EnforceCodeStyleInBuild` now, without having to fix everything, which helps prevent future mistakes. Note that many of these should be fixed ASAP, and that we previously thought we'd enabled all the maintainability warnings, but since they are not turned on by default, the category does nothing. Co-authored-by: Andy Schwartzmeyer <[email protected]>
1 parent 3c5a7ae commit 47ce69f

File tree

2 files changed

+47
-7
lines changed

2 files changed

+47
-7
lines changed

.editorconfig

+46-6
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,56 @@ dotnet_diagnostic.CA1823.severity = error
3232
dotnet_diagnostic.CA2007.severity = error
3333
# CA2016: Forward the CancellationToken parameter to methods that take one
3434
dotnet_diagnostic.CA2016.severity = error
35-
# All maintainability issues (dead code etc.)
35+
36+
# TODO: Enable all maintainability issues (dead code etc.) and enforce
3637
# See: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/maintainability-warnings
3738
dotnet_analyzer_diagnostic.category-Maintainability.severity = error
38-
# VSTHRD002: Synchronously waiting on tasks or awaiters may cause deadlocks
39-
# TODO: Fix all of these issues and explicitly ignore the intentional ones.
40-
dotnet_diagnostic.VSTHRD002.severity = silent
39+
40+
# TODO: Fix all of these issues and explicitly ignore the intentional ones!
41+
42+
# CA2016: Forward the CancellationToken parameter to methods that take one
43+
dotnet_diagnostic.CA2016.severity = suggestion
44+
# CS0618: A class member was marked with the Obsolete attribute
45+
dotnet_diagnostic.CS0618.severity = suggestion
46+
# CS0649: Uninitialized private or internal field declaration that is never assigned a value
47+
dotnet_diagnostic.CS0649.severity = suggestion
48+
# CS1998: This async method lacks 'await' operators and will run synchronously
49+
dotnet_diagnostic.CS1998.severity = suggestion
50+
# CS4014: Consider applying the await operator to the result of the call
51+
dotnet_diagnostic.CS4014.severity = suggestion
52+
53+
# RCS1102: Make class static
54+
dotnet_diagnostic.RCS1102.severity = suggestion
55+
# RCS1139: Add summary element to documentation comment
56+
dotnet_diagnostic.RCS1139.severity = suggestion
57+
# RCS1194: Implement exception constructors
58+
dotnet_diagnostic.RCS1194.severity = suggestion
59+
# RCS1210: Return completed task instead of returning null
60+
dotnet_diagnostic.RCS1210.severity = suggestion
61+
# RCS1075: Avoid empty catch clause that catches System.Exception
62+
dotnet_diagnostic.RCS1075.severity = suggestion
63+
64+
# VSTHRD002: Avoid problematic synchronous waits
65+
dotnet_diagnostic.VSTHRD002.severity = suggestion
66+
# VSTHRD003: Avoid awaiting foreign Tasks
67+
dotnet_diagnostic.VSTHRD003.severity = suggestion
68+
# VSTHRD105: Avoid method overloads that assume TaskScheduler.Current
69+
dotnet_diagnostic.VSTHRD105.severity = suggestion
70+
# VSTHRD100: Avoid async void methods
71+
dotnet_diagnostic.VSTHRD100.severity = suggestion
72+
# VSTHRD103: Call async methods when in an async method
73+
dotnet_diagnostic.VSTHRD103.severity = suggestion
74+
# VSTHRD110: Observe result of async calls
75+
dotnet_diagnostic.VSTHRD110.severity = suggestion
76+
# VSTHRD114: Avoid returning a null Task
77+
dotnet_diagnostic.VSTHRD114.severity = suggestion
4178
# VSTHRD200: Use "Async" suffix for awaitable methods
42-
dotnet_diagnostic.VSTHRD200.severity = silent
79+
dotnet_diagnostic.VSTHRD200.severity = suggestion
80+
81+
# xUnit2013: Do not use equality check to check for collection size
82+
dotnet_diagnostic.xUnit2013.severity = suggestion
4383
# IDE0003: this and Me preferences
44-
dotnet_diagnostic.IDE0003.severity = silent
84+
dotnet_diagnostic.IDE0003.severity = suggestion
4585

4686
[*.{json}]
4787
indent_size = 2

PowerShellEditorServices.Common.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<RepositoryUrl>https://github.com/PowerShell/PowerShellEditorServices</RepositoryUrl>
1313
<DebugType>portable</DebugType>
1414
<!-- See: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview -->
15-
<!-- TODO: Enable `EnforceCodeStyleInBuild` -->
1615
<EnableNETAnalyzers>true</EnableNETAnalyzers>
16+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1717
<!-- See: https://docs.microsoft.com/en-us/dotnet/core/compatibility/sdk/6.0/implicit-namespaces -->
1818
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
1919
</PropertyGroup>

0 commit comments

Comments
 (0)