-
Notifications
You must be signed in to change notification settings - Fork 832
Add compiler compatibility test suite for anonymous records with MSBuild-generated build verification and comprehensive documentation #18913
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
T-Gro
merged 32 commits into
main
from
copilot/fix-7efdf64f-592c-4ce7-9871-9e7dadc5a81e
Oct 22, 2025
+584
−15
Merged
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
c628564
Initial plan
Copilot e8d910f
Add compiler compatibility test suite with anonymous records
Copilot bbefae5
Complete compiler compatibility test suite implementation
Copilot 13ca28d
Final implementation of compiler compatibility test suite
Copilot c5a2700
Address code review feedback: parametrized tests, global.json support…
Copilot 360ae63
Address code review: fix LoadLocalFSharpBuild, simplify versions, rem…
Copilot 9ea30da
Fix test failures: replace Unicode checkmarks with platform-agnostic …
Copilot 86a9207
Add .NET 9 test cases and build verification info
Copilot 2720a6f
Enhance build verification with detailed compiler tracking
Copilot 91da72a
Fix CI failures by removing .NET 9 dependency
Copilot 9846cef
Merge branch 'main' into copilot/fix-7efdf64f-592c-4ce7-9871-9e7dadc5…
T-Gro 194b5fe
Implement proper build-time generated BuildInfo files with MSBuild ta…
Copilot 8fc9d44
Fix CI compilation errors by converting arrays to lists for String.co…
Copilot f3cd733
Add comprehensive build verification assertions to prevent regressions
Copilot 8294e80
Remove BuildInfo files from repository - they should be generated at …
Copilot c2a1464
Merge branch 'main' into copilot/fix-7efdf64f-592c-4ce7-9871-9e7dadc5…
T-Gro 9f5a170
address build errors
T-Gro ee94052
Make it actually correct via human intervention
T-Gro 4b7d566
Apply suggestion from @T-Gro
T-Gro c5a8fa3
Merge branch 'main' into copilot/fix-7efdf64f-592c-4ce7-9871-9e7dadc5…
T-Gro 45c0567
Fix SDK version compatibility and rollForward policy
Copilot 44e61f0
Fix all remaining SDK version references to 9.0.300
Copilot 036cf72
Move from vstest (messes up with envvars and msbuild) to standalone f…
T-Gro 25121d0
try using the arcade dotnet script
T-Gro 921af4a
Add comprehensive README documentation to CompilerCompatibilityTests
Copilot 776ef49
Merge branch 'main' into copilot/fix-7efdf64f-592c-4ce7-9871-9e7dadc5…
T-Gro f5aedac
Apply suggestion from @T-Gro
T-Gro b39c8ea
Apply suggestion from @T-Gro
T-Gro 426812c
Apply suggestion from @T-Gro
T-Gro c060bfd
Apply suggestion from @T-Gro
T-Gro 4eab007
Apply suggestion from @T-Gro
T-Gro 1cc0fbd
Apply suggestion from @T-Gro
T-Gro 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
113 changes: 113 additions & 0 deletions
113
tests/FSharp.Compiler.ComponentTests/CompilerCompatibilityTests.fs
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,113 @@ | ||
| module FSharp.Compiler.ComponentTests.CompilerCompatibilityTests | ||
|
|
||
| open System | ||
| open System.IO | ||
| open Xunit | ||
| open FSharp.Test | ||
| open FSharp.Test.Assert | ||
| open TestFramework | ||
|
|
||
| type CompilerCompatibilityTests() = | ||
|
|
||
| let projectsPath = Path.GetFullPath(Path.Combine(__SOURCE_DIRECTORY__, "../projects/CompilerCompat")) | ||
| let libProjectPath = Path.Combine(projectsPath, "CompilerCompatLib") | ||
| let appProjectPath = Path.Combine(projectsPath, "CompilerCompatApp") | ||
|
|
||
| let runDotnetBuild projectPath useLocalCompiler = | ||
| let args = | ||
| if useLocalCompiler then | ||
| "build -c Release -p:LoadLocalFSharpBuild=True" | ||
T-Gro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| else | ||
| "build -c Release" | ||
|
|
||
| let (exitCode, output, error) = Commands.executeProcess "dotnet" args projectPath | ||
|
|
||
| if exitCode <> 0 then | ||
| let outputStr = String.concat "\n" output | ||
| let errorStr = String.concat "\n" error | ||
| failwith $"Build failed with exit code {exitCode}. Output: {outputStr}. Error: {errorStr}" | ||
|
|
||
| String.concat "\n" output | ||
|
|
||
| let runApp appBinaryPath = | ||
| let (exitCode, output, error) = Commands.executeProcess "dotnet" appBinaryPath (Path.GetDirectoryName(appBinaryPath)) | ||
| (exitCode, String.concat "\n" output, String.concat "\n" error) | ||
|
|
||
| let cleanBinObjDirectories projectPath = | ||
| let binPath = Path.Combine(projectPath, "bin") | ||
| let objPath = Path.Combine(projectPath, "obj") | ||
|
|
||
| if Directory.Exists(binPath) then | ||
| Directory.Delete(binPath, true) | ||
| if Directory.Exists(objPath) then | ||
| Directory.Delete(objPath, true) | ||
|
|
||
| let getAppDllPath () = | ||
| // The app is built to artifacts directory due to Directory.Build.props | ||
| Path.Combine(__SOURCE_DIRECTORY__, "..", "..", "artifacts", "bin", "CompilerCompatApp", "Release", "net8.0", "CompilerCompatApp.dll") | ||
|
|
||
| [<Fact>] | ||
| member _.``Baseline scenario - Both library and app built with local compiler``() = | ||
T-Gro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Clean previous builds | ||
| cleanBinObjDirectories libProjectPath | ||
| cleanBinObjDirectories appProjectPath | ||
|
|
||
| // Build library with local compiler | ||
| let libOutput = runDotnetBuild libProjectPath true | ||
| Assert.Contains("CompilerCompatLib -> ", libOutput) | ||
|
|
||
| // Build app with local compiler | ||
| let appOutput = runDotnetBuild appProjectPath true | ||
| Assert.Contains("CompilerCompatApp -> ", appOutput) | ||
|
|
||
| // Run app and verify it works | ||
| let appDllPath = getAppDllPath() | ||
| Assert.True(File.Exists(appDllPath), $"App DLL not found at {appDllPath}") | ||
|
|
||
| let (exitCode, output, _error) = runApp appDllPath | ||
| Assert.Equal(0, exitCode) | ||
| Assert.Contains("✓ All compiler compatibility tests passed", output) | ||
|
|
||
| [<Fact>] | ||
| member _.``Forward compatibility - Library built with SDK compiler, app with local compiler``() = | ||
| // Clean previous builds | ||
| cleanBinObjDirectories libProjectPath | ||
| cleanBinObjDirectories appProjectPath | ||
|
|
||
| // Build library with SDK compiler | ||
| let libOutput = runDotnetBuild libProjectPath false | ||
| Assert.Contains("CompilerCompatLib -> ", libOutput) | ||
|
|
||
| // Build app with local compiler (should use the library built with SDK compiler) | ||
| let appOutput = runDotnetBuild appProjectPath true | ||
| Assert.Contains("CompilerCompatApp -> ", appOutput) | ||
|
|
||
| // Run app and verify it works | ||
| let appDllPath = getAppDllPath() | ||
| Assert.True(File.Exists(appDllPath), $"App DLL not found at {appDllPath}") | ||
|
|
||
| let (exitCode, output, _error) = runApp appDllPath | ||
| Assert.Equal(0, exitCode) | ||
| Assert.Contains("✓ All compiler compatibility tests passed", output) | ||
|
|
||
| [<Fact>] | ||
| member _.``Backward compatibility - Library built with local compiler, app with SDK compiler``() = | ||
| // Clean previous builds | ||
| cleanBinObjDirectories libProjectPath | ||
| cleanBinObjDirectories appProjectPath | ||
|
|
||
| // Build library with local compiler | ||
| let libOutput = runDotnetBuild libProjectPath true | ||
| Assert.Contains("CompilerCompatLib -> ", libOutput) | ||
|
|
||
| // Build app with SDK compiler (should use the library built with local compiler) | ||
| let appOutput = runDotnetBuild appProjectPath false | ||
| Assert.Contains("CompilerCompatApp -> ", appOutput) | ||
|
|
||
| // Run app and verify it works | ||
| let appDllPath = getAppDllPath() | ||
| Assert.True(File.Exists(appDllPath), $"App DLL not found at {appDllPath}") | ||
|
|
||
| let (exitCode, output, _error) = runApp appDllPath | ||
| Assert.Equal(0, exitCode) | ||
| Assert.Contains("✓ All compiler compatibility tests passed", output) | ||
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
16 changes: 16 additions & 0 deletions
16
tests/projects/CompilerCompat/CompilerCompatApp/CompilerCompatApp.fsproj
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,16 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="Program.fs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="../CompilerCompatLib/CompilerCompatLib.fsproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
37 changes: 37 additions & 0 deletions
37
tests/projects/CompilerCompat/CompilerCompatApp/Program.fs
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,37 @@ | ||
| open CompilerCompatLib | ||
| open System | ||
|
|
||
| [<EntryPoint>] | ||
| let main _argv = | ||
| try | ||
| // Test basic anonymous record functionality | ||
| let record = Library.getAnonymousRecord() | ||
| printfn "Basic record: X=%d, Y=%s" record.X record.Y | ||
|
|
||
| // Verify expected values | ||
| if record.X <> 42 || record.Y <> "hello" then | ||
| printfn "ERROR: Basic record values don't match expected" | ||
| 1 | ||
| else | ||
| printfn "✓ Basic record test passed" | ||
|
|
||
| // Test complex anonymous record functionality | ||
| let complex = Library.getComplexAnonymousRecord() | ||
| printfn "Complex record: Simple.A=%d, Simple.B=%s" complex.Simple.A complex.Simple.B | ||
| printfn "Complex record: List has %d items" complex.List.Length | ||
| printfn "Complex record: Tuple=(%d, Value=%f)" (fst complex.Tuple) (snd complex.Tuple).Value | ||
|
|
||
| // Test function that takes anonymous record | ||
| let processed = Library.processAnonymousRecord({| X = 123; Y = "test" |}) | ||
| printfn "Processed result: %s" processed | ||
|
|
||
| if processed = "Processed: X=123, Y=test" then | ||
| printfn "✓ All compiler compatibility tests passed" | ||
| 0 | ||
| else | ||
| printfn "ERROR: Processed result doesn't match expected" | ||
| 1 | ||
|
|
||
| with ex -> | ||
| printfn "ERROR: Exception occurred: %s" ex.Message | ||
| 1 |
2 changes: 2 additions & 0 deletions
2
tests/projects/CompilerCompat/CompilerCompatApp/commandline.txt
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,2 @@ | ||
| cd /home/runner/work/fsharp/fsharp/tests/projects/CompilerCompat/CompilerCompatApp | ||
| dotnet build -c Release -p:LoadLocalFSharpBuild=True /bl | ||
T-Gro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
12 changes: 12 additions & 0 deletions
12
tests/projects/CompilerCompat/CompilerCompatLib/CompilerCompatLib.fsproj
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,12 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="Library.fs" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
17 changes: 17 additions & 0 deletions
17
tests/projects/CompilerCompat/CompilerCompatLib/Library.fs
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,17 @@ | ||
| namespace CompilerCompatLib | ||
|
|
||
| module Library = | ||
| /// Returns an anonymous record to test compiler compatibility | ||
| let getAnonymousRecord () = {| X = 42; Y = "hello" |} | ||
|
|
||
| /// Returns a more complex anonymous record with nested structure | ||
| let getComplexAnonymousRecord () = | ||
| {| | ||
| Simple = {| A = 1; B = "test" |}; | ||
| List = [ {| Id = 1; Name = "first" |}; {| Id = 2; Name = "second" |} ]; | ||
| Tuple = (42, {| Value = 3.14; Label = "pi" |}) | ||
| |} | ||
|
|
||
| /// Function that takes an anonymous record as parameter | ||
| let processAnonymousRecord (record: {| X: int; Y: string |}) = | ||
| sprintf "Processed: X=%d, Y=%s" record.X record.Y |
2 changes: 2 additions & 0 deletions
2
tests/projects/CompilerCompat/CompilerCompatLib/commandline.txt
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,2 @@ | ||
| cd /home/runner/work/fsharp/fsharp/tests/projects/CompilerCompat/CompilerCompatLib | ||
T-Gro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| dotnet build -c Release -p:LoadLocalFSharpBuild=True /bl | ||
Oops, something went wrong.
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.