
Roslynator
- 16 installs
- 466 repo stars
- Updated July 25, 2026
- managedcode/dotnet-skills
Helps with ai & agent building tasks.
About
roslynator is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.
- roslynator
- AI & Agent Building
- AI-coding skill
Roslynator by the numbers
- 16 all-time installs (skills.sh)
- +1 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #11,068 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 3, 2026 (Skillselion catalog sync)
npx skills add https://github.com/managedcode/dotnet-skills --skill roslynatorAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 16 |
|---|---|
| repo stars | ★ 466 |
| Last updated | July 25, 2026 |
| Repository | managedcode/dotnet-skills ↗ |
What it does
Helps with ai & agent building tasks.
Files
Roslynator
Trigger On
- the repo uses or wants
Roslynator.Analyzers - the team wants Roslynator CLI or extra Roslyn-based rules
- the user asks about C# linting, static analysis, code cleanup, or unused code
Value
- produce a concrete project delta: code, docs, config, tests, CI, or review artifact
- reduce ambiguity through explicit planning, verification, and final validation skills
- leave reusable project context so future tasks are faster and safer
Do Not Use For
- repos that already have overlapping analyzer packs with no consolidation plan
- formatting-only work when the repo already standardized on
dotnet formatorCSharpier
Inputs
- the nearest
AGENTS.md - current analyzer packages
.editorconfig
Quick Start
1. Read the nearest AGENTS.md and confirm scope and constraints. 2. Run this skill's Workflow through the Ralph Loop until outcomes are acceptable. 3. Return the Required Result Format with concrete artifacts and verification evidence.
Workflow
1. Prefer the NuGet analyzer packages for build-enforced checks. 2. Use the CLI when the repo needs one of these flows explicitly:
analyzefixfind-unusedformat
3. Build first when Roslynator needs compiled context. 4. Configure rule severity and Roslynator behavior in .editorconfig. 5. Avoid duplicating the same rules across multiple analyzer packs without a severity plan. 6. Treat CLI auto-fix as a controlled change:
- run it on a bounded target first
- rebuild
- rerun tests
Bootstrap When Missing
If Roslynator is not configured yet:
1. Detect current state:
rg -n "Roslynator\\.Analyzers" -g '*.csproj' .rg --files -g '.config/dotnet-tools.json'dotnet tool list --localdotnet tool list --globalcommand -v roslynator
2. Choose the install path deliberately:
- analyzer package:
dotnet add PROJECT.csproj package Roslynator.Analyzers - optional CLI:
dotnet new tool-manifest(if missing) anddotnet tool install roslynator.dotnet.cli
3. Configure ownership in root .editorconfig so Roslynator does not fight SDK analyzers, StyleCop, or Meziantou. 4. If the CLI is adopted, add exact commands in AGENTS.md and CI, such as:
dotnet tool run roslynator analyze SOLUTION_OR_PROJECTdotnet tool run roslynator fix SOLUTION_OR_PROJECT
5. Run dotnet build SOLUTION_OR_PROJECT and the selected Roslynator command, then return status: configured or status: improved. 6. If the repo wants only the current analyzer baseline and no Roslynator-specific CLI workflow, return status: not_applicable.
Deliver
- Roslynator package or CLI setup that fits the repo
- explicit ownership of rule severity
- repeatable commands for analyze, fix, or unused-code workflows when the repo adopts them
Validate
- Roslynator adds value beyond the current analyzer baseline
- CI commands remain reviewable and reproducible
- the repo is not confusing Roslynator CLI with the analyzer package itself
Ralph Loop
Use the Ralph Loop for every task, including docs, architecture, testing, and tooling work.
1. Plan first (mandatory):
- analyze current state
- define target outcome, constraints, and risks
- write a detailed execution plan
- list final validation skills to run at the end, with order and reason
2. Execute one planned step and produce a concrete delta. 3. Review the result and capture findings with actionable next fixes. 4. Apply fixes in small batches and rerun the relevant checks or review steps. 5. Update the plan after each iteration. 6. Repeat until outcomes are acceptable or only explicit exceptions remain. 7. If a dependency is missing, bootstrap it or return status: not_applicable with explicit reason and fallback path.
Required Result Format
status:complete|clean|improved|configured|not_applicable|blockedplan: concise plan and current iteration stepactions_taken: concrete changes madevalidation_skills: final skills run, or skipped with reasonsverification: commands, checks, or review evidence summaryremaining: top unresolved items ornone
For setup-only requests with no execution, return status: configured and exact next commands.
Load References
- references/rules.md
- references/config.md
- references/roslynator.md
Example Requests
- "Add Roslynator analyzers."
- "Use Roslynator CLI in CI."
- "Find unused code with Roslynator."
- "Auto-fix Roslynator issues in this solution."
{
"version": "1.0.0",
"category": "Code Quality",
"packages": [
"Roslynator.Analyzers",
"Roslynator.CodeAnalysis.Analyzers",
"Roslynator.Formatting.Analyzers"
]
}
Roslynator EditorConfig Configuration
This document provides .editorconfig settings for configuring Roslynator analyzers.
Basic Setup
Roslynator respects standard .editorconfig files. Place configuration in your solution's root .editorconfig or in nested .editorconfig files for directory-specific settings.
Rule Severity Configuration
Configure rule severity using the standard diagnostic severity format:
[*.cs]
# Syntax: dotnet_diagnostic.<rule_id>.severity = <severity>
# Severities: none, silent, suggestion, warning, error
# Example: Disable a rule
dotnet_diagnostic.RCS1090.severity = none
# Example: Elevate to warning
dotnet_diagnostic.RCS1163.severity = warning
# Example: Treat as error
dotnet_diagnostic.RCS1155.severity = errorRoslynator-Specific Options
Roslynator provides additional configuration options beyond severity:
[*.cs]
# Configure specific rule behavior
roslynator_accessibility_modifiers = explicit
roslynator_accessor_braces_style = single_line_when_expression_is_on_single_line
roslynator_array_creation_type_style = implicit_when_type_is_obvious
roslynator_arrow_token_new_line = before
roslynator_binary_operator_new_line = before
roslynator_blank_line_after_file_scoped_namespace_declaration = true
roslynator_blank_line_between_closing_brace_and_switch_section = false
roslynator_blank_line_between_single_line_accessors = false
roslynator_blank_line_between_using_directives = never
roslynator_block_braces_style = single_line_when_empty
roslynator_body_style = expression
roslynator_conditional_operator_condition_parentheses_style = include
roslynator_conditional_operator_new_line = before
roslynator_configure_await = true
roslynator_doc_comment_summary_style = multi_line
roslynator_empty_string_style = literal
roslynator_enum_flag_value_style = decimal_number
roslynator_enum_has_flag_style = method
roslynator_equals_token_new_line = before
roslynator_infinite_loop_style = while
roslynator_max_line_length = 140
roslynator_new_line_at_end_of_file = true
roslynator_new_line_before_while_in_do_statement = true
roslynator_null_check_style = pattern_matching
roslynator_null_conditional_operator_new_line = before
roslynator_object_creation_parentheses_style = include
roslynator_object_creation_type_style = implicit_when_type_is_obvious
roslynator_prefix_field_identifier_with_underscore = true
roslynator_suppress_unity_script_methods = true
roslynator_tab_length = 4
roslynator_trailing_comma_style = omit_when_single_line
roslynator_unity_code_analysis.enabled = false
roslynator_use_anonymous_function_or_method_group = method_group
roslynator_use_block_body_when_declaration_spans_over_multiple_lines = true
roslynator_use_block_body_when_expression_spans_over_multiple_lines = true
roslynator_use_collection_expression = true
roslynator_use_var = when_type_is_obvious
roslynator_use_var_instead_of_implicit_object_creation = falseRefactoring Configuration
Enable or disable specific refactorings:
[*.cs]
# Syntax: roslynator_refactoring.<id>.enabled = true|false
# Example: Disable "Add braces" refactoring
roslynator_refactoring.RR0002.enabled = false
# Example: Enable "Extract method" refactoring
roslynator_refactoring.RR0047.enabled = trueCompiler Diagnostic Configuration
Configure standard compiler diagnostics alongside Roslynator:
[*.cs]
# Syntax: roslynator_compiler_diagnostic.<id>.enabled = true|false
# Example: Include specific compiler diagnostics in analysis
roslynator_compiler_diagnostic.CS0162.enabled = trueComplete Configuration Templates
Minimal Strict Configuration
A minimal configuration that enforces important code quality rules:
# .editorconfig
root = true
[*.cs]
# Core code quality rules - elevate to warning
dotnet_diagnostic.RCS1155.severity = warning # Use StringComparison
dotnet_diagnostic.RCS1163.severity = warning # Unused parameter
dotnet_diagnostic.RCS1169.severity = warning # Make field read-only
dotnet_diagnostic.RCS1213.severity = warning # Remove unused member
dotnet_diagnostic.RCS1225.severity = warning # Make class sealed
dotnet_diagnostic.RCS1210.severity = warning # Return completed task
# Performance rules
dotnet_diagnostic.RCS1077.severity = warning # Optimize LINQ
dotnet_diagnostic.RCS1080.severity = warning # Use Count/Length
# Architecture rules
dotnet_diagnostic.RCS1102.severity = warning # Make class static
dotnet_diagnostic.RCS1110.severity = warning # Type inside namespace
# Disable noisy rules
dotnet_diagnostic.RCS1090.severity = none # ConfigureAwait (if not library)
dotnet_diagnostic.RCS1036.severity = none # Remove blank lineLibrary/Package Configuration
Configuration suitable for libraries distributed via NuGet:
# .editorconfig
root = true
[*.cs]
# API design rules - enforce strictly
dotnet_diagnostic.RCS1110.severity = error # Type inside namespace
dotnet_diagnostic.RCS1194.severity = error # Exception constructors
dotnet_diagnostic.RCS1203.severity = error # AttributeUsage
dotnet_diagnostic.RCS1160.severity = error # Abstract public constructors
dotnet_diagnostic.RCS1193.severity = error # params modifier
# Async rules - important for libraries
dotnet_diagnostic.RCS1090.severity = warning # ConfigureAwait
dotnet_diagnostic.RCS1210.severity = error # Return completed task
dotnet_diagnostic.RCS1046.severity = warning # Async suffix
dotnet_diagnostic.RCS1047.severity = warning # Non-async suffix
# Documentation
dotnet_diagnostic.RCS1138.severity = warning # Summary required
dotnet_diagnostic.RCS1139.severity = warning # Summary element
dotnet_diagnostic.RCS1141.severity = warning # param element
dotnet_diagnostic.RCS1142.severity = warning # typeparam element
dotnet_diagnostic.RCS1263.severity = error # Invalid doc reference
# Code quality
dotnet_diagnostic.RCS1155.severity = error # StringComparison
dotnet_diagnostic.RCS1163.severity = warning # Unused parameter
dotnet_diagnostic.RCS1169.severity = warning # Read-only field
dotnet_diagnostic.RCS1213.severity = warning # Unused member
# Roslynator options
roslynator_configure_await = true
roslynator_accessibility_modifiers = explicit
roslynator_prefix_field_identifier_with_underscore = trueApplication Configuration
Configuration suitable for applications (not libraries):
# .editorconfig
root = true
[*.cs]
# Disable library-specific rules
dotnet_diagnostic.RCS1090.severity = none # ConfigureAwait
dotnet_diagnostic.RCS1046.severity = none # Async suffix
# Enable code quality
dotnet_diagnostic.RCS1155.severity = warning # StringComparison
dotnet_diagnostic.RCS1163.severity = warning # Unused parameter
dotnet_diagnostic.RCS1169.severity = warning # Read-only field
dotnet_diagnostic.RCS1213.severity = warning # Unused member
dotnet_diagnostic.RCS1225.severity = warning # Sealed class
dotnet_diagnostic.RCS1102.severity = warning # Static class
# Performance
dotnet_diagnostic.RCS1077.severity = warning # Optimize LINQ
dotnet_diagnostic.RCS1080.severity = warning # Count/Length
dotnet_diagnostic.RCS1197.severity = warning # StringBuilder
dotnet_diagnostic.RCS1235.severity = warning # Optimize method
# Simplification
dotnet_diagnostic.RCS1049.severity = suggestion
dotnet_diagnostic.RCS1058.severity = suggestion
dotnet_diagnostic.RCS1068.severity = suggestion
dotnet_diagnostic.RCS1084.severity = suggestion
# Roslynator options
roslynator_configure_await = false
roslynator_use_var = when_type_is_obvious
roslynator_object_creation_type_style = implicit_when_type_is_obviousTest Project Configuration
Configuration suitable for test projects:
# tests/.editorconfig
[*.cs]
# Relax some rules for test code
dotnet_diagnostic.RCS1163.severity = suggestion # Unused parameter (common in tests)
dotnet_diagnostic.RCS1213.severity = suggestion # Unused member (test helpers)
dotnet_diagnostic.RCS1225.severity = none # Sealed (test classes often inherited)
dotnet_diagnostic.RCS1090.severity = none # ConfigureAwait
dotnet_diagnostic.RCS1046.severity = none # Async suffix
# Keep important rules
dotnet_diagnostic.RCS1155.severity = warning # StringComparison
dotnet_diagnostic.RCS1077.severity = suggestion # LINQ optimization
# Allow more flexibility
roslynator_use_var = alwaysGlobal Suppression
To suppress rules project-wide via GlobalSuppressions.cs:
// GlobalSuppressions.cs
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Roslynator", "RCS1090:Add call to 'ConfigureAwait'")]
[assembly: SuppressMessage("Roslynator", "RCS1036:Remove unnecessary blank line")]Inline Suppression
Suppress rules inline with pragma directives:
#pragma warning disable RCS1163 // Unused parameter
public void Method(string unused)
#pragma warning restore RCS1163
{
// ...
}Or with attributes:
[SuppressMessage("Roslynator", "RCS1163:Unused parameter")]
public void Method(string unused)
{
// ...
}Combining with Other Analyzers
When using Roslynator alongside other analyzers (SDK analyzers, StyleCop, Meziantou), establish clear ownership:
[*.cs]
# Disable Roslynator formatting when using dotnet format or CSharpier
dotnet_diagnostic.RCS0001.severity = none
dotnet_diagnostic.RCS0002.severity = none
# ... other RCS0xxx rules
# Disable overlapping rules if StyleCop handles them
dotnet_diagnostic.RCS1018.severity = none # Accessibility (SA1400)
dotnet_diagnostic.RCS1019.severity = none # Modifier order (SA1206)
# Let SDK analyzers handle nullability
# Roslynator complements but doesn't replace CS8xxx rulesCLI-Specific Configuration
When using Roslynator CLI, additional options can be passed:
# Analyze with specific severity minimum
roslynator analyze Solution.sln --severity-level warning
# Fix with specific rules
roslynator fix Solution.sln --diagnostic-ids RCS1163,RCS1213
# Find unused code
roslynator find-unused Solution.slnThe CLI respects .editorconfig settings for rule configuration.
Further Reading
Roslynator
Open/Free Status
- open source
- free to use
Install
Analyzer package:
dotnet add package Roslynator.AnalyzersOptional CLI:
dotnet tool install -g roslynator.dotnet.cliVerify First
Before installing anything, check whether the repo already references the analyzer package or already has the CLI:
rg -n "Roslynator\\.Analyzers" -g '*.csproj' .
dotnet tool list --local
dotnet tool list --global
command -v roslynatorRequirements
- current Roslynator CLI requires a supported modern .NET SDK
- the official CLI docs currently list support for .NET SDK 7, 8, or 9 depending on Roslynator version
Important Distinction
- the CLI tool itself does not provide the analyzer rules by magic
- build-enforced diagnostics usually come from NuGet packages such as
Roslynator.Analyzers - the CLI is most useful for explicit analysis, fix, formatting, and unused-code workflows
Common Usage
dotnet build MySolution.sln -warnaserror
roslynator analyze MySolution.sln
roslynator fix MySolution.sln
roslynator format MySolution.sln
roslynator find-unused MySolution.sln
roslynator list-symbols MySolution.sln
roslynator lloc MySolution.slnUseful CI-focused variation:
roslynator analyze MySolution.sln --severity-level warningUseful scoping flags from the CLI:
--projects PROJECT_NAME--ignored-projects PROJECT_NAME--include GLOB--exclude GLOB--verbosity LEVEL--properties NAME=VALUE
CI Fit
- prefer package-based analyzers as the primary gate
- use
.editorconfigto configure rule severity - keep CLI usage explicit if the repo adopts it
- use
analyzefor report-only flows andfixonly in controlled local or pre-PR cleanup flows - rebuild and retest after
fix
Configuration
Roslynator configuration belongs in .editorconfig, for example:
[*.cs]
dotnet_analyzer_diagnostic.category-roslynator.severity = warning
dotnet_diagnostic.RCS1001.severity = none
dotnet_diagnostic.RCS1036.severity = error
roslynator_refactoring.add_braces.enabled = falseExit Codes
0: success, or no diagnostics left for the current command1: diagnostics found, or not all diagnostics fixed2: error or execution canceled
When Not To Use
- when the repo already uses enough overlapping analyzers and does not want the extra rule surface
- when the team wants only build-integrated analyzer behavior and has no need for Roslynator CLI workflows
Sources
Roslynator Rules Reference
This document covers commonly used Roslynator analyzer rules, organized by category.
Rule Naming Convention
Roslynator rules follow these prefixes:
RCS0xxx- Formatting analyzers (fromRoslynator.Formatting.Analyzers)RCS1xxx- Code analyzers (fromRoslynator.Analyzers)RCS9xxx- Code analysis analyzers
Commonly Used Code Analyzers (RCS1xxx)
Simplification and Redundancy
| Rule | Description | Default |
|---|---|---|
| RCS1001 | Add braces to if-else chain | Info |
| RCS1003 | Add braces to if-else when multi-line | Info |
| RCS1015 | Use nameof operator | Warning |
| RCS1021 | Convert lambda expression body to expression-body | Info |
| RCS1032 | Remove redundant parentheses | Info |
| RCS1033 | Remove redundant boolean literal | Info |
| RCS1036 | Remove unnecessary blank line | Info |
| RCS1037 | Remove trailing white-space | Hidden |
| RCS1038 | Remove empty statement | Info |
| RCS1039 | Remove argument list from attribute | Info |
| RCS1040 | Remove empty else clause | Info |
| RCS1049 | Simplify boolean comparison | Info |
| RCS1058 | Use compound assignment | Info |
| RCS1068 | Simplify logical negation | Info |
| RCS1069 | Remove unnecessary case label | Hidden |
| RCS1073 | Convert if to return statement | Info |
| RCS1077 | Optimize LINQ method call | Info |
| RCS1084 | Use coalesce expression instead of conditional expression | Info |
| RCS1085 | Use auto-implemented property | Info |
| RCS1089 | Use postfix unary operator instead of assignment | Info |
| RCS1097 | Remove redundant ToString call | Info |
| RCS1104 | Simplify conditional expression | Info |
| RCS1118 | Mark local variable as const | Info |
| RCS1123 | Add parentheses when necessary | Info |
| RCS1128 | Use coalesce expression | Info |
| RCS1129 | Remove redundant field initialization | Hidden |
| RCS1132 | Remove redundant overriding member | Info |
| RCS1133 | Remove redundant Dispose/Close call | Hidden |
| RCS1138 | Add summary to documentation comment | Warning |
| RCS1139 | Add summary element to documentation comment | Warning |
| RCS1140 | Add exception to documentation comment | Info |
| RCS1141 | Add 'param' element to documentation comment | Info |
| RCS1142 | Add 'typeparam' element to documentation comment | Info |
| RCS1143 | Simplify coalesce expression | Info |
| RCS1146 | Use conditional access | Info |
| RCS1151 | Remove redundant cast | Hidden |
| RCS1154 | Sort enum members | Info |
| RCS1155 | Use StringComparison when comparing strings | Warning |
| RCS1156 | Use string.Length instead of comparison with empty string | Info |
| RCS1161 | Enum should declare explicit values | Hidden |
| RCS1163 | Unused parameter | Info |
| RCS1168 | Parameter name differs from base name | Hidden |
| RCS1169 | Make field read-only | Info |
| RCS1170 | Use read-only auto-implemented property | Info |
| RCS1171 | Simplify lazy initialization | Info |
| RCS1173 | Use coalesce expression instead of if | Info |
| RCS1175 | Unused 'this' parameter | Info |
| RCS1177 | Use 'var' instead of explicit type in foreach | Hidden |
| RCS1179 | Unnecessary assignment | Info |
| RCS1180 | Inline lazy initialization | Info |
| RCS1181 | Convert comment to documentation comment | Hidden |
| RCS1182 | Remove redundant base interface | Hidden |
| RCS1187 | Use constant instead of field | Info |
| RCS1188 | Remove redundant auto-property initialization | Hidden |
| RCS1189 | Add or remove region name | Hidden |
| RCS1190 | Join string expressions | Info |
| RCS1191 | Declare enum value as combination of names | Info |
| RCS1192 | Unnecessary usage of verbatim string literal | Info |
| RCS1193 | Overriding member should not change 'params' modifier | Warning |
| RCS1194 | Implement exception constructors | Warning |
| RCS1195 | Use ^ operator | Info |
| RCS1196 | Call extension method as instance method | Info |
| RCS1197 | Optimize StringBuilder.Append/AppendLine call | Info |
| RCS1198 | Avoid unnecessary boxing of value type | Hidden |
| RCS1199 | Unnecessary null check | Info |
| RCS1200 | Call 'Enumerable.ThenBy' instead of 'Enumerable.OrderBy' | Info |
| RCS1201 | Use method chaining | Hidden |
| RCS1202 | Avoid NullReferenceException | Info |
| RCS1203 | Use AttributeUsageAttribute | Warning |
| RCS1205 | Order named arguments according to the order of parameters | Info |
| RCS1206 | Use conditional access instead of conditional expression | Info |
| RCS1207 | Convert anonymous function to method group | Info |
| RCS1208 | Reduce if nesting | Hidden |
| RCS1209 | Order type parameter constraints | Info |
| RCS1210 | Return completed task instead of returning null | Warning |
| RCS1211 | Remove unnecessary else | Hidden |
| RCS1212 | Remove redundant assignment | Info |
| RCS1213 | Remove unused member declaration | Info |
| RCS1214 | Unnecessary interpolated string | Info |
| RCS1215 | Expression is always equal to true/false | Warning |
| RCS1216 | Unnecessary unsafe context | Info |
| RCS1217 | Convert interpolated string to concatenation | Hidden |
| RCS1218 | Simplify code branching | Hidden |
| RCS1220 | Use pattern matching instead of combination of 'is' and cast | Info |
| RCS1221 | Use pattern matching instead of combination of 'as' and null check | Info |
| RCS1222 | Merge preprocessor directives | Info |
| RCS1223 | Mark publicly visible type with DebuggerDisplay attribute | Hidden |
| RCS1224 | Make method an extension method | Info |
| RCS1225 | Make class sealed | Info |
| RCS1226 | Add paragraph to documentation comment | Info |
| RCS1227 | Validate arguments correctly | Info |
| RCS1228 | Unused element in documentation comment | Info |
| RCS1229 | Use async/await when necessary | Info |
| RCS1230 | Unnecessary explicit use of enumerator | Info |
| RCS1231 | Make parameter ref read-only | Hidden |
| RCS1232 | Order elements in documentation comment | Info |
| RCS1233 | Use short-circuiting operator | Info |
| RCS1234 | Duplicate enum value | Info |
| RCS1235 | Optimize method call | Info |
| RCS1236 | Use exception filter | Info |
| RCS1238 | Avoid nested ?: operators | Info |
| RCS1239 | Use 'for' statement instead of 'while' statement | Info |
| RCS1240 | Operator is unnecessary | Info |
| RCS1241 | Implement non-generic counterpart | Info |
| RCS1242 | Do not pass non-read-only struct by read-only reference | Warning |
| RCS1243 | Duplicate word in comment | Info |
| RCS1244 | Simplify 'default' expression | Hidden |
| RCS1246 | Use element access | Info |
| RCS1247 | Fix documentation comment tag | Info |
| RCS1248 | Normalize null check | Info |
| RCS1249 | Unnecessary null-forgiving operator | Info |
| RCS1250 | Use implicit/explicit object creation | Hidden |
| RCS1251 | Remove unnecessary braces from record declaration | Info |
| RCS1252 | Normalize usage of infinite loop | Hidden |
| RCS1253 | Format documentation comment summary | Hidden |
| RCS1254 | Normalize format of enum flag value | Info |
| RCS1255 | Simplify argument null check | Info |
| RCS1256 | Invalid argument null check | Info |
| RCS1257 | Use enum field explicitly | Info |
| RCS1258 | Unnecessary enum flag | Info |
| RCS1259 | Remove empty syntax | Info |
| RCS1260 | Add/remove trailing comma | Hidden |
| RCS1261 | Resource can be disposed asynchronously | Info |
| RCS1262 | Unnecessary raw string literal | Info |
| RCS1263 | Invalid reference in a documentation comment | Warning |
| RCS1264 | Use 'var' or explicit type | Hidden |
| RCS1265 | Remove redundant catch block | Info |
| RCS1266 | Use raw string literal | Info |
| RCS1267 | Use string interpolation instead of 'string.Concat' | Info |
| RCS1268 | Simplify numeric comparison | Info |
Async and Threading
| Rule | Description | Default |
|---|---|---|
| RCS1046 | Asynchronous method name should end with 'Async' | Hidden |
| RCS1047 | Non-asynchronous method name should not end with 'Async' | Info |
| RCS1090 | Add call to 'ConfigureAwait' | Hidden |
| RCS1174 | Remove redundant async/await | Info |
| RCS1229 | Use async/await when necessary | Info |
Design and Architecture
| Rule | Description | Default |
|---|---|---|
| RCS1016 | Convert block body to expression-body | Hidden |
| RCS1017 | Convert expression-body to block body | Hidden |
| RCS1018 | Add accessibility modifiers | Info |
| RCS1019 | Order modifiers | Hidden |
| RCS1045 | Rename private field to camel case with underscore | Hidden |
| RCS1050 | Include/omit parentheses when creating new object | Hidden |
| RCS1051 | Add/remove parentheses from condition in conditional operator | Hidden |
| RCS1061 | Merge if with nested if | Hidden |
| RCS1080 | Use 'Count' or 'Length' property instead of 'Any' method | Info |
| RCS1090 | Add call to 'ConfigureAwait' | Hidden |
| RCS1091 | Remove empty region | Hidden |
| RCS1094 | Declare using directive on top level | Hidden |
| RCS1096 | Convert 'HasFlag' call to bitwise operation | Info |
| RCS1102 | Make class static | Info |
| RCS1110 | Declare type inside namespace | Warning |
| RCS1126 | Add braces to if-else | Hidden |
| RCS1134 | Remove redundant statement | Info |
| RCS1135 | Declare enum member with zero value | Info |
| RCS1136 | Merge switch sections with equivalent content | Hidden |
| RCS1145 | Remove redundant 'as' operator | Hidden |
| RCS1158 | Static member in generic type should use a type parameter | Info |
| RCS1159 | Use EventHandler<T> | Info |
| RCS1160 | Abstract type should not have public constructors | Info |
| RCS1162 | Avoid chain of assignments | Hidden |
| RCS1164 | Unused type parameter | Info |
| RCS1166 | Value type object is never equal to null | Info |
| RCS1225 | Make class sealed | Info |
Formatting Analyzers (RCS0xxx)
These rules control code formatting and are part of Roslynator.Formatting.Analyzers:
| Rule | Description | Default |
|---|---|---|
| RCS0001 | Add blank line after embedded statement | None |
| RCS0002 | Add blank line after #region | None |
| RCS0003 | Add blank line after using directive list | None |
| RCS0004 | Add blank line before #endregion | None |
| RCS0005 | Add blank line before using directive list | None |
| RCS0006 | Add blank line between declaration and documentation comment | None |
| RCS0007 | Add blank line between accessors | None |
| RCS0008 | Add blank line between closing brace and next statement | None |
| RCS0009 | Add blank line between declaration and documentation comment | None |
| RCS0010 | Add blank line between declarations | None |
| RCS0011 | Add/remove blank line between single-line accessors | None |
| RCS0012 | Add blank line between single-line declarations | None |
| RCS0013 | Add blank line between single-line declarations of different kind | None |
| RCS0014 | Add blank line between switch sections | None |
| RCS0015 | Add/remove blank line between using directives | None |
| RCS0016 | Put attribute list on its own line | None |
| RCS0020 | Format accessor's braces on a single line or multiple lines | None |
| RCS0021 | Format block's braces on a single line or multiple lines | None |
| RCS0022 | Format type declaration's braces | None |
| RCS0023 | Format type declaration's braces | None |
| RCS0024 | Add newline after switch label | None |
| RCS0025 | Put full accessor on its own line | None |
| RCS0027 | Place new line after/before binary operator | None |
| RCS0028 | Place new line after/before '?:' operator | None |
| RCS0029 | Put constructor initializer on its own line | None |
| RCS0030 | Put embedded statement on its own line | None |
| RCS0031 | Put enum member on its own line | None |
| RCS0032 | Place new line after/before arrow token | None |
| RCS0033 | Put statement on its own line | None |
| RCS0034 | Put type parameter constraint on its own line | None |
| RCS0036 | Remove blank line between single-line declarations of same kind | None |
| RCS0038 | Remove blank line between using directives with same root namespace | None |
| RCS0039 | Remove newline before base list | None |
| RCS0041 | Remove newline between 'if' keyword and 'else' keyword | None |
| RCS0042 | Put auto-accessors on a single line | None |
| RCS0043 | Format accessor's braces on a single line when expression is on single line | None |
| RCS0044 | Use carriage return + linefeed as newline | None |
| RCS0045 | Use linefeed as newline | None |
| RCS0046 | Use spaces instead of tab | None |
| RCS0048 | Put initializer on a single line | None |
| RCS0049 | Add blank line after top comment | None |
| RCS0050 | Add blank line before top declaration | None |
| RCS0051 | Add/remove newline between closing brace and 'while' keyword | None |
| RCS0052 | Place new line after/before equals token | None |
| RCS0053 | Fix formatting of a list | None |
| RCS0054 | Fix formatting of a call chain | None |
| RCS0055 | Fix formatting of a binary expression chain | None |
| RCS0056 | Line is too long | None |
| RCS0057 | Normalize whitespace at the beginning of a file | None |
| RCS0058 | Normalize whitespace at the end of a file | None |
| RCS0059 | Place new line after/before null-conditional operator | None |
| RCS0060 | Add/remove line after file scoped namespace declaration | None |
| RCS0061 | Add/remove blank line between switch sections | None |
High-Impact Rules for Code Quality
These rules have the highest impact on code quality and maintainability:
Must-Enable (Recommended as Warning or Error)
1. RCS1155 - Use StringComparison when comparing strings 2. RCS1210 - Return completed task instead of returning null 3. RCS1194 - Implement exception constructors 4. RCS1203 - Use AttributeUsageAttribute 5. RCS1110 - Declare type inside namespace 6. RCS1215 - Expression is always equal to true/false 7. RCS1263 - Invalid reference in a documentation comment 8. RCS1242 - Do not pass non-read-only struct by read-only reference 9. RCS1193 - Overriding member should not change 'params' modifier
Often Elevated to Warning
1. RCS1163 - Unused parameter 2. RCS1213 - Remove unused member declaration 3. RCS1169 - Make field read-only 4. RCS1102 - Make class static 5. RCS1225 - Make class sealed 6. RCS1077 - Optimize LINQ method call 7. RCS1080 - Use 'Count' or 'Length' property instead of 'Any' method
Performance-Related Rules
1. RCS1077 - Optimize LINQ method call 2. RCS1080 - Use 'Count' or 'Length' property instead of 'Any' method 3. RCS1096 - Convert 'HasFlag' call to bitwise operation 4. RCS1197 - Optimize StringBuilder.Append/AppendLine call 5. RCS1198 - Avoid unnecessary boxing of value type 6. RCS1235 - Optimize method call
Refactorings
Roslynator also provides refactorings (not analyzers) that can be invoked manually. These are not rule-based but are useful code transformations available through the IDE.
Common refactorings include:
- Add braces
- Extract method
- Inline method
- Introduce local variable
- Merge if statements
- Replace method group with lambda
- Split variable declaration
- Wrap in region
- And many more
Refactorings can be enabled/disabled in .editorconfig using roslynator_refactoring.<id>.enabled settings.