Skip to content

Compile UpdateOptions_ServerCertificateContextProvided test on desktop only - #132277

Merged
rzikm merged 1 commit into
mainfrom
rzikm-disable-net-security-tvos-test
Aug 14, 2026
Merged

Compile UpdateOptions_ServerCertificateContextProvided test on desktop only#132277
rzikm merged 1 commit into
mainfrom
rzikm-disable-net-security-tvos-test

Conversation

@rzikm

@rzikm rzikm commented Aug 13, 2026

Copy link
Copy Markdown
Member

Alternative to #131929 and #132125 for #131922.

System.Net.Security.Unit.Tests crashes during runtime init on Apple-mobile CoreCLR (e.g. tvOS), before test discovery runs. The single test UpdateOptions_ServerCertificateContextProvided_DoesNotDisposeCallerContext exercises SslStreamCertificateContext.Create with intermediate certificates, which pulls in a generic Dictionary instantiation whose IL body is stripped from the Apple-mobile CoreCLR ReadyToRun composite image, crashing the whole app at startup. Because the app crashes before test discovery, per-test [Fact]/attribute-based skipping can't help.

Approach

Rather than disabling the entire test project on non-desktop platforms (as the alternatives do), this keeps the rest of the suite running on mobile and only excludes the one problematic test from the mobile build:

  • Make SslAuthenticationOptionsTests a partial class.
  • Move UpdateOptions_ServerCertificateContextProvided_DoesNotDisposeCallerContext verbatim into a new SslAuthenticationOptionsTests.Desktop.cs.
  • Register that file with an MSBuild Compile condition limited to desktop platforms (windows/unix/osx). An MSBuild condition is used rather than a #if because the TARGET_* C# defines aren't reliably present in this test project.

TargetFrameworks and the existing IgnoreForCI line are untouched, so the app still builds and all other unit tests still run on mobile.

Comparison to alternatives

This PR is the most surgical option: it drops only the one test on mobile and preserves the remaining coverage.

Validation

Test-only change; no product code touched. Not built locally (test project requires the full libraries baseline build in this environment); the change is a mechanical move plus a build-condition addition. CI will exercise the desktop and mobile legs.

Note

This PR was generated with the assistance of GitHub Copilot.

…p only

The UpdateOptions_ServerCertificateContextProvided_DoesNotDisposeCallerContext test exercises SslStreamCertificateContext.Create with intermediate certificates, which pulls in a generic Dictionary instantiation whose IL body is stripped from the Apple-mobile CoreCLR ReadyToRun composite image, crashing System.Net.Security.Unit.Tests at startup before test discovery.

Move the single failing test into a new SslAuthenticationOptionsTests.Desktop.cs partial class file and register it via an MSBuild Compile condition limited to desktop platforms (windows/unix/osx). The rest of the test suite keeps running on mobile.

Fixes #131922

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 13, 2026 14:21
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the System.Net.Security.Unit.Tests unit test project to exclude a single SslAuthenticationOptionsTests test from non-desktop target frameworks by splitting it into a desktop-only source file and compiling that file conditionally.

Changes:

  • Made SslAuthenticationOptionsTests a partial class to allow splitting tests across platform-targeted source files.
  • Moved UpdateOptions_ServerCertificateContextProvided_DoesNotDisposeCallerContext into a new SslAuthenticationOptionsTests.Desktop.cs.
  • Added an MSBuild Compile include conditioned on TargetPlatformIdentifier (windows/unix/osx) so only desktop builds compile the moved test.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/libraries/System.Net.Security/tests/UnitTests/System.Net.Security.Unit.Tests.csproj Conditionally compiles the new desktop-only test file for windows/unix/osx TFMs.
src/libraries/System.Net.Security/tests/UnitTests/SslAuthenticationOptionsTests.Desktop.cs Introduces the desktop-only partial class file containing the moved [Fact] test.
src/libraries/System.Net.Security/tests/UnitTests/SslAuthenticationOptionsTests.cs Converts the test class to partial and removes the moved test from the shared file.

@rzikm
rzikm requested review from a team and BrzVlad August 13, 2026 14:27
@rzikm rzikm added the os-tvos Apple tvOS label Aug 13, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'os-tvos': @vitek-karas, @kotlarmilos, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants