Skip to content

Commit a7e1a77

Browse files
authored
feat: Add EditorConfig and C#/.NET janitor agent documentation (#18)
1 parent fbca77f commit a7e1a77

9 files changed

Lines changed: 516 additions & 117 deletions

File tree

‎.editorconfig‎

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# Top-most EditorConfig file
4+
root = true
5+
6+
# All files
7+
[*]
8+
charset = utf-8
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
# Code files
13+
[*.{cs,csx,vb,vbx}]
14+
indent_style = tab
15+
indent_size = 4
16+
end_of_line = crlf
17+
18+
# XML project files
19+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
20+
indent_style = tab
21+
indent_size = 2
22+
23+
# XML config files
24+
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
25+
indent_style = tab
26+
indent_size = 2
27+
28+
# JSON files
29+
[*.json]
30+
indent_style = tab
31+
indent_size = 2
32+
33+
# YAML files
34+
[*.{yml,yaml}]
35+
indent_style = space
36+
indent_size = 2
37+
38+
# Markdown files
39+
[*.md]
40+
indent_style = space
41+
trim_trailing_whitespace = false
42+
43+
# Shell scripts
44+
[*.{sh,ps1,cmd}]
45+
end_of_line = crlf
46+
47+
# Dotnet code style settings:
48+
[*.{cs,vb}]
49+
50+
# Sort using and Import directives with System.* appearing first
51+
dotnet_sort_system_directives_first = true
52+
dotnet_separate_import_directive_groups = false
53+
54+
# Avoid "this." and "Me." if not necessary
55+
dotnet_style_qualification_for_field = false:refactoring
56+
dotnet_style_qualification_for_property = false:refactoring
57+
dotnet_style_qualification_for_method = false:refactoring
58+
dotnet_style_qualification_for_event = false:refactoring
59+
60+
# Use language keywords instead of framework type names for type references
61+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
62+
dotnet_style_predefined_type_for_member_access = true:suggestion
63+
64+
# Suggest more modern language features when available
65+
dotnet_style_object_initializer = true:suggestion
66+
dotnet_style_collection_initializer = true:suggestion
67+
dotnet_style_coalesce_expression = true:suggestion
68+
dotnet_style_null_propagation = true:suggestion
69+
dotnet_style_explicit_tuple_names = true:suggestion
70+
71+
# Whitespace options
72+
dotnet_style_allow_multiple_blank_lines_experimental = true
73+
74+
# Non-private static fields are PascalCase
75+
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion
76+
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields
77+
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style
78+
79+
dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field
80+
dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
81+
dotnet_naming_symbols.non_private_static_fields.required_modifiers = static
82+
83+
dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case
84+
85+
# Non-private readonly fields are PascalCase
86+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion
87+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
88+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style
89+
90+
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
91+
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
92+
dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
93+
94+
dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case
95+
96+
# Constants are ALL_CAPS
97+
dotnet_naming_rule.constants_should_be_all_caps.severity = suggestion
98+
dotnet_naming_rule.constants_should_be_all_caps.symbols = constants
99+
dotnet_naming_rule.constants_should_be_all_caps.style = constant_style
100+
101+
dotnet_naming_symbols.constants.applicable_kinds = field, local
102+
dotnet_naming_symbols.constants.required_modifiers = const
103+
104+
dotnet_naming_style.constant_style.capitalization = all_upper
105+
dotnet_naming_style.constant_style.word_separator = _
106+
107+
# Static fields are PascalCase and start with _
108+
dotnet_naming_rule.static_fields_should_be_pascal_case.severity = suggestion
109+
dotnet_naming_rule.static_fields_should_be_pascal_case.symbols = static_fields
110+
dotnet_naming_rule.static_fields_should_be_pascal_case.style = private_field_style
111+
112+
dotnet_naming_symbols.static_fields.applicable_kinds = field
113+
dotnet_naming_symbols.static_fields.required_modifiers = static
114+
115+
dotnet_naming_style.private_field_style.capitalization = pascal_case
116+
dotnet_naming_style.private_field_style.required_prefix = _
117+
118+
# Instance fields are PascalCase and start with _
119+
dotnet_naming_rule.instance_fields_should_be_pascal_case.severity = suggestion
120+
dotnet_naming_rule.instance_fields_should_be_pascal_case.symbols = instance_fields
121+
dotnet_naming_rule.instance_fields_should_be_pascal_case.style = private_field_style
122+
123+
dotnet_naming_symbols.instance_fields.applicable_kinds = field
124+
125+
# Locals and parameters are camelCase
126+
dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion
127+
dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
128+
dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
129+
130+
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
131+
132+
dotnet_naming_style.camel_case_style.capitalization = camel_case
133+
134+
# Local functions are PascalCase
135+
dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion
136+
dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
137+
dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style
138+
139+
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
140+
141+
dotnet_naming_style.local_function_style.capitalization = pascal_case
142+
143+
# By default, name items with PascalCase
144+
dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion
145+
dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members
146+
dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style
147+
148+
dotnet_naming_symbols.all_members.applicable_kinds = *
149+
150+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
151+
152+
# CSharp code style settings:
153+
[*.cs]
154+
155+
# Newline settings
156+
csharp_new_line_before_open_brace = all
157+
csharp_new_line_before_else = true
158+
csharp_new_line_before_catch = true
159+
csharp_new_line_before_finally = true
160+
csharp_new_line_before_members_in_object_initializers = true
161+
csharp_new_line_before_members_in_anonymous_types = true
162+
csharp_new_line_between_query_expression_clauses = true
163+
164+
# Indentation preferences
165+
csharp_indent_block_contents = true
166+
csharp_indent_braces = false
167+
csharp_indent_case_contents = true
168+
csharp_indent_case_contents_when_block = true
169+
csharp_indent_switch_labels = true
170+
csharp_indent_labels = flush_left
171+
172+
# Prefer "var" everywhere
173+
csharp_style_var_for_built_in_types = true:suggestion
174+
csharp_style_var_when_type_is_apparent = true:suggestion
175+
csharp_style_var_elsewhere = true:suggestion
176+
177+
# Prefer method-like constructs to have a block body
178+
csharp_style_expression_bodied_methods = false:none
179+
csharp_style_expression_bodied_constructors = false:none
180+
csharp_style_expression_bodied_operators = false:none
181+
182+
# Prefer property-like constructs to have an expression-body
183+
csharp_style_expression_bodied_properties = true:none
184+
csharp_style_expression_bodied_indexers = true:none
185+
csharp_style_expression_bodied_accessors = true:none
186+
187+
# Suggest more modern language features when available
188+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
189+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
190+
csharp_style_inlined_variable_declaration = true:suggestion
191+
csharp_style_throw_expression = true:suggestion
192+
csharp_style_conditional_delegate_call = true:suggestion
193+
194+
# Space preferences
195+
csharp_space_after_cast = false
196+
csharp_space_after_colon_in_inheritance_clause = true
197+
csharp_space_after_comma = true
198+
csharp_space_after_dot = false
199+
csharp_space_after_keywords_in_control_flow_statements = true
200+
csharp_space_after_semicolon_in_for_statement = true
201+
csharp_space_around_binary_operators = before_and_after
202+
csharp_space_around_declaration_statements = false
203+
csharp_space_before_colon_in_inheritance_clause = true
204+
csharp_space_before_comma = false
205+
csharp_space_before_dot = false
206+
csharp_space_before_open_square_brackets = false
207+
csharp_space_before_semicolon_in_for_statement = false
208+
csharp_space_between_empty_square_brackets = false
209+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
210+
csharp_space_between_method_call_name_and_opening_parenthesis = false
211+
csharp_space_between_method_call_parameter_list_parentheses = false
212+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
213+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
214+
csharp_space_between_method_declaration_parameter_list_parentheses = false
215+
csharp_space_between_parentheses = false
216+
csharp_space_between_square_brackets = false
217+
218+
# Blocks are allowed
219+
csharp_prefer_braces = true:silent
220+
csharp_preserve_single_line_blocks = true
221+
csharp_preserve_single_line_statements = true
222+
223+
# Currently only enabled for C# due to issue https://github.com/dotnet/roslyn/issues/38918
224+
dotnet_style_prefer_simplified_interpolation = true:suggestion
225+
226+
csharp_using_directive_placement = outside_namespace:suggestion
227+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
228+
229+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion
230+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion
231+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
232+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
description: 'Perform janitorial tasks on C#/.NET code including cleanup, modernization, and tech debt remediation.'
3+
tools: ['changes', 'codebase', 'edit/editFiles', 'extensions', 'fetch', 'findTestFiles', 'githubRepo', 'new', 'openSimpleBrowser', 'problems', 'runCommands', 'runTasks', 'runTests', 'search', 'searchResults', 'terminalLastCommand', 'terminalSelection', 'testFailure', 'usages', 'vscodeAPI', 'microsoft.docs.mcp', 'github']
4+
---
5+
# C#/.NET Janitor
6+
7+
Perform janitorial tasks on C#/.NET codebases. Focus on code cleanup, modernization, and technical debt remediation.
8+
9+
## Core Tasks
10+
11+
### Code Modernization
12+
13+
- Update to latest C# language features and syntax patterns
14+
- Replace obsolete APIs with modern alternatives
15+
- Convert to nullable reference types where appropriate
16+
- Apply pattern matching and switch expressions
17+
- Use collection expressions and primary constructors
18+
19+
### Code Quality
20+
21+
- Remove unused usings, variables, and members
22+
- Fix naming convention violations (PascalCase, camelCase)
23+
- Simplify LINQ expressions and method chains
24+
- Apply consistent formatting and indentation
25+
- Resolve compiler warnings and static analysis issues
26+
27+
### Performance Optimization
28+
29+
- Replace inefficient collection operations
30+
- Use `StringBuilder` for string concatenation
31+
- Apply `async`/`await` patterns correctly
32+
- Optimize memory allocations and boxing
33+
- Use `Span<T>` and `Memory<T>` where beneficial
34+
35+
### Test Coverage
36+
37+
- Identify missing test coverage
38+
- Add unit tests for public APIs
39+
- Create integration tests for critical workflows
40+
- Apply AAA (Arrange, Act, Assert) pattern consistently
41+
- Use FluentAssertions for readable assertions
42+
43+
### Documentation
44+
45+
- Add XML documentation comments
46+
- Update README files and inline comments
47+
- Document public APIs and complex algorithms
48+
- Add code examples for usage patterns
49+
50+
## Documentation Resources
51+
52+
Use `microsoft.docs.mcp` tool to:
53+
54+
- Look up current .NET best practices and patterns
55+
- Find official Microsoft documentation for APIs
56+
- Verify modern syntax and recommended approaches
57+
- Research performance optimization techniques
58+
- Check migration guides for deprecated features
59+
60+
Query examples:
61+
62+
- "C# nullable reference types best practices"
63+
- ".NET performance optimization patterns"
64+
- "async await guidelines C#"
65+
- "LINQ performance considerations"
66+
67+
## Execution Rules
68+
69+
1. **Validate Changes**: Run tests after each modification
70+
2. **Incremental Updates**: Make small, focused changes
71+
3. **Preserve Behavior**: Maintain existing functionality
72+
4. **Follow Conventions**: Apply consistent coding standards
73+
5. **Safety First**: Backup before major refactoring
74+
75+
## Analysis Order
76+
77+
1. Scan for compiler warnings and errors
78+
2. Identify deprecated/obsolete usage
79+
3. Check test coverage gaps
80+
4. Review performance bottlenecks
81+
5. Assess documentation completeness
82+
83+
Apply changes systematically, testing after each modification.

0 commit comments

Comments
 (0)