-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Create copilot-instructions.md #115917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Create copilot-instructions.md #115917
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b4a95e1
Create copilot-instructions.md
CarnaViire aaaf1a1
more instructions
CarnaViire ef1d362
Update .github/copilot-instructions.md
CarnaViire 29771cf
Merge branch 'main' into CarnaViire-patch-1
CarnaViire 2f13499
Code review suggestions, unify formatting
CarnaViire 914a4f8
fix sudo
CarnaViire f4219b9
Add missing testhost instruction
CarnaViire 45b25c6
Pre-build clr+libs
CarnaViire a44c846
Apply suggestions from code review
CarnaViire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
Important: **Ensure the code compiles and the tests pass.** Use the "Building & Testing in dotnet/runtime" instructions below. | ||
|
||
Additionally, | ||
|
||
* Don't leave trailling whitespaces. | ||
* Apply code-formatting style defined in `.editorconfig`. | ||
* Prefer file-scoped namespace declarations and single-line using directives. | ||
* Insert a newline before the opening curly brace of any code block (e.g., after `if`, `for`, `while`, `foreach`, `using`, `try`, etc.). | ||
* Ensure that the final return statement of a method is on its own line. | ||
* Use pattern matching and switch expressions wherever possible. | ||
* Use `nameof` instead of string literals when referring to member names. | ||
* Always use `is null` or `is not null` instead of `== null` or `!= null`. | ||
* Trust the C# null annotations and don't add null checks when the type system says a value cannot be null. | ||
* Prefer `?.` if applicable (e.g. `scope?.Dispose()`). | ||
* Use `ObjectDisposedException.ThrowIf` where applicable. | ||
* Use explicit types instead of `var`. | ||
* When writing tests, do not emit "Act", "Arrange" or "Assert" comments. | ||
|
||
--- | ||
|
||
# Building & Testing in dotnet/runtime | ||
|
||
## 1. Prerequisites | ||
|
||
These steps need to be done **before** applying any changes. | ||
|
||
### 1.1. Determine Affected Components | ||
|
||
Identify which components will be impacted by the changes. If in doubt, analyze the paths of the files to be updated: | ||
|
||
- **CoreCLR (CLR):** Changes in `src/coreclr/` or `src/tests/` | ||
- **Mono Runtime:** Changes in `src/mono/` | ||
- **Libraries:** Changes in `src/libraries/` | ||
- **WASM/WASI Libraries:** Changes in `src/libraries/` *and* the affected library targets WASM or WASI *and* the changes are included for the target (see below for details). | ||
- If none above apply, it is most possibly an infra-only or a docs-only change. Skip build and test steps. | ||
|
||
**WASM/WASI Library Change Detection** | ||
A change is considered WASM/WASI-relevant if: | ||
- The relevant `.csproj` contains explicit Browser/WASM or WASI targets (look for `<TargetFrameworks>`, `$(TargetPlatformIdentifier)`, or `Condition` attributes referencing `browser` or `wasi`, as well as `TARGET_BROWSER` or `TARGET_WASI` constants), **and** | ||
- The changed file is not excluded from the build for that platform in any way with a `Condition` attribute on `<ItemGroup>` or `<Compile>`. | ||
|
||
### 1.2. Baseline Setup | ||
|
||
Ensure you have a full successful build of the needed runtime+libraries as a baseline. | ||
|
||
1. Checkout `main` branch | ||
|
||
2. From the repository root, run the build depending on the affected component. If multiple components are affected, subsequently run and verify the builds for all of them. | ||
- **CoreCLR (CLR):** `./build.sh clr+libs` | ||
CarnaViire marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
- **Mono Runtime:** `./build.sh mono+libs` | ||
- **Libraries:** `./build.sh clr+libs -rc release` | ||
CarnaViire marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
- **WASM/WASI Libraries:** `./build.sh mono+libs -os browser` | ||
|
||
3. Verify the build completed without error. | ||
- _If the build failed, report the failure and don't proceed with the changes._ | ||
4. From the repository root: | ||
- Configure PATH: `export PATH="$(pwd)/.dotnet:$PATH"` | ||
- Verify SDK Version: `dotnet --version` should match `sdk.version` in `global.json`. | ||
5. Switch back to the working branch. | ||
|
||
--- | ||
|
||
## 2. Iterative Build and Test Strategy | ||
|
||
1. Apply the intended changes | ||
2. **Attempt Build.** If the build fails, attempt to fix and retry the step (up to 5 attempts). | ||
CarnaViire marked this conversation as resolved.
Show resolved
Hide resolved
|
||
3. **Attempt Test.** | ||
* If a test _build_ fails, attempt to fix and retry the step (up to 5 attempts). | ||
* If a test _run_ fails, | ||
- Determine if the problem is in the test or in the source | ||
- If the problem is in the test, attempt to fix and retry the step (up to 5 attempts). | ||
- If the problem is in the source, reconsider the full changeset, attempt to fix and repeat the workflow. | ||
4. **Workflow Iteration:** | ||
* Repeat build and test up to 5 cycles. | ||
* If issues persist after 5 workflow cycles, report failure. | ||
* If the same error persists after each fix attempt, do not repeat the same fix. Instead, escalate or report with full logs. | ||
|
||
When retrying, attempt different fixes and adjust based on the build/test results. | ||
|
||
### Success Criteria | ||
|
||
* **Build:** | ||
- Completes without errors. | ||
- Any non-zero exit code from build commands is considered a failure. | ||
* **Tests:** | ||
- All tests must pass (zero failures). | ||
- Any non-zero exit code from test commands is considered a failure. | ||
|
||
* **On success:** Report completion; | ||
- Otherwise, report error(s) with logs for diagnostics. | ||
- Collect logs from `artifacts/log/` and the console output for both build and test steps. | ||
- Attach relevant log files or error snippets when reporting failures. | ||
|
||
--- | ||
|
||
## 3. CoreCLR (CLR) Workflow | ||
|
||
From the repository root: | ||
|
||
- Build: `./build.sh -subset clr` | ||
- Run tests: `cd src/tests && ./build.sh` | ||
CarnaViire marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
- More info: | ||
- [Building CoreCLR Guide](https://github.com/dotnet/runtime/blob/main/docs/workflow/building/coreclr/README.md) | ||
- [Building and Running CoreCLR Tests](https://github.com/dotnet/runtime/blob/main/docs/workflow/testing/coreclr/testing.md) | ||
|
||
--- | ||
|
||
## 4. Mono Runtime Workflow | ||
|
||
From the repository root: | ||
|
||
- Build: `./build.sh -subset mono+libs` | ||
|
||
- Run tests: | ||
|
||
```bash | ||
./build.sh clr.host | ||
cd src/tests | ||
./build.sh mono debug /p:LibrariesConfiguration=debug | ||
``` | ||
|
||
- More info: | ||
- [Building Mono](https://github.com/dotnet/runtime/blob/main/docs/workflow/building/mono/README.md) | ||
- [Running test suites using Mono](https://github.com/dotnet/runtime/blob/main/docs/workflow/testing/mono/testing.md) | ||
|
||
--- | ||
|
||
## 5. Libraries Workflow | ||
|
||
From the repository root: | ||
|
||
- Build: `./build.sh -subset libs -rc release` | ||
- Run tests: `./build.sh -subset libs.tests -test -rc release` | ||
|
||
- More info: | ||
- [Build Libraries](https://github.com/dotnet/runtime/blob/main/docs/workflow/building/libraries/README.md) | ||
- [Testing Libraries](https://github.com/dotnet/runtime/blob/main/docs/workflow/testing/libraries/testing.md) | ||
|
||
### HOW-TO: Identify Affected Libraries | ||
|
||
For each changed file under `src/libraries/`, find the matching library and its test project(s): | ||
|
||
* Most libraries use: | ||
|
||
* Source: `src/libraries/<LibraryName>/src/<LibraryName>.csproj` | ||
* Tests (single): | ||
|
||
* `src/libraries/<LibraryName>/tests/<LibraryName>.Tests.csproj` | ||
* OR `src/libraries/<LibraryName>/tests/<LibraryName>.Tests/<LibraryName>.Tests.csproj` | ||
* Tests (multiple types): | ||
|
||
* `src/libraries/<LibraryName>/tests/FunctionalTests/<LibraryName>.Functional.Tests.csproj` | ||
* `src/libraries/<LibraryName>/tests/UnitTests/<LibraryName>.Unit.Tests.csproj` | ||
* Or similar. | ||
|
||
### HOW-TO: Build and Test Specific Library | ||
|
||
If only one library is affected: | ||
|
||
1. **Navigate to the library directory:** `cd src/libraries/<LibraryName>` | ||
2. **Build the library:** `dotnet build` | ||
3. **Build and run all test projects:** | ||
- For each discovered `*.Tests.csproj` in the `tests` subdirectory: | ||
|
||
```bash | ||
dotnet build /t:test ./tests/<TestProject>.csproj | ||
``` | ||
|
||
*(Adjust path as needed. If in doubt, search with `find tests -name '*.csproj'`.)* | ||
|
||
--- | ||
|
||
## 6. WebAssembly (WASM) Libraries Workflow | ||
|
||
From the repository root: | ||
|
||
- Build: `./build.sh libs -os browser` | ||
- Run tests: `./build.sh libs.tests -test -os browser` | ||
|
||
- More info: | ||
- [Build libraries for WebAssembly](https://github.com/dotnet/runtime/blob/main/docs/workflow/building/libraries/webassembly-instructions.md) | ||
- [Testing Libraries on WebAssembly](https://github.com/dotnet/runtime/blob/main/docs/workflow/testing/libraries/testing-wasm.md) | ||
|
||
--- | ||
|
||
## 7. Additional Notes | ||
|
||
**Troubleshooting** | ||
|
||
If the build fails with an error "The shared framework must be built before the local targeting pack can be consumed.", build the runtime (clr or mono) first. E.g. (from the repo root) `./build.sh clr -c release` | ||
|
||
**Windows Command Equivalents** | ||
|
||
- Use `build.cmd` instead of `build.sh` on Windows. | ||
- Set PATH: `set PATH=%CD%\.dotnet;%PATH%` | ||
- All other commands are similar unless otherwise noted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,61 @@ jobs: | |
steps: | ||
- uses: actions/[email protected] | ||
|
||
# From https://github.com/dotnet/dotnet-buildtools-prereqs-docker/blob/main/src/ubuntu/25.04/helix/Dockerfile | ||
- name: Install dependencies | ||
env: | ||
LIBMSQUIC_VERSION: '2.4.8' | ||
run: | | ||
sudo apt-get update -y && \ | ||
sudo apt-get install -qq -y \ | ||
autoconf \ | ||
automake \ | ||
build-essential \ | ||
cmake \ | ||
clang \ | ||
curl \ | ||
gcc \ | ||
gdb \ | ||
CarnaViire marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
git \ | ||
gss-ntlmssp \ | ||
iputils-ping \ | ||
libcurl4 \ | ||
libffi-dev \ | ||
libicu-dev \ | ||
libssl-dev \ | ||
libtool \ | ||
libunwind8 \ | ||
libunwind-dev \ | ||
lldb \ | ||
llvm \ | ||
locales \ | ||
locales-all \ | ||
python3-dev \ | ||
python3-pip \ | ||
python3-venv \ | ||
software-properties-common \ | ||
sudo \ | ||
tzdata \ | ||
unzip \ | ||
libbpf1 \ | ||
libelf1t64 \ | ||
CarnaViire marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
libnl-3-200 \ | ||
libnl-route-3-200 \ | ||
libnuma1 \ | ||
libxdp1 \ | ||
libkrb5-dev \ | ||
liblttng-ust-dev \ | ||
cpio \ | ||
lld \ | ||
python-is-python3 && \ | ||
curl -LO "https://packages.microsoft.com/ubuntu/24.04/prod/pool/main/libm/libmsquic/libmsquic_${LIBMSQUIC_VERSION}_amd64.deb" && \ | ||
sudo dpkg -i libmsquic* && \ | ||
rm libmsquic* | ||
CarnaViire marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Restore solution | ||
run: ./build.sh --restore --excludecibinarylog --warnaserror false /p:BuildAllConfigurations=true /p:DotNetBuildAllRuntimePacks=true | ||
env: | ||
RESTORE_ARGS: --restore --excludecibinarylog --warnaserror false /p:BuildAllConfigurations=true /p:DotNetBuildAllRuntimePacks=true | ||
# 'DefaultSubsets' don't include 'libs.tests', so restoring it explicitly | ||
run: | | ||
./build.sh $RESTORE_ARGS && \ | ||
./build.sh libs.tests $RESTORE_ARGS |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.