Skip to content

Commit 4e6cc86

Browse files
Merge pull request #201 from CodebreakerApp/copilot/fix-200
Add Copilot instructions targeting .NET 9 instead of .NET 8
2 parents 02de39c + 119936c commit 4e6cc86

2 files changed

Lines changed: 162 additions & 2 deletions

File tree

.github/copilot-instructions.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Copilot Instructions for Codebreaker.Xaml
2+
3+
## Repository Guidelines Alignment
4+
5+
This document extends the existing [guidelines.md](../guidelines.md) with .NET 9 specific guidance:
6+
7+
- **Modern Technologies**: .NET 9 represents the latest modern technology stack
8+
- **Productivity**: Leverage .NET 9 features for shorter, more efficient code
9+
- **Released Versions**: Use .NET 9 as it's a released, stable version
10+
- **Built-in Features**: Prefer .NET 9 built-in features over external libraries
11+
12+
## Target Framework
13+
14+
**Use .NET 9 as the primary target framework** instead of .NET 8 for all new projects and when updating existing projects.
15+
16+
> This follows the repository's guideline to use modern, released versions of .NET. .NET 9 provides significant performance improvements, new language features, and enhanced cross-platform capabilities compared to .NET 8.
17+
18+
### Framework Guidelines
19+
20+
- **Primary Target**: Use `net9.0` for most projects
21+
- **Multi-targeting**: When supporting multiple frameworks, include `net9.0` as the primary target
22+
- **Platform-specific**: Use `net9.0-windows` for Windows-specific projects (WinUI, WPF)
23+
- **Mobile/Cross-platform**: Use appropriate TFMs like `net9.0-android`, `net9.0-ios` for mobile projects
24+
- **Library Projects**: Use multi-targeting for STS and LTS, thus `net9.0` and `net8.0` for maximum compatibility
25+
26+
### Project Types and Framework Usage
27+
28+
#### Desktop Applications
29+
- **WinUI projects**: Use `net9.0-windows10.0.19041.0` (or later Windows version)
30+
- **WPF projects**: Use `net9.0-windows`
31+
- **Avalonia projects**: Use `net9.0` for cross-platform, `net9.0-windows` for Windows-specific features
32+
33+
#### Cross-Platform Applications
34+
- **MAUI projects**: Use `net9.0` as base with platform-specific TFMs
35+
- **Uno Platform projects**: Follow Uno Platform .NET 9 compatibility guidelines
36+
- **Avalonia cross-platform**: Use `net9.0`
37+
38+
#### Libraries and Shared Code
39+
- **Shared libraries**: Use `net9.0` and `net8.0` for maximum compatibility
40+
- **Multi-target libraries**: Include `net9.0` as primary target, consider `net8.0` for backward compatibility if needed
41+
- **ViewModels**: Target `net9.0` and `net8.0`
42+
43+
## Language and Code Style
44+
45+
- **C# Language Version**: Use the latest C# version compatible with .NET 9
46+
- **Lang Version**: Set `<LangVersion>latest</LangVersion>` in project files to use latest C# features
47+
- **Nullable Reference Types**: Enable with `<Nullable>enable</Nullable>`
48+
- **Implicit Usings**: Enable with `<ImplicitUsings>enable</ImplicitUsings>`
49+
50+
## Modern .NET 9 Features
51+
52+
When writing code, prefer modern .NET 9 and C# features:
53+
54+
### Recommended Patterns
55+
- Use **primary constructors** for classes where appropriate
56+
- Use **collection expressions** for initializing collections
57+
- Use **file-scoped namespaces** for cleaner code organization
58+
- Prefer **record types** over classes for data containers
59+
- Use **minimal APIs** for web services instead of controllers
60+
- Leverage **source generators** for performance-critical scenarios
61+
62+
### Dependency Injection and Configuration
63+
- Use the modern **Host.CreateApplicationBuilder()** pattern
64+
- Prefer **IServiceCollection** extensions for service registration
65+
- Use **configuration binding** with strongly-typed options
66+
- Leverage **keyed services** in .NET 9 for multiple implementations
67+
68+
## Package References
69+
70+
When adding or updating NuGet packages:
71+
72+
- **Microsoft packages**: Use .NET 9 compatible versions (9.x.x)
73+
- **Third-party packages**: Ensure compatibility with .NET 9
74+
- **Community Toolkit**: Use latest versions that support .NET 9
75+
- **UI Frameworks**: Use .NET 9 compatible versions of WinUI, Avalonia, etc.
76+
77+
## Platform-Specific Considerations
78+
79+
### WinUI Projects
80+
- Target Windows 10/11 APIs appropriately
81+
- Use Windows App SDK versions compatible with .NET 9
82+
- Leverage WinUI 3 features optimized for .NET 9
83+
84+
### MAUI Projects
85+
- Use .NET MAUI versions that support .NET 9
86+
- Target latest platform versions where possible
87+
- Utilize MAUI-specific .NET 9 optimizations
88+
89+
### Avalonia Projects
90+
- Use Avalonia versions compatible with .NET 9
91+
- Leverage cross-platform .NET 9 features
92+
- Consider Avalonia's .NET 9 performance improvements
93+
94+
### Uno Platform Projects
95+
- Follow Uno Platform's .NET 9 migration guidelines
96+
- Use compatible Uno.Sdk versions
97+
- Update global.json files to reference .NET 9 compatible tooling
98+
99+
## Codebreaker-Specific Guidance
100+
101+
### Configuration and Dependency Injection
102+
```csharp
103+
// Use .NET 9 Host.CreateApplicationBuilder() pattern
104+
var builder = Host.CreateApplicationBuilder();
105+
106+
// Modern service registration
107+
builder.Services.AddScoped<GamePageViewModel>();
108+
builder.Services.AddHttpClient<IGamesClient, GamesClient>();
109+
```
110+
111+
### Cross-Platform UI Development
112+
- **WinUI**: Leverage .NET 9 performance improvements for Windows applications
113+
- **Avalonia**: Use .NET 9 for enhanced cross-platform compatibility
114+
- **MAUI**: Target .NET 9 for latest mobile development features
115+
116+
### Game Logic and ViewModels
117+
- Use **record types** for game state and model objects
118+
- Leverage **collection expressions** for game collections
119+
- Use **primary constructors** in ViewModels where appropriate
120+
121+
## Migration Guidance
122+
123+
When updating existing projects from .NET 8 to .NET 9:
124+
125+
1. **Update TargetFramework**: Change `net8.0` to `net9.0`
126+
2. **Update Package References**: Bump Microsoft.* packages to 9.x versions
127+
3. **Review Breaking Changes**: Check for any .NET 9 breaking changes
128+
4. **Test Thoroughly**: Ensure all functionality works with .NET 9
129+
5. **Update Global.json**: Ensure SDK references support .NET 9
130+
131+
## Performance and Modern Practices
132+
133+
- Utilize .NET 9 performance improvements
134+
- Use **span and memory APIs** for performance-critical code
135+
- Leverage **async/await patterns** with .NET 9 enhancements
136+
- Consider **AOT compilation** where supported
137+
- Use **generic math** and other .NET 9 features for better performance
138+
139+
## Testing
140+
141+
- Use latest versions of testing frameworks compatible with .NET 9
142+
- Ensure test projects target `net9.0`
143+
- Leverage .NET 9 testing improvements and new APIs
144+
145+
## Build and Deployment
146+
147+
- Update CI/CD pipelines to use .NET 9 SDK
148+
- Ensure deployment targets support .NET 9 runtime
149+
- Use .NET 9 optimizations in release builds
150+
- Consider using .NET 9 specific features for better performance
151+
152+
## Documentation
153+
154+
When documenting code or creating examples:
155+
- Reference .NET 9 APIs and patterns
156+
- Include .NET 9 specific features in code samples
157+
- Update any framework version references in documentation
158+
- Highlight .NET 9 benefits and new capabilities

guidelines.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ Prefer using modern APIs, e.g.
99
* Minimal APIs instead of controllers
1010
* C# records if possible and useful instead of classes and structs
1111
* Primary records when possible
12-
* Use *nullable reference types*, *file-scoped
12+
* collection expressions
13+
* Use *nullable reference types*, *file-scoped namespaces*, *global usings*, *top-level statements* and other modern C# features
14+
*
1315

1416
## Released versions
1517

16-
Use released versions (e.g. .NET 6) to make it easier using the applications and services from all developers.
18+
Use released versions (e.g. .NET 9) to make it easier using the applications and services from all developers.
1719

1820
> An exception from this rule can be applied if a pre-release version is not too far away, it's not expected the pre-release version adds many required changes on the code, and offers many advantages on the implementation (e.g. .NET 7 with Minimal APIs). If needed, a long-time branch can be used to use pre-release versions where this exception does not apply.
1921

0 commit comments

Comments
 (0)