From 568e8f21bbdf23e07b75109f0845710b2157862d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 30 Jan 2026 12:04:08 +0000 Subject: [PATCH 1/4] Initial plan From 7b76d133362697c350e0957ab18b4694427ee4c6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 30 Jan 2026 12:10:16 +0000 Subject: [PATCH 2/4] Add JIT regression test skill for extracting test cases from GitHub issues Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com> --- .github/skills/jit-regression-test/SKILL.md | 228 ++++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100644 .github/skills/jit-regression-test/SKILL.md diff --git a/.github/skills/jit-regression-test/SKILL.md b/.github/skills/jit-regression-test/SKILL.md new file mode 100644 index 00000000000000..ed0fc95a8984d1 --- /dev/null +++ b/.github/skills/jit-regression-test/SKILL.md @@ -0,0 +1,228 @@ +--- +name: jit-regression-test +description: Extract a standalone JIT regression test case from a given GitHub issue and save it under the JitBlue folder. Use this when asked to create or extract a JIT regression test from an issue. +--- + +# JIT Regression Test Extraction + +When you need to extract a JIT regression test case from a GitHub issue, follow this process to create a properly structured test under `src/tests/JIT/Regression/JitBlue/`. + +## Step 1: Gather Information from the GitHub Issue + +From the GitHub issue, extract: +1. **Issue number** - Used to name the test folder and files (e.g., issue #99391 → `Runtime_99391`) +2. **Reproduction code** - The C# code that demonstrates the bug +3. **Environment variables** - Any DOTNET_* environment variables required to reproduce the bug +4. **Expected behavior** - What the correct output/behavior should be + +## Step 2: Create the Test Directory + +Create a new folder under `src/tests/JIT/Regression/JitBlue/`: + +``` +src/tests/JIT/Regression/JitBlue/Runtime_/ +``` + +## Step 3: Create the Test File + +Create a `Runtime_.cs` file following these conventions: + +### Basic Structure + +```csharp +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + + +namespace Runtime_; + +using System; +using System.Runtime.CompilerServices; +using Xunit; + +public class Runtime_ +{ + [Fact] + public static void TestEntryPoint() + { + // Test code that exercises the bug + // Use Assert.Equal, Assert.True, etc. for validation + } +} +``` + +### Key Conventions + +- **License header**: Always include the standard .NET Foundation license header +- **Namespace**: Use `Runtime_;` with file-scoped namespace +- **Using directives**: Place `using` statements after the namespace declaration +- **Class name**: Match the file name exactly (`Runtime_`) +- **Test method**: Use `[Fact]` attribute and name the method `TestEntryPoint()` or `Test()` +- **Return type**: Two options: + - `void` with Assert methods (preferred for most cases) + - `int` returning 100 for success, any other value for failure (legacy pattern) +- **Assertions**: Prefer `Assert.Equal`, `Assert.True`, `Assert.False` from Xunit + +### Example: Simple Test (from Runtime_99391) + +```csharp +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + + +namespace Runtime_99391; + +using System; +using System.Runtime.CompilerServices; +using System.Numerics; +using Xunit; + +public class Runtime_99391 +{ + [Fact] + public static void TestEntryPoint() + { + Vector2 result2a = Vector2.Normalize(Value2); + Assert.Equal(new Vector2(0, 1), result2a); + } + + private static Vector2 Value2 + { + [MethodImpl(MethodImplOptions.NoInlining)] + get => new Vector2(0, 2); + } +} +``` + +### Example: Test with Return Code (from Runtime_97625) + +```csharp +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + + +namespace Runtime_97625; + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +public static class Runtime_97625 +{ + public class CustomModel + { + public decimal Cost { get; set; } + } + + [Fact] + public static int Test() + { + List models = new List(); + models.Add(new CustomModel { Cost = 1 }); + return models.Average(x => x.Cost) == 1 ? 100 : -1; + } +} +``` + +## Step 4: Create a .csproj File (Only When Needed) + +A custom `.csproj` file is **only required** when: +- Environment variables are needed to reproduce the bug +- Unsafe code is used (`AllowUnsafeBlocks`) +- Special compilation settings are required + +### When Environment Variables Are Required + +If the issue mentions environment variables like `DOTNET_TieredCompilation=0`, `DOTNET_JitStressModeNames`, etc., create a `Runtime_.csproj` file: + +```xml + + + True + None + + true + + + + + + + +``` + +### Common Environment Variable Patterns + +| Scenario | Environment Variables | +|----------|----------------------| +| Disable tiered compilation | `DOTNET_TieredCompilation=0` | +| Enable tiered PGO | `DOTNET_TieredCompilation=1`, `DOTNET_TieredPGO=1` | +| Disable hardware intrinsics | `DOTNET_EnableHWIntrinsic=0` | +| JIT stress mode | `DOTNET_JitStressModeNames=STRESS_*` | + +### When Unsafe Code Is Used + +If the test uses `unsafe` blocks or pointers: + +```xml + + + True + None + true + + + + + +``` + +### Example: Full .csproj with Environment Variables (from Runtime_95315) + +```xml + + + True + None + true + + true + + + + + + + + +``` + +## Step 5: Verify the Test + +After creating the test files, verify they compile and run: + +1. Navigate to the test directory +2. Build the test: `dotnet build` +3. Run the test: `dotnet build /t:test` + +## Important Notes + +- **No .csproj needed for simple tests**: Most tests only need the `.cs` file. The test infrastructure uses default settings that work for most cases. +- **Look at recent tests**: When in doubt, examine recent tests under `src/tests/JIT/Regression/JitBlue/Runtime_*` for the latest conventions. +- **Use `[MethodImpl(MethodImplOptions.NoInlining)]`**: When you need to prevent inlining to reproduce a JIT bug. +- **Minimize the reproduction**: Strip down the test code to the minimal case that reproduces the issue. + +## Test Location + +All tests should be placed in: +``` +src/tests/JIT/Regression/JitBlue/Runtime_/ +``` + +The final structure should be: +``` +Runtime_/ +├── Runtime_.cs +└── Runtime_.csproj (optional, only if needed) +``` From 55f22f5b530b24f1a2dcfa9976146578eff2b3f8 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Fri, 30 Jan 2026 22:04:19 +0100 Subject: [PATCH 3/4] Update SKILL.md --- .github/skills/jit-regression-test/SKILL.md | 118 +------------------- 1 file changed, 4 insertions(+), 114 deletions(-) diff --git a/.github/skills/jit-regression-test/SKILL.md b/.github/skills/jit-regression-test/SKILL.md index ed0fc95a8984d1..4f0f23d31e8831 100644 --- a/.github/skills/jit-regression-test/SKILL.md +++ b/.github/skills/jit-regression-test/SKILL.md @@ -11,7 +11,7 @@ When you need to extract a JIT regression test case from a GitHub issue, follow From the GitHub issue, extract: 1. **Issue number** - Used to name the test folder and files (e.g., issue #99391 → `Runtime_99391`) -2. **Reproduction code** - The C# code that demonstrates the bug +2. **Reproduction code** - The C# code that demonstrates the bug. If no code provided, try to compose it yourself. 3. **Environment variables** - Any DOTNET_* environment variables required to reproduce the bug 4. **Expected behavior** - What the correct output/behavior should be @@ -27,15 +27,12 @@ src/tests/JIT/Regression/JitBlue/Runtime_/ Create a `Runtime_.cs` file following these conventions: -### Basic Structure +Example: ```csharp // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - -namespace Runtime_; - using System; using System.Runtime.CompilerServices; using Xunit; @@ -54,14 +51,9 @@ public class Runtime_ ### Key Conventions - **License header**: Always include the standard .NET Foundation license header -- **Namespace**: Use `Runtime_;` with file-scoped namespace -- **Using directives**: Place `using` statements after the namespace declaration - **Class name**: Match the file name exactly (`Runtime_`) - **Test method**: Use `[Fact]` attribute and name the method `TestEntryPoint()` or `Test()` -- **Return type**: Two options: - - `void` with Assert methods (preferred for most cases) - - `int` returning 100 for success, any other value for failure (legacy pattern) -- **Assertions**: Prefer `Assert.Equal`, `Assert.True`, `Assert.False` from Xunit +- **Assertions**: Use Xunit's helpers or just throw plain exceptions. ### Example: Simple Test (from Runtime_99391) @@ -94,46 +86,12 @@ public class Runtime_99391 } ``` -### Example: Test with Return Code (from Runtime_97625) - -```csharp -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - - -namespace Runtime_97625; - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; - -public static class Runtime_97625 -{ - public class CustomModel - { - public decimal Cost { get; set; } - } - - [Fact] - public static int Test() - { - List models = new List(); - models.Add(new CustomModel { Cost = 1 }); - return models.Average(x => x.Cost) == 1 ? 100 : -1; - } -} -``` - -## Step 4: Create a .csproj File (Only When Needed) +## [Optional] Step 4: Create a .csproj File (Only When Needed) A custom `.csproj` file is **only required** when: - Environment variables are needed to reproduce the bug -- Unsafe code is used (`AllowUnsafeBlocks`) - Special compilation settings are required -### When Environment Variables Are Required - If the issue mentions environment variables like `DOTNET_TieredCompilation=0`, `DOTNET_JitStressModeNames`, etc., create a `Runtime_.csproj` file: ```xml @@ -152,77 +110,9 @@ If the issue mentions environment variables like `DOTNET_TieredCompilation=0`, ` ``` -### Common Environment Variable Patterns - -| Scenario | Environment Variables | -|----------|----------------------| -| Disable tiered compilation | `DOTNET_TieredCompilation=0` | -| Enable tiered PGO | `DOTNET_TieredCompilation=1`, `DOTNET_TieredPGO=1` | -| Disable hardware intrinsics | `DOTNET_EnableHWIntrinsic=0` | -| JIT stress mode | `DOTNET_JitStressModeNames=STRESS_*` | - -### When Unsafe Code Is Used - -If the test uses `unsafe` blocks or pointers: - -```xml - - - True - None - true - - - - - -``` - -### Example: Full .csproj with Environment Variables (from Runtime_95315) - -```xml - - - True - None - true - - true - - - - - - - - -``` - -## Step 5: Verify the Test - -After creating the test files, verify they compile and run: - -1. Navigate to the test directory -2. Build the test: `dotnet build` -3. Run the test: `dotnet build /t:test` - ## Important Notes - **No .csproj needed for simple tests**: Most tests only need the `.cs` file. The test infrastructure uses default settings that work for most cases. - **Look at recent tests**: When in doubt, examine recent tests under `src/tests/JIT/Regression/JitBlue/Runtime_*` for the latest conventions. - **Use `[MethodImpl(MethodImplOptions.NoInlining)]`**: When you need to prevent inlining to reproduce a JIT bug. - **Minimize the reproduction**: Strip down the test code to the minimal case that reproduces the issue. - -## Test Location - -All tests should be placed in: -``` -src/tests/JIT/Regression/JitBlue/Runtime_/ -``` - -The final structure should be: -``` -Runtime_/ -├── Runtime_.cs -└── Runtime_.csproj (optional, only if needed) -``` From b5a7c0905688ee0534271b4a4be4f394a9fa13c0 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Fri, 30 Jan 2026 22:07:04 +0100 Subject: [PATCH 4/4] Update SKILL.md --- .github/skills/jit-regression-test/SKILL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/skills/jit-regression-test/SKILL.md b/.github/skills/jit-regression-test/SKILL.md index 4f0f23d31e8831..6f86920dea902d 100644 --- a/.github/skills/jit-regression-test/SKILL.md +++ b/.github/skills/jit-regression-test/SKILL.md @@ -89,10 +89,10 @@ public class Runtime_99391 ## [Optional] Step 4: Create a .csproj File (Only When Needed) A custom `.csproj` file is **only required** when: -- Environment variables are needed to reproduce the bug +- Environment variables are needed to reproduce the bug (such as `DOTNET_JitStressModeNames`) - Special compilation settings are required -If the issue mentions environment variables like `DOTNET_TieredCompilation=0`, `DOTNET_JitStressModeNames`, etc., create a `Runtime_.csproj` file: +It should be located next to the test source file with the following name: `Runtime_.csproj`. Example: ```xml