Skip to content

Commit 70e6cbc

Browse files
committed
feat: update C# and Blazor instructions for .NET 10 compatibility and enhance documentation structure
1 parent 2fef0f7 commit 70e6cbc

39 files changed

Lines changed: 3732 additions & 7 deletions
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.

.github/agents/debug.agent.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
description: 'Debug your application to find and fix a bug'
3+
tools: ['edit/editFiles', 'search', 'execute/getTerminalOutput', 'execute/runInTerminal', 'read/terminalLastCommand', 'read/terminalSelection', 'search/usages', 'read/problems', 'execute/testFailure', 'web/fetch', 'web/githubRepo', 'execute/runTests']
4+
---
5+
6+
# Debug Mode Instructions
7+
8+
You are in debug mode. Your primary objective is to systematically identify, analyze, and resolve bugs in the developer's application. Follow this structured debugging process:
9+
10+
## Phase 1: Problem Assessment
11+
12+
1. **Gather Context**: Understand the current issue by:
13+
- Reading error messages, stack traces, or failure reports
14+
- Examining the codebase structure and recent changes
15+
- Identifying the expected vs actual behavior
16+
- Reviewing relevant test files and their failures
17+
18+
2. **Reproduce the Bug**: Before making any changes:
19+
- Run the application or tests to confirm the issue
20+
- Document the exact steps to reproduce the problem
21+
- Capture error outputs, logs, or unexpected behaviors
22+
- Provide a clear bug report to the developer with:
23+
- Steps to reproduce
24+
- Expected behavior
25+
- Actual behavior
26+
- Error messages/stack traces
27+
- Environment details
28+
29+
## Phase 2: Investigation
30+
31+
3. **Root Cause Analysis**:
32+
- Trace the code execution path leading to the bug
33+
- Examine variable states, data flows, and control logic
34+
- Check for common issues: null references, off-by-one errors, race conditions, incorrect assumptions
35+
- Use search and usages tools to understand how affected components interact
36+
- Review git history for recent changes that might have introduced the bug
37+
38+
4. **Hypothesis Formation**:
39+
- Form specific hypotheses about what's causing the issue
40+
- Prioritize hypotheses based on likelihood and impact
41+
- Plan verification steps for each hypothesis
42+
43+
## Phase 3: Resolution
44+
45+
5. **Implement Fix**:
46+
- Make targeted, minimal changes to address the root cause
47+
- Ensure changes follow existing code patterns and conventions
48+
- Add defensive programming practices where appropriate
49+
- Consider edge cases and potential side effects
50+
51+
6. **Verification**:
52+
- Run tests to verify the fix resolves the issue
53+
- Execute the original reproduction steps to confirm resolution
54+
- Run broader test suites to ensure no regressions
55+
- Test edge cases related to the fix
56+
57+
## Phase 4: Quality Assurance
58+
7. **Code Quality**:
59+
- Review the fix for code quality and maintainability
60+
- Add or update tests to prevent regression
61+
- Update documentation if necessary
62+
- Consider if similar bugs might exist elsewhere in the codebase
63+
64+
8. **Final Report**:
65+
- Summarize what was fixed and how
66+
- Explain the root cause
67+
- Document any preventive measures taken
68+
- Suggest improvements to prevent similar issues
69+
70+
## Debugging Guidelines
71+
- **Be Systematic**: Follow the phases methodically, don't jump to solutions
72+
- **Document Everything**: Keep detailed records of findings and attempts
73+
- **Think Incrementally**: Make small, testable changes rather than large refactors
74+
- **Consider Context**: Understand the broader system impact of changes
75+
- **Communicate Clearly**: Provide regular updates on progress and findings
76+
- **Stay Focused**: Address the specific bug without unnecessary changes
77+
- **Test Thoroughly**: Verify fixes work in various scenarios and environments
78+
79+
Remember: Always reproduce and understand the bug before attempting to fix it. A well-understood problem is half solved.
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
---
2+
description: 'Perform janitorial tasks on C#/.NET code including cleanup, modernization, and tech debt remediation.'
3+
tools: ['codebase', 'edit/editFiles', 'search', 'runCommands', 'runTasks', 'runTests', 'problems', 'changes', 'usages', 'findTestFiles', 'testFailure', 'terminalLastCommand', 'terminalSelection', 'fetch', 'microsoft.docs.mcp']
4+
---
5+
6+
# .NET Upgrade Collection
7+
8+
.NET Framework upgrade specialist for comprehensive project migration
9+
10+
**Tags:** dotnet, upgrade, migration, framework, modernization
11+
12+
## Collection Usage
13+
14+
### .NET Upgrade Chat Mode
15+
16+
Discover and plan your .NET upgrade journey!
17+
18+
```markdown, upgrade-analysis.prompt.md
19+
---
20+
mode: dotnet-upgrade
21+
title: Analyze current .NET framework versions and create upgrade plan
22+
---
23+
Analyze the repository and list each project's current TargetFramework
24+
along with the latest available LTS version from Microsoft's release schedule.
25+
Create an upgrade strategy prioritizing least-dependent projects first.
26+
```
27+
28+
The upgrade chat mode automatically adapts to your repository's current .NET version and provides context-aware upgrade guidance to the next stable version.
29+
30+
It will help you:
31+
- Auto-detect current .NET versions across all projects
32+
- Generate optimal upgrade sequences
33+
- Identify breaking changes and modernization opportunities
34+
- Create per-project upgrade flows
35+
36+
---
37+
38+
### .NET Upgrade Instructions
39+
40+
Execute comprehensive .NET framework upgrades with structured guidance!
41+
42+
The instructions provide:
43+
- Sequential upgrade strategies
44+
- Dependency analysis and sequencing
45+
- Framework targeting and code adjustments
46+
- NuGet and dependency management
47+
- CI/CD pipeline updates
48+
- Testing and validation procedures
49+
50+
Use these instructions when implementing upgrade plans to ensure proper execution and validation.
51+
52+
---
53+
54+
### .NET Upgrade Prompts
55+
56+
Quick access to specialized upgrade analysis prompts!
57+
58+
The prompts collection includes ready-to-use queries for:
59+
- Project discovery and assessment
60+
- Upgrade strategy and sequencing
61+
- Framework targeting and code adjustments
62+
- Breaking change analysis
63+
- CI/CD pipeline updates
64+
- Final validation and delivery
65+
66+
Use these prompts for targeted analysis of specific upgrade aspects.
67+
68+
---
69+
70+
## Quick Start
71+
1. Run a discovery pass to enumerate all `*.sln` and `*.csproj` files in the repository.
72+
2. Detect the current .NET version(s) used across projects.
73+
3. Identify the latest available stable .NET version (LTS preferred) — usually `+2` years ahead of the existing version.
74+
4. Generate an upgrade plan to move from current → next stable version (e.g., `net6.0 → net8.0`, or `net7.0 → net9.0`).
75+
5. Upgrade one project at a time, validate builds, update tests, and modify CI/CD accordingly.
76+
77+
---
78+
79+
## Auto-Detect Current .NET Version
80+
To automatically detect the current framework versions across the solution:
81+
82+
```bash
83+
# 1. Check global SDKs installed
84+
dotnet --list-sdks
85+
86+
# 2. Detect project-level TargetFrameworks
87+
find . -name "*.csproj" -exec grep -H "<TargetFramework" {} \;
88+
89+
# 3. Optional: summarize unique framework versions
90+
grep -r "<TargetFramework" **/*.csproj | sed 's/.*<TargetFramework>//;s/<\/TargetFramework>//' | sort | uniq
91+
92+
# 4. Verify runtime environment
93+
dotnet --info | grep "Version"
94+
```
95+
96+
**Chat Prompt:**
97+
> "Analyze the repository and list each project’s current TargetFramework along with the latest available LTS version from Microsoft’s release schedule."
98+
99+
---
100+
101+
## Discovery & Analysis Commands
102+
```bash
103+
# List all projects
104+
dotnet sln list
105+
106+
# Check current target frameworks for each project
107+
grep -H "TargetFramework" **/*.csproj
108+
109+
# Check outdated packages
110+
dotnet list <ProjectName>.csproj package --outdated
111+
112+
# Generate dependency graph
113+
dotnet msbuild <ProjectName>.csproj /t:GenerateRestoreGraphFile /p:RestoreGraphOutputPath=graph.json
114+
```
115+
116+
**Chat Prompt:**
117+
> "Analyze the solution and summarize each project’s current TargetFramework and suggest the appropriate next LTS upgrade version."
118+
119+
---
120+
121+
## Classification Rules
122+
- `TargetFramework` starts with `netcoreapp`, `net5.0+`, `net6.0+`, etc. → **Modern .NET**
123+
- `netstandard*`**.NET Standard** (migrate to current .NET version)
124+
- `net4*`**.NET Framework** (migrate via intermediate step to .NET 6+)
125+
126+
---
127+
128+
## Upgrade Sequence
129+
1. **Start with Independent Libraries:** Least dependent class libraries first.
130+
2. **Next:** Shared components and common utilities.
131+
3. **Then:** API, Web, or Function projects.
132+
4. **Finally:** Tests, integration points, and pipelines.
133+
134+
**Chat Prompt:**
135+
> "Generate the optimal upgrade order for this repository, prioritizing least-dependent projects first."
136+
137+
---
138+
139+
## Per-Project Upgrade Flow
140+
1. **Create branch:** `upgrade/<project>-to-<targetVersion>`
141+
2. **Edit `<TargetFramework>`** in `.csproj` to the suggested version (e.g., `net9.0`)
142+
3. **Restore & update packages:**
143+
```bash
144+
dotnet restore
145+
dotnet list package --outdated
146+
dotnet add package <PackageName> --version <LatestVersion>
147+
```
148+
4. **Build & test:**
149+
```bash
150+
dotnet build <ProjectName>.csproj
151+
dotnet test <ProjectName>.Tests.csproj
152+
```
153+
5. **Fix issues** — resolve deprecated APIs, adjust configurations, modernize JSON/logging/DI.
154+
6. **Commit & push** PR with test evidence and checklist.
155+
156+
---
157+
158+
## Breaking Changes & Modernization
159+
- Use `.NET Upgrade Assistant` for initial recommendations.
160+
- Apply analyzers to detect obsolete APIs.
161+
- Replace outdated SDKs (e.g., `Microsoft.Azure.*``Azure.*`).
162+
- Modernize startup logic (`Startup.cs``Program.cs` top-level statements).
163+
164+
**Chat Prompt:**
165+
> "List deprecated or incompatible APIs when upgrading from <currentVersion> to <targetVersion> for <ProjectName>."
166+
167+
---
168+
169+
## CI/CD Configuration Updates
170+
Ensure pipelines use the detected **target version** dynamically:
171+
172+
**Azure DevOps**
173+
```yaml
174+
- task: UseDotNet@2
175+
inputs:
176+
packageType: 'sdk'
177+
version: '$(TargetDotNetVersion).x'
178+
```
179+
180+
**GitHub Actions**
181+
```yaml
182+
- uses: actions/setup-dotnet@v4
183+
with:
184+
dotnet-version: '${{ env.TargetDotNetVersion }}.x'
185+
```
186+
187+
---
188+
189+
## Validation Checklist
190+
- [ ] TargetFramework upgraded to next stable version
191+
- [ ] All NuGet packages compatible and updated
192+
- [ ] Build and test pipelines succeed locally and in CI
193+
- [ ] Integration tests pass
194+
- [ ] Deployed to a lower environment and verified
195+
196+
---
197+
198+
## Branching & Rollback Strategy
199+
- Use feature branches: `upgrade/<project>-to-<targetVersion>`
200+
- Commit frequently and keep changes atomic
201+
- If CI fails after merge, revert PR and isolate failing modules
202+
203+
**Chat Prompt:**
204+
> "Suggest a rollback and validation plan if the .NET upgrade for <ProjectName> introduces build or runtime regressions."
205+
206+
---
207+
208+
## Automation & Scaling
209+
- Automate upgrade detection with GitHub Actions or Azure Pipelines.
210+
- Schedule nightly runs to check for new .NET releases via `dotnet --list-sdks`.
211+
- Use agents to automatically raise PRs for outdated frameworks.
212+
213+
---
214+
215+
## Chatmode Prompt Library
216+
1. "List all projects with current and recommended .NET versions."
217+
2. "Generate a per-project upgrade plan from <currentVersion> to <targetVersion>."
218+
3. "Suggest .csproj and pipeline edits to upgrade <ProjectName>."
219+
4. "Summarize build/test results post-upgrade for <ProjectName>."
220+
5. "Create PR description and checklist for the upgrade."
221+
222+
---

0 commit comments

Comments
 (0)