Skip to content

Commit 0227826

Browse files
committed
Improving the copilot instructions
1 parent 59a4a9d commit 0227826

File tree

1 file changed

+57
-11
lines changed

1 file changed

+57
-11
lines changed

.github/copilot-instructions.md

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,74 @@
1-
## Coding Style
1+
## .NET Aspire Community Toolkit — Copilot Coding Instructions
22

3-
- Use spaces for indentation with four-spaces per level, unless it is a csproj file, then use two-spaces per level.
4-
- For integrations use the following namespace rules:
5-
- If the integration is a hosting integration (starts with CommunityToolkit.Aspire.Hosting), extension methods should be placed in `Aspire.Hosting`.
6-
- If the integration is a client integration (starts with CommunityToolkit.Aspire), extension methods should be placed in `Microsoft.Extensions.Hosting`.
3+
### Project Overview
4+
5+
- This repo is a collection of community-driven integrations and extensions for [.NET Aspire](https://aka.ms/dotnet/aspire), supporting a wide range of runtimes and cloud-native patterns.
6+
- Major components are organized by integration in `src/`, with tests in `tests/` and usage examples in `examples/`.
7+
- Each integration is a NuGet package, following naming: `CommunityToolkit.Aspire.Hosting.*` (hosting) or `CommunityToolkit.Aspire.*` (client).
8+
9+
### Architecture & Patterns
10+
11+
- **Resource-based model:** Integrations define resources (e.g., `NodeAppResource`, `NpmInstallerResource`) that appear in the Aspire dashboard and support parent-child relationships for startup ordering and dependency management.
12+
- **Extension methods:**
13+
- Hosting integrations: extension methods in `Aspire.Hosting` namespace.
14+
- Client integrations: extension methods in `Microsoft.Extensions.Hosting` namespace.
715
- Use file-scoped namespaces.
8-
- All public members require doc comments.
9-
- Prefer type declarations over `var` when the type isn't obvious.
10-
- Use the C# Collection Initializer syntax, `List<T> items = []` (where `List<T>` could be any collection type), rather than `new()`.
11-
- Use `is not null` or `is null` over `!= null` and `== null`.
16+
- **Installer resources:** For Node.js, package installers (npm/yarn/pnpm) are modeled as `ExecutableResource` instances, providing dashboard visibility and proper process management. See `src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/REFACTORING_NOTES.md` for rationale and migration.
17+
18+
### Coding Style
1219

13-
## Sample hosting integration
20+
- Use spaces for indentation (4 per level; 2 for `.csproj`).
21+
- All public members require XML doc comments.
22+
- Prefer explicit type declarations unless type is obvious.
23+
- Use collection initializers: `List<T> items = []`.
24+
- Use `is not null`/`is null` over `!= null`/`== null`.
25+
26+
#### Example: Hosting Integration
1427

1528
```csharp
1629
namespace Aspire.Hosting;
1730

1831
public static class SomeProgramExtensions
1932
{
33+
/// <summary>Adds a SomeProgram resource.</summary>
2034
public static IResourceBuilder<SomeProgramResource> AddSomeProgram(
2135
this IDistributedApplicationBuilder builder,
2236
[ResourceName] string name)
2337
{
24-
var resource = new SomeProgramResource(name);
38+
SomeProgramResource resource = new(name);
2539
return builder.AddResource(resource);
2640
}
2741
}
2842
```
43+
44+
### Developer Workflows
45+
46+
- **Build:** Use `dotnet build` or VS Code task `build`.
47+
- **Test:**
48+
- All tests use xUnit. Place test projects in `tests/` (naming: `CommunityToolkit.Aspire.Hosting.MyIntegration.Tests`).
49+
- Integration tests that test containerized resources will require Docker; mark with `[RequiresDocker]` if so.
50+
- Use `WaitForTextAsync` to wait for resource readiness if not using Aspire health checks.
51+
- Add new test projects to CI by running `./eng/testing/generate-test-list-for-workflow.sh` and updating `.github/workflows/tests.yml`.
52+
- **Debug:** For devcontainers, manually forward DCP ports if HTTP endpoints are unreachable.
53+
54+
### Project Conventions
55+
56+
- Integrations must add `Aspire.Hosting` as a dependency; see `Directory.Build.props` for shared MSBuild config.
57+
- Use the [create-integration guide](../docs/create-integration.md) for new integrations.
58+
- For Azure/Dapr integrations, see `src/Shared/DaprAzureExtensions/README.md` for shared resource patterns.
59+
60+
### External Dependencies & Integration
61+
62+
- Many integrations wrap external services (e.g., Dapr, MinIO, k6, Node.js, Python, Rust, Java, etc.).
63+
- Each integration's README in `src/` or `examples/` details usage, supported versions, and special setup.
64+
- For Node.js, package manager flags can be customized via extension methods (see `src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/README.md`).
65+
66+
### Documentation & Contribution
67+
68+
- Main docs: [Microsoft Docs](https://learn.microsoft.com/dotnet/aspire/community-toolkit/overview)
69+
- FAQ: `docs/faq.md` | Contribution: `CONTRIBUTING.md`
70+
- Versioning: `docs/versioning.md` | Diagnostics: `docs/diagnostics.md`
71+
72+
---
73+
74+
If you find any unclear or incomplete sections, please provide feedback to improve these instructions.

0 commit comments

Comments
 (0)