Skip to content

Commit eea465d

Browse files
Add README for netstandard2.0 test project
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
1 parent 38dcf26 commit eea465d

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

  • tests/ModelContextProtocol.Netstandard2_0.Tests
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# ModelContextProtocol.Netstandard2_0.Tests
2+
3+
This test project provides cross-platform testing of the `netstandard2.0` build of `ModelContextProtocol.Core`.
4+
5+
## Purpose
6+
7+
The main test project (`ModelContextProtocol.Tests`) targets multiple frameworks including `net472`, which only runs on Windows. This creates a gap for developers on non-Windows platforms who want to test the `netstandard2.0` build.
8+
9+
This project solves that by:
10+
1. Targeting `net8.0` (stable, cross-platform)
11+
2. Forcing `ModelContextProtocol.Core` to use its `netstandard2.0` build via `SetTargetFramework`
12+
3. Including all test source files from the main test project
13+
14+
## Key Features
15+
16+
- **Cross-platform**: Runs on Windows, Linux, and macOS using the modern .NET runtime
17+
- **netstandard2.0 testing**: Verifies the netstandard2.0 build without requiring .NET Framework or mono
18+
- **Shared tests**: Uses the same test source files as `ModelContextProtocol.Tests` to ensure consistency
19+
20+
## How It Works
21+
22+
The project uses the MSBuild `SetTargetFramework` property on the project reference to force the referenced project to build for a specific target framework:
23+
24+
```xml
25+
<ProjectReference Include="..\..\src\ModelContextProtocol.Core\ModelContextProtocol.Core.csproj">
26+
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework>
27+
</ProjectReference>
28+
```
29+
30+
This allows the test project (targeting `net8.0`) to reference and test the `netstandard2.0` build of `ModelContextProtocol.Core`.
31+
32+
## Running Tests
33+
34+
```bash
35+
# Run all tests
36+
dotnet test tests/ModelContextProtocol.Netstandard2_0.Tests
37+
38+
# Run with filter
39+
dotnet test tests/ModelContextProtocol.Netstandard2_0.Tests --filter '(Execution!=Manual)'
40+
```
41+
42+
## Reference
43+
44+
This pattern is based on the approach used by [googleapis/dotnet-genai](https://github.com/googleapis/dotnet-genai/blob/f0d9a3eb970e91293b806dac49853b68e4ddcdca/Google.GenAI.Tests/Netstandard2_0Tests/Google.GenAI.Netstandard2_0.Tests.csproj).

0 commit comments

Comments
 (0)