-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add (commented) test case that crashes LibraryImportGenerator #117447
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
Conversation
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.
Pull Request Overview
This PR introduces a new test snippet that triggers a generator crash when a collection marshaller is mis-shaped, but leaves the test commented out until the issue is resolved.
- Added
ImproperCollectionWithMarshalUsingOnElements
snippet inCodeSnippets.cs
. - Added commented-out test entry in
CompileFails.cs
for the new snippet.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
CompileFails.cs | Commented new test case for improper collection marshalling that currently crashes the generator |
CodeSnippets.cs | Defined ImproperCollectionWithMarshalUsingOnElements snippet to reproduce the crash |
Comments suppressed due to low confidence (3)
src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CompileFails.cs:60
- [nitpick] Add a TODO with a reference to the GitHub issue tracking this crash so it’s clear when to re-enable the test (e.g.,
// TODO: re-enable once dotnet/runtime#12345 is fixed
).
// Bug: crashes
src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CompileFails.cs:61
- The test for the improper collection scenario is currently disabled, leaving this crash case unverified; consider adding a placeholder assertion or a skipping mechanism that documents expected behavior until the bug is fixed.
// yield return new[] { ID(), CodeSnippets.ImproperCollectionWithMarshalUsingOnElements };
src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CompileFails.cs:61
- The commented test uses
new[]
without specifying the expectedDiagnosticResult
array or matching theobject[]
signature used elsewhere. Usenew object[] { ID(), CodeSnippets.ImproperCollectionWithMarshalUsingOnElements, Array.Empty<DiagnosticResult>() }
to match the helper method signature.
// yield return new[] { ID(), CodeSnippets.ImproperCollectionWithMarshalUsingOnElements };
Tagging subscribers to this area: @dotnet/interop-contrib |
...raries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CompileFails.cs
Outdated
Show resolved
Hide resolved
…rtGenerator.UnitTests/CompileFails.cs Co-authored-by: Aaron Robinson <[email protected]>
Ran into this while testing some some sample code. When a collection marshaller does not conform to the correct shape and an element marshaller is specified, we crash the generator with a NullRef.
Filed #117448 to track this.