-
Notifications
You must be signed in to change notification settings - Fork 615
Add cross-platform netstandard2.0 test coverage #1235
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
| @@ -0,0 +1,83 @@ | |||
| <Project Sdk="Microsoft.NET.Sdk"> | |||
|
|
|||
| <PropertyGroup> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Please avoid using a separate test project. Ideally this should use the exact same test project, but non-Windows environments should be configured automatically accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to use the existing test project with conditional SetTargetFramework on the ModelContextProtocol.Core project reference. On non-Windows platforms, net8.0 tests now use the netstandard2.0 build automatically. See commit 753cc88.
…f separate project On non-Windows platforms, the net8.0 test target now forces netstandard2.0 build of ModelContextProtocol.Core via conditional SetTargetFramework. This provides cross-platform netstandard2.0 test coverage without requiring a separate test project. Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
| <ProjectReference Include="..\..\src\ModelContextProtocol.Core\ModelContextProtocol.Core.csproj" /> | ||
| <ProjectReference Include="..\..\src\ModelContextProtocol.Core\ModelContextProtocol.Core.csproj"> | ||
| <!-- On non-Windows platforms, force net8.0 tests to use netstandard2.0 build for cross-platform netstandard2.0 coverage --> | ||
| <SetTargetFramework Condition="'$(TargetFramework)' == 'net8.0' AND !$([MSBuild]::IsOSPlatform('Windows'))">TargetFramework=netstandard2.0</SetTargetFramework> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot you probably also need to remove DefaultTestTargetFrameworks which is used by the earlier attempt to fix this same issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the platform-specific conditional logic from DefaultTestTargetFrameworks and made SetTargetFramework apply to all platforms. All platforms now test the same target frameworks (net10.0, net9.0, net8.0) with net8.0 using netstandard2.0 builds everywhere. See commit db11c07.
…getFramework to all platforms - Removed conditional net472 addition to DefaultTestTargetFrameworks on Windows - Changed SetTargetFramework to apply to all platforms (not just non-Windows) - Now all platforms test net10.0, net9.0, and net8.0, with net8.0 using netstandard2.0 build - This provides consistent netstandard2.0 test coverage across all platforms Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
| <!-- Shared target frameworks for test projects and test support projects. net472 is only included on Windows. --> | ||
| <!-- Shared target frameworks for test projects and test support projects. --> | ||
| <DefaultTestTargetFrameworks>net10.0;net9.0;net8.0</DefaultTestTargetFrameworks> | ||
| <DefaultTestTargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(DefaultTestTargetFrameworks);net472</DefaultTestTargetFrameworks> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not desirable.
There are two aspects to the netstandard2.0 build we want to test:
- The netstandard2.0 asset of these libraries when running on .NET Framework on Windows.
- The netstandard2.0 asset of these libraries, regardless of what underlying .NET runtime is being used.
The main branch is successfully validating (1). It's not validating (2), in particular on Linux / macOS.
On Windows, we want the TFMs net10.0, net9.0, net8.0, and net472.
To handle (2) on non-Windows, we should have a separate test .csproj that's ideally only run on non-Windows, with a net8.0 TFM that uses SetTargetFramework to set the target framework of the MCP.Core library to netstandard2.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot please revert the last commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the last commit in 259aee5. The configuration now maintains net472 on Windows for .NET Framework testing, while using conditional SetTargetFramework on non-Windows for netstandard2.0 testing on modern .NET runtime.
This reverts the changes from commit db11c07. The approach of removing net472 on Windows was incorrect. We need to maintain both: 1. net472 tests on Windows (for netstandard2.0 testing on .NET Framework) 2. Conditional SetTargetFramework on non-Windows (for netstandard2.0 testing on modern .NET) Restoring the configuration where: - Windows tests: net10.0, net9.0, net8.0, net472 - Non-Windows tests: net10.0, net9.0, net8.0 (with net8.0 using netstandard2.0 build) Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
The net472 test target only runs on Windows, leaving netstandard2.0 builds untested on Linux/macOS.
Changes
ModelContextProtocol.Testsnow uses conditionalSetTargetFrameworkto automatically test netstandard2.0 on non-Windows platformsImplementation
Uses MSBuild's conditional
SetTargetFrameworkproperty on the project reference:Configuration
Windows platforms:
net10.0;net9.0;net8.0;net472Non-Windows platforms:
net10.0;net9.0;net8.0SetTargetFrameworkThis validates both aspects of netstandard2.0 builds:
The solution provides netstandard2.0 test coverage on non-Windows platforms without requiring .NET Framework, mono, or a separate test project, while maintaining existing Windows test coverage.
Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.