|  | 
| 1 | 1 | # GitHub Copilot Instructions for F# Compiler | 
| 2 | 2 | 
 | 
| 3 |  | -## Build and test steps (only on Linux) | 
| 4 |  | - | 
| 5 |  | -Always build and test the project before submitting your final solution. | 
| 6 |  | - | 
| 7 |  | -In order to build and test, run  `./build.sh -c Release --testcoreclr` . | 
| 8 |  | - | 
| 9 |  | -If the build fails with errors or non-zero exit code, fix it based on the error messages given and repeat the build step. | 
| 10 |  | - | 
| 11 |  | -If either of the steps 3 fails, fix the errors and repeat - up to 3 times. | 
| 12 |  | -After that, report all relevant build errors, error messages and specific details about failing tests and their test test failure details. | 
| 13 |  | - | 
| 14 |  | -### Fixing tests | 
| 15 |  | - | 
| 16 |  | -- If any of the tests fail: Check if the test, test expectation (either inline in the test or a reference file configured for the test) or implementation needs updating, and fix it | 
| 17 |  | -- If you see test failures for Surface area baselines: Refer to "Updating FCS surface area baselines" in devguide.md | 
| 18 |  | -- If you see test failures for IL baselines: Refer to "Updating ILVerify baselines" in devguide.md | 
| 19 |  | - | 
| 20 |  | - | 
| 21 |  | -## Acceptance criteria | 
| 22 |  | - | 
| 23 |  | -- Code is formatted using `dotnet fantomas .` executed at the repo root. | 
| 24 |  | -- Builds without errors. | 
| 25 |  | -- Runs tests without errors. If some tests needed adjustments, those test expectations/baseline adjustments were done. | 
| 26 |  | -- Follow the docs/release-notes folder by adding release notes. The guidelines are in docs/release-notes/About.md. | 
| 27 |  | -- If the acceptance criteria was not met, collect the error messages (build failures or failing tests) and report them. | 
| 28 |  | - | 
| 29 |  | -## Release notes | 
| 30 |  | -- Each PR must have release notes attached. Those are saved in the `docs` folder, split by version and product aspect. Follow the existing notes to figure out the right format. | 
| 31 |  | -- Follow the docs/release-notes structure and writing style. The guidelines are in docs/release-notes/About.md. | 
| 32 |  | - | 
| 33 |  | -## Coding standards | 
| 34 |  | - | 
| 35 |  | -### Language and Environment | 
| 36 |  | -- Use modern F# with functional-first approach | 
|  | 3 | +## STRUCTURE YOUR CHANGE (BEFORE EDITING) | 
|  | 4 | +Keep scope tight.   | 
|  | 5 | +General guide: | 
|  | 6 | +- Use F# | 
| 37 | 7 | - Target .NET Standard 2.0 for compatibility | 
| 38 |  | -- Avoid external dependencies - the codebase is self-contained | 
| 39 |  | - | 
| 40 |  | -### Code Style and Standards | 
| 41 |  | -- Follow docs/coding-standards.md, especially: | 
| 42 |  | -  - Prefer immutability and pure functions | 
| 43 |  | -  - Use consistent naming (see abbreviation guide) | 
| 44 |  | -  - Process complex types recursively with pattern matching | 
| 45 |  | -  - Avoid single-character identifiers except in established patterns | 
| 46 |  | -- This project uses .fsi signature files. When adding a new public API to a namespace/module which will be consumed from other file, add it to the respective .fsi signature file as well | 
| 47 |  | -- Follow docs/overview.md for key compiler data formats and representations | 
| 48 |  | - | 
| 49 |  | -### Type System Handling | 
| 50 |  | -- When working with `TType` instances, use appropriate stripping functions: | 
| 51 |  | -  - `stripTyparEqns` - Removes inference equations from type parameters | 
| 52 |  | -  - `stripTyEqns` - Removes type equations and type abbreviations | 
| 53 |  | -  - `stripTyEqnsAndErase` - Also erases compilation representations | 
| 54 |  | -  - Match the appropriate stripper to the context (e.g., display vs compilation) | 
| 55 |  | -  - Check equality with `typeEquiv` after stripping rather than direct comparison | 
| 56 |  | - | 
| 57 |  | -### Core Data Structures | 
| 58 |  | -- Use F# discriminated unions for type representations | 
| 59 |  | -- Respect representation hiding through access control | 
| 60 |  | -- Use `remapX` functions when transforming types across boundaries | 
| 61 |  | -- Be aware of performance implications for recursive type operations | 
| 62 |  | - | 
| 63 |  | -### Documentation and Naming | 
| 64 |  | -- Document public APIs with XML comments | 
| 65 |  | -- Use descriptive function names that indicate transformation direction | 
| 66 |  | -- Follow established naming conventions for error messages based on FSComp.txt file. Put all error messages into the FSComp.txt file to ensure localisation | 
|  | 8 | +- Avoid external dependencies – the codebase is self-contained (do NOT add new NuGet packages) | 
|  | 9 | +- Follow docs/coding-standards.md and docs/overview.md | 
|  | 10 | + | 
|  | 11 | +Plan your task: | 
|  | 12 | +1. Write a 1–2 sentence intent (bug fix / API add / language tweak).   | 
|  | 13 | +2. Identify domain: Language (`LanguageFeature.fsi` touched) vs `src/FSharp.Core/` vs `vsintegration/` vs compiler/service.   | 
|  | 14 | +3. Public API? Edit matching `.fsi` simultaneously.   | 
|  | 15 | +4. New/changed diagnostics? Update FSComp.txt.   | 
|  | 16 | +5. IL shape change expected? Plan ILVerify baseline update.   | 
|  | 17 | +6. Expect baseline diffs? Plan `TEST_UPDATE_BSL=1` run.   | 
|  | 18 | +7. Add/adjust tests in existing projects.   | 
|  | 19 | +8. Decide release-notes sink now (Section 8).   | 
|  | 20 | +9. Run formatting only at the end. | 
|  | 21 | + | 
|  | 22 | +--- | 
|  | 23 | + | 
|  | 24 | +# AFTER CHANGING CODE ( Agent-only. Ubuntu only ) | 
|  | 25 | + | 
|  | 26 | +Always run the core command. Always verify exit codes. No assumptions. | 
|  | 27 | + | 
|  | 28 | +## 1. Core Command | 
|  | 29 | +``` | 
|  | 30 | +./build.sh -c Release --testcoreclr | 
|  | 31 | +``` | 
|  | 32 | +Non‑zero → classify & stop. | 
|  | 33 | + | 
|  | 34 | +## 2. Bootstrap (Failure Detection Only) | 
|  | 35 | +Two-phase build. No separate bootstrap command.   | 
|  | 36 | +Early proto/tool errors (e.g. "Error building tools") → `BootstrapFailure` (capture key lines). Stop. | 
|  | 37 | + | 
|  | 38 | +## 3. Build Failure | 
|  | 39 | +Proto ok but solution build fails → `BuildFailure`.   | 
|  | 40 | +Capture exit code, ≤15 error lines (`error FS`, `error F#`, `error MSB`), binlog path: `artifacts/log/Release/Build.*.binlog`.   | 
|  | 41 | +Do not proceed to tests. | 
|  | 42 | + | 
|  | 43 | +## 4. Tests | 
|  | 44 | +Core command runs CoreCLR tests: | 
|  | 45 | +- FSharp.Test.Utilities | 
|  | 46 | +- FSharp.Compiler.ComponentTests | 
|  | 47 | +- FSharp.Compiler.Service.Tests | 
|  | 48 | +- FSharp.Compiler.Private.Scripting.UnitTests | 
|  | 49 | +- FSharp.Build.UnitTests | 
|  | 50 | +- FSharp.Core.UnitTests | 
|  | 51 | +Failures → `TestFailure` (projects + failing lines + baseline hints). | 
|  | 52 | + | 
|  | 53 | +## 5. Baselines | 
|  | 54 | +Drift → update then re-run. | 
|  | 55 | + | 
|  | 56 | +General/component: | 
|  | 57 | +``` | 
|  | 58 | +TEST_UPDATE_BSL=1 | 
|  | 59 | +./build.sh -c Release --testcoreclr | 
|  | 60 | +``` | 
|  | 61 | +Surface area: | 
|  | 62 | +``` | 
|  | 63 | +TEST_UPDATE_BSL=1  | 
|  | 64 | +dotnet test tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj --filter "SurfaceAreaTest" -c Release /p:BUILDING_USING_DOTNET=true | 
|  | 65 | +``` | 
|  | 66 | +ILVerify: | 
|  | 67 | +``` | 
|  | 68 | +TEST_UPDATE_BSL=1  | 
|  | 69 | +pwsh tests/ILVerify/ilverify.ps1 | 
|  | 70 | +``` | 
|  | 71 | +Classify: `BaselineDrift(SurfaceArea|ILVerify|GeneralBSL)` + changed files. | 
|  | 72 | + | 
|  | 73 | +## 6. Formatting | 
|  | 74 | +``` | 
|  | 75 | +dotnet fantomas . --check | 
|  | 76 | +``` | 
|  | 77 | +If fail: | 
|  | 78 | +``` | 
|  | 79 | +dotnet fantomas . | 
|  | 80 | +dotnet fantomas . --check | 
|  | 81 | +``` | 
|  | 82 | +Still failing → `FormattingFailure`. | 
|  | 83 | + | 
|  | 84 | +## 7. Public API / IL | 
|  | 85 | +If new/changed public symbol (`.fsi` touched or public addition): | 
|  | 86 | +1. Update `.fsi`. | 
|  | 87 | +2. Surface area baseline flow. | 
|  | 88 | +3. ILVerify if IL shape changed. | 
|  | 89 | +4. Release notes (Section 8). | 
|  | 90 | +Missed baseline update → `BaselineDrift`. | 
|  | 91 | + | 
|  | 92 | +## 8. Release Notes (Sink Rules – Compact) | 
|  | 93 | +Most fixes → FSharp.Compiler.Service. | 
|  | 94 | + | 
|  | 95 | +| Condition | Sink | | 
|  | 96 | +|-----------|------| | 
|  | 97 | +| `LanguageFeature.fsi` changed | Language | | 
|  | 98 | +| Public API/behavior/perf change under `src/FSharp.Core/` | FSharp.Core | | 
|  | 99 | +| Only `vsintegration/` impacted | VisualStudio | | 
|  | 100 | +| Otherwise | FSharp.Compiler.Service | | 
|  | 101 | + | 
|  | 102 | +Action each needed sink: | 
|  | 103 | +- Append bullet in latest version file under `docs/release-notes/<Sink>/` | 
|  | 104 | +- Format: `* Description. ([PR #NNNNN](https://github.com/dotnet/fsharp/pull/NNNNN))` | 
|  | 105 | +- Optional issue link before PR. | 
|  | 106 | +Missing required entry → `ReleaseNotesMissing`. | 
|  | 107 | + | 
|  | 108 | +## 9. Classifications | 
|  | 109 | +Use one or more exactly: | 
|  | 110 | +- `BootstrapFailure` | 
|  | 111 | +- `BuildFailure` | 
|  | 112 | +- `TestFailure` | 
|  | 113 | +- `FormattingFailure` | 
|  | 114 | +- `BaselineDrift(SurfaceArea|ILVerify|GeneralBSL)` | 
|  | 115 | +- `ReleaseNotesMissing` | 
|  | 116 | + | 
|  | 117 | +Schema: | 
|  | 118 | +``` | 
|  | 119 | +Classification: | 
|  | 120 | +Command: | 
|  | 121 | +ExitCode: | 
|  | 122 | +KeySnippets: | 
|  | 123 | +ActionTaken: | 
|  | 124 | +Result: | 
|  | 125 | +OutstandingIssues: | 
|  | 126 | +``` | 
|  | 127 | + | 
|  | 128 | +## 10. Decision Flow | 
|  | 129 | +1. Format check   | 
|  | 130 | +2. Core command   | 
|  | 131 | +3. If fail classify & stop   | 
|  | 132 | +4. Tests → `TestFailure` if any   | 
|  | 133 | +5. Baseline drift? update → re-run → classify if persists   | 
|  | 134 | +6. Public surface/IL? Section 7   | 
|  | 135 | +7. Release notes sink (Section 8)   | 
|  | 136 | +8. If no unresolved classifications → success summary | 
|  | 137 | + | 
|  | 138 | +## 11. Success Example | 
|  | 139 | +``` | 
|  | 140 | +AllChecksPassed: | 
|  | 141 | +  Formatting: OK | 
|  | 142 | +  Bootstrap: OK | 
|  | 143 | +  Build: OK | 
|  | 144 | +  Tests: Passed | 
|  | 145 | +  Baselines: Clean | 
|  | 146 | +  ReleaseNotes: FSharp.Compiler.Service | 
|  | 147 | +``` | 
|  | 148 | + | 
|  | 149 | +## 12. Failure Example | 
|  | 150 | +``` | 
|  | 151 | +BootstrapFailure: | 
|  | 152 | +  Command: ./build.sh -c Release --testcoreclr | 
|  | 153 | +  ExitCode: 1 | 
|  | 154 | +  KeySnippets: | 
|  | 155 | +    - "Error building tools" | 
|  | 156 | +  ActionTaken: None | 
|  | 157 | +  Result: Stopped | 
|  | 158 | +  OutstandingIssues: Bootstrap must be fixed | 
|  | 159 | +``` | 
|  | 160 | +(eof) | 
0 commit comments