-
Notifications
You must be signed in to change notification settings - Fork 839
Warn when FSharp.Core major version exceeds SDK compiler version #19183
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
Open
Copilot
wants to merge
6
commits into
main
Choose a base branch
from
copilot/warn-high-fsharp-core-version
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+129
−2
Conversation
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
Co-authored-by: T-Gro <[email protected]>
Co-authored-by: T-Gro <[email protected]>
Co-authored-by: T-Gro <[email protected]>
Co-authored-by: T-Gro <[email protected]>
Co-authored-by: T-Gro <[email protected]>
Copilot
AI
changed the title
[WIP] Add warning for FSharp.Core version validation
Warn when FSharp.Core major version exceeds SDK compiler version
Dec 30, 2025
Member
|
This honestly feels like a very ad hoc fix. |
T-Gro
reviewed
Dec 31, 2025
Member
|
It is not a fix - updating the SDK is the fix. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Emits
FSSDK0001warning when a project references (directly or transitively) an FSharp.Core package with a higher major version than the SDK's compiler supports.Implementation
Props file (
Microsoft.FSharp.Core.NetSdk.props):_FSCorePackageVersionSet→FSCorePackageVersionSet(now public for test hooks)FSharpCoreMaximumMajorVersionproperty computed from SDK'sFSCorePackageVersion.Split('-')[0]before version parsingTargets file (
Microsoft.FSharp.NetSdk.targets):_CheckForUnsupportedFSharpCoreVersiontarget (runs afterResolvePackageAssets)"The referenced FSharp.Core X.Y.Z has a higher major version (X) than this SDK supports (N)..."<ValidateFSharpCoreVersion>false</ValidateFSharpCoreVersion>Test Coverage
Four MSBuild test projects validate:
Example
Build output with SDK 10.x:
Original prompt
FSharp.Core Version Validation
Goal
Warn (
FSSDK0001) when a project references FSharp.Core with a higher major version than the SDK's compiler supports (directly or via transitive dependency).Scenarios
Implementation
1. Modify Props File
File:
src/FSharp.Build/Microsoft.FSharp.Core.NetSdk.propsCurrent content (lines 23-27):
Replace with:
Changes:
_FSCorePackageVersionSet→FSCorePackageVersionSet(public, for testability)FSharpCoreMaximumMajorVersioncomputation.Split('-')[0]strips prerelease suffix (required becauseSystem.Version.Parsedoesn't handle semver)2. Add Validation Target
File:
src/FSharp.Build/Microsoft.FSharp.NetSdk.targetsAdd before closing
</Project>tag (after line 221):Key points:
AfterTargets="ResolvePackageAssets"— runs after NuGet resolves all packages (including transitives)%(ReferencePath.NuGetPackageVersion)— gets the resolved package version<ValidateFSharpCoreVersion>false</ValidateFSharpCoreVersion>Testing
Test Location
Directory:
tests/fsharp/SDKTests/tests/Test runner:
tests/fsharp/SDKTests/AllSdkTargetsTests.projExisting patterns to follow:
tests/fsharp/SDKTests/tests/PackageTest.propstests/fsharp/SDKTests/tests/PackageTest.targetstests/fsharp/SDKTests/tests/SetImplicitReferenceTest.projNew Test Files to Create
tests/fsharp/SDKTests/tests/FSharpCoreVersionTest.props