Static code analysis with Roslyn analyzers, StyleCop, and EditorConfig. Covers analyzer configuration, rule customization, and CI enforcement. Trigger: code analysis, Roslyn, StyleCop, EditorConfig, analyzer, lint.
From dotnet-ai-kitnpx claudepluginhub faysilalshareef/dotnet-ai-kit --plugin dotnet-ai-kitThis skill uses the workspace's default tool permissions.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Enables AI agents to execute x402 payments with per-task budgets, spending controls, and non-custodial wallets via MCP tools. Use when agents pay for APIs, services, or other agents.
.editorconfig enforces consistent code style across the teamDirectory.Build.props enables analyzers for all projectsTreatWarningsAsErrors in CI prevents degradationEnforceCodeStyleInBuild enables style warnings during build# .editorconfig (solution root)
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = crlf
charset = utf-8-bom
trim_trailing_whitespace = true
insert_final_newline = true
[*.cs]
# Namespace
csharp_style_namespace_declarations = file_scoped:warning
# Using directives
dotnet_sort_system_directives_first = true
csharp_using_directive_placement = outside_namespace:warning
# var preferences
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion
# Expression-bodied members
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
csharp_style_expression_bodied_properties = true:suggestion
# Null checking
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
# Naming conventions
dotnet_naming_rule.private_fields.symbols = private_fields
dotnet_naming_rule.private_fields.style = _camelCase
dotnet_naming_rule.private_fields.severity = warning
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
dotnet_naming_style._camelCase.required_prefix = _
dotnet_naming_style._camelCase.capitalization = camel_case
# Analyzer severity
dotnet_diagnostic.CA1062.severity = warning # Validate arguments
dotnet_diagnostic.CA1822.severity = suggestion # Mark static
dotnet_diagnostic.CA2007.severity = none # ConfigureAwait
<Project>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.182">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
// stylecop.json (solution root)
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"companyName": "{Company}",
"xmlHeader": false,
"documentInterfaces": false,
"documentPrivateElements": false
},
"orderingRules": {
"usingDirectivesPlacement": "outsideNamespace"
}
}
}
// Targeted suppression (prefer over global)
[SuppressMessage("Style", "IDE0057",
Justification = "Range operator less readable here")]
public string GetPrefix(string value) => value.Substring(0, 3);
// Global suppression file
// GlobalSuppressions.cs
[assembly: SuppressMessage("Design", "CA1062",
Scope = "namespaceanddescendants",
Target = "~N:{Company}.{Domain}.Tests")]
| Anti-Pattern | Correct Approach |
|---|---|
| Disabling all warnings | Fix warnings or suppress with justification |
| No .editorconfig | Create one at solution root |
| Analyzers only in CI | Enable in IDE and build |
| Global suppressions without justification | Always include Justification |
# Find .editorconfig
find . -name ".editorconfig" -type f
# Find analyzer packages
grep -r "StyleCop\|Meziantou\|Roslynator" --include="*.csproj" .
grep -r "StyleCop\|Meziantou\|Roslynator" --include="*.props" .
# Find TreatWarningsAsErrors
grep -r "TreatWarningsAsErrors" --include="*.props" --include="*.csproj" .
.editorconfig — extend, don't replaceDirectory.Build.propsTreatWarningsAsErrors without fixing existing warningsdotnet format to auto-fix formatting issues