Add trimming test for Marshal.StructureToPtr with ByVal DateTime arra…#129538
Closed
MichalStrehovsky wants to merge 1 commit into
Closed
Add trimming test for Marshal.StructureToPtr with ByVal DateTime arra…#129538MichalStrehovsky wants to merge 1 commit into
MichalStrehovsky wants to merge 1 commit into
Conversation
…y (issue dotnet#127952) Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/d5cc9194-87ba-4a47-aab5-a1c8f5c11865 Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @dotnet/interop-contrib |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new trimming test console app intended to cover Marshal.StructureToPtr/Marshal.DestroyStructure behavior for a struct containing a ByValArray of DateTime, and wires it into the System.Runtime.InteropServices trimming test project.
Changes:
- Register a new trimming test source file in
System.Runtime.InteropServices.TrimmingTests.proj. - Add a new console-app style trimming test
MarshalStructureToPtrByValDateArray.csthat exercisesStructureToPtrand cleanup.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/System.Runtime.InteropServices.TrimmingTests.proj | Adds the new trimming test app to the trimming test item list. |
| src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/MarshalStructureToPtrByValDateArray.cs | New trimming test app that marshals a struct with a fixed-size DateTime array field. |
Comment on lines
+30
to
+33
| <!-- Regression test for https://github.com/dotnet/runtime/issues/127952 --> | ||
| <!-- Marshal.StructureToPtr on a struct containing a ByValArray of DateTime values --> | ||
| <!-- is expected to fail on tvos-arm64 until the underlying issue is fixed. --> | ||
| <TestConsoleAppSourceFiles Include="MarshalStructureToPtrByValDateArray.cs" /> |
Comment on lines
+24
to
+35
| int size = Marshal.SizeOf(structure); | ||
| IntPtr memory = Marshal.AllocHGlobal(size); | ||
| try | ||
| { | ||
| Marshal.StructureToPtr(structure, memory, false); | ||
| Marshal.StructureToPtr(structure, memory, true); | ||
| } | ||
| finally | ||
| { | ||
| Marshal.DestroyStructure(memory, structure.GetType()); | ||
| Marshal.FreeHGlobal(memory); | ||
| } |
This was referenced Jun 18, 2026
Open
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.
…y (issue #127952)
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/d5cc9194-87ba-4a47-aab5-a1c8f5c11865