Skip to content

Add trimming test for Marshal.StructureToPtr with ByVal DateTime arra…#129538

Closed
MichalStrehovsky wants to merge 1 commit into
dotnet:mainfrom
MichalStrehovsky:verifyfix
Closed

Add trimming test for Marshal.StructureToPtr with ByVal DateTime arra…#129538
MichalStrehovsky wants to merge 1 commit into
dotnet:mainfrom
MichalStrehovsky:verifyfix

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

…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>
Copilot AI review requested due to automatic review settings June 17, 2026 20:43
@MichalStrehovsky MichalStrehovsky added NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) NO-REVIEW Experimental/testing PR, do NOT review it labels Jun 17, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

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

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.cs that exercises StructureToPtr and 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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Runtime.InteropServices NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) NO-REVIEW Experimental/testing PR, do NOT review it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants