[dotnet] [test] Update tests to target .NET 10#17353
Conversation
Review Summary by Qodo
WalkthroughsDescription• Update .NET test projects from net8.0 to net10.0 target framework • Improve Bazel glob patterns to exclude build output directories • Update conditional compilation symbols from NET8_0 to NET10_0 File Changes1. dotnet/test/webdriver/Infrastructure/IgnoreTargetAttribute.cs
|
Code Review by Qodo
1.
|
|
Thank you, @nvborisenko for this code suggestion. The support packages contain example code that many users find helpful, but they do not necessarily represent After reviewing the change, unless it is a critical fix or a feature that is needed for Selenium We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks. |
There was a problem hiding this comment.
Pull request overview
This PR updates the .NET test projects and Bazel test targets to run against the net10.0 target framework, and tightens Bazel globbing to avoid picking up build output directories as test sources.
Changes:
- Bump .NET test project TFMs from
net8.0tonet10.0. - Update Bazel
target_frameworksfor .NET test rules tonet10.0. - Exclude
bin/**andobj/**from Bazelglob()test source collection.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/test/webdriver/TakesScreenshotTests.cs | Updates conditional compilation symbols to NET10_0 for screenshot color/pixel helpers. |
| dotnet/test/webdriver/Selenium.WebDriver.Tests.csproj | Switches WebDriver test project target framework to net10.0. |
| dotnet/test/webdriver/Infrastructure/IgnoreTargetAttribute.cs | Updates current TFM detection to NET10_0 / net10. |
| dotnet/test/webdriver/BUILD.bazel | Moves test suite to net10.0 and excludes bin//obj/ from sources. |
| dotnet/test/testing.webserver/Selenium.Testing.WebServer.csproj | Switches web server test project target framework to net10.0. |
| dotnet/test/testing.webserver/BUILD.bazel | Moves library to net10.0 and excludes bin//obj/ from sources. |
| dotnet/test/support/Selenium.WebDriver.Support.Tests.csproj | Switches support tests target framework to net10.0. |
| dotnet/test/support/BUILD.bazel | Moves test suite to net10.0 and excludes bin//obj/ from sources. |
| dotnet/test/remote/Selenium.WebDriver.Remote.Tests.csproj | Switches remote tests target framework to net10.0. |
| dotnet/test/remote/BUILD.bazel | Moves test suite to net10.0 and excludes bin//obj/ from sources. |
Comments suppressed due to low confidence (2)
dotnet/test/webdriver/TakesScreenshotTests.cs:373
ScanActualColorsis now entirely excluded when compiling for net10 (#if !NET10_0). Since the test projects now target net10.0, this method will always return an empty set, and the screenshot color comparison assertions in this file become invalid (likely failing or becoming meaningless). Either update the framework guards so these tests are ignored on net10 as well (similar to existing NET6_0/NET8_0 skips), or provide a net10-compatible implementation for extracting pixel colors (e.g., via a supported cross-platform image API).
#if !NET10_0
try
{
Image image = Image.FromStream(new MemoryStream(screenshot.AsByteArray));
Bitmap bitmap = new Bitmap(image);
int height = bitmap.Height;
int width = bitmap.Width;
Assert.That(width, Is.GreaterThan(0));
Assert.That(height, Is.GreaterThan(0));
for (int i = 0; i < width; i = i + stepX)
{
for (int j = 0; j < height; j = j + stepY)
{
string hex = FormatColorToHex(bitmap.GetPixel(i, j).ToArgb());
colors.Add(hex);
}
}
}
catch (Exception e)
{
Assert.Fail("Unable to get actual colors from screenshot: " + e.Message);
}
Assert.That(colors.Count, Is.GreaterThan(0));
#endif
return colors;
dotnet/test/webdriver/TakesScreenshotTests.cs:386
GetPixelColoris also excluded for net10 (#if !NET10_0), so on net10 it will always returnColor.Black. If any tests rely on this helper to validate screenshot pixels, they will produce incorrect results under the new target framework. Consider skipping the relevant tests on net10 (as is done for earlier TFMs) or reworking the implementation to use a net10-compatible image decoding approach.
Color pixelColor = Color.Black;
#if !NET10_0
Image image = Image.FromStream(new MemoryStream(screenshot.AsByteArray));
Bitmap bitmap = new Bitmap(image);
pixelColor = bitmap.GetPixel(1, 1);
#endif
return pixelColor;
}
|
Edit: My bad - not updated everything. |
There was a problem hiding this comment.
Pull request overview
This PR updates the .NET test suite build configuration to run on .NET 10, aligning both MSBuild test projects and Bazel targets with the new target framework while preventing build output directories from being treated as sources.
Changes:
- Retarget .NET test projects (
.csproj) fromnet8.0tonet10.0. - Update Bazel
target_frameworksfor test suites/libraries tonet10.0and excludebin/**+obj/**fromglob()sources. - Adjust conditional compilation/platform identification in tests to match the new TFM (
NET10_0,"net10").
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/test/webdriver/TakesScreenshotTests.cs | Updates conditional compilation symbols to NET10_0 for framework-specific skips and code paths. |
| dotnet/test/webdriver/Selenium.WebDriver.Tests.csproj | Retargets the main WebDriver test project to net10.0. |
| dotnet/test/webdriver/Infrastructure/IgnoreTargetAttribute.cs | Updates TFM-to-string mapping to report "net10" under NET10_0. |
| dotnet/test/webdriver/BUILD.bazel | Retargets Bazel test suite to net10.0 and excludes bin/ + obj/ from source globs. |
| dotnet/test/testing.webserver/Selenium.Testing.WebServer.csproj | Retargets the test web server project to net10.0. |
| dotnet/test/testing.webserver/BUILD.bazel | Retargets Bazel library to net10.0 and excludes bin/ + obj/ from source globs. |
| dotnet/test/support/Selenium.WebDriver.Support.Tests.csproj | Retargets the support test project to net10.0. |
| dotnet/test/support/BUILD.bazel | Retargets Bazel support test suite to net10.0 and excludes bin/ + obj/ from source globs. |
| dotnet/test/remote/Selenium.WebDriver.Remote.Tests.csproj | Retargets the remote test project to net10.0. |
| dotnet/test/remote/BUILD.bazel | Retargets Bazel remote test suite to net10.0 and excludes bin/ + obj/ from source globs. |
.NET 10 for tests projects.
💥 What does this PR do?
This pull request updates the .NET test projects and Bazel build definitions to target .NET 10.0 instead of .NET 8.0, and improves the globbing patterns to exclude build output directories from test sources. Additionally, conditional compilation symbols and platform checks are updated to match the new target framework. These changes ensure the test suite is aligned with the latest .NET version and avoids including unnecessary files in test builds.
Target framework updates:
.csproj) are updated to usenet10.0as the target framework instead ofnet8.0. [1] [2] [3] [4]BUILD.bazelfiles) are updated to usenet10.0in thetarget_frameworksattribute. [1] [2] [3] [4]Build system improvements:
globpatterns in Bazel build files for test sources now explicitly excludebin/**andobj/**directories to prevent build artifacts from being included as source files. [1] [2] [3] [4]Conditional compilation and platform checks:
NET8_0toNET10_0to match the new target framework. This affects platform checks inIgnoreTargetAttribute.csand conditional logic inTakesScreenshotTests.cs. [1] [2] [3]🔧 Implementation Notes
Also added
bin/objas exclusion for bazel.🔄 Types of changes