Fix ForceDirectedLayout.Tests CI crash: exclude native C ABI shim from code coverage#196
Merged
Merged
Conversation
ForceDirectedLayout.Tests crashed the Microsoft dynamic code-coverage collector during teardown (System.Exception: Pipe was disconnected, process exit 0xE0434352, test-platform exit 7) on the .NET 10 CI runner. It is the only test assembly referencing code with [UnmanagedCallersOnly] native entry points (NativeExports); the coverage engine takes that path and crashes per the .NET 10 dynamic-native-instrumentation behavior change. Mark NativeExports with [ExcludeFromCodeCoverage] - those boundary methods are reachable only via native function pointers and cannot be exercised by managed tests anyway, so excluding them keeps the coverage instrumenter away from them while preserving coverage for the rest of the engine. (Disabling the coverage extension for the project is not viable: CI passes --coverage to every test app, so a project without the extension fails with an unknown-option error.) Also suppress two new SonarAnalyzer warnings with justifications: S1244 on Vec2D ==/Equals (exact equality is intentional for a blittable value type; a tolerance would break the Equals/GetHashCode contract) and S6640 on the unsafe NativeExports class (unsafe is required for C ABI pointer marshalling).
|
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
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.




Problem
CI run 26700545963 failed. All 498 tests pass, but the test host for
ForceDirectedLayout.Testscrashes during code-coverage teardown:→ process exit
0xE0434352, test-platform exit 7, job exit 1.It is the only test assembly referencing code with
[UnmanagedCallersOnly]native entry points (NativeExports). On the .NET 10 runner the coverage engine takes that assembly down the dynamic native-instrumentation path, which crashes — consistent with the .NET 10 dynamic-native-instrumentation breaking change and microsoft/codecoverage#202.Fix
Mark
NativeExportswith[ExcludeFromCodeCoverage]. Those boundary methods are reachable only via native function pointers and cannot be exercised by managed tests anyway, so excluding them keeps the coverage instrumenter away from them while preserving coverage for the rest of the engine.Rejected alternative: setting
EnableMicrosoftTestingExtensionsCodeCoverage=falseon the project breaks the run a different way — CI passes--coverageto every test app, so a project without the extension fails with an unknown-option error (verified: exit 5, only 478/498 tests run).Also suppresses two new SonarAnalyzer warnings with justifications:
Vec2D==/Equals— exact equality is intentional for a blittable value type; a tolerance would break theEquals/GetHashCodecontract.unsafe NativeExportsclass —unsafeis required for C ABI pointer marshalling.Verification
dotnet test --coverage --coverage-output coverage.xml --report-trx …) → 498 pass, exit 0, coverage + TRX still produced.🤖 Generated with Claude Code