Skip to content

Conversation

MichalStrehovsky
Copy link
Member

Fixes #114355.

Special case ComWrappers.ComInterfaceEntry and types that only consist of these fields to achieve this.

Cc @dotnet/ilc-contrib @Sergio0694

Fixes dotnet#114355.

Special case `ComWrappers.ComInterfaceEntry` and types that only consist of these fields to achieve this.
@Copilot Copilot AI review requested due to automatic review settings April 9, 2025 21:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

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

Comments suppressed due to low confidence (3)

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs:2705

  • In the Clone method of VTableLikeStructValue (line 2705), passing null for fieldThatOwnsMemory may cause loss of necessary context. Consider preserving the existing fieldThatOwnsMemory if applicable.
return new VTableLikeStructValue(_type, (MethodDesc[])_methods.Clone(), fieldThatOwnsMemory: null);

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs:2727

  • The MemoryOwner property in VTableLikeSlotReferenceValue returns a non-null value only when _index is 0. Verify that this behavior is intentional for all indices.
public override FieldDesc MemoryOwner => _index == 0 ? _fieldThatOwnsMemory : null;

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs:2491

  • In the IsCompatible method of ComInterfaceEntryArrayValue, entryType is overwritten for each non-static field without verifying that all fields share the same ComInterfaceEntry type. Consider adding an explicit check to ensure consistency across all instance fields.
foreach (FieldDesc field in type.GetFields()) { ... entryType = field.FieldType; ... }

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

@Sergio0694
Copy link
Contributor

Looks great!! Example use in CsWinRT 3.0 (assuming #114455 too), for reference: here 🙂

@MichalStrehovsky MichalStrehovsky merged commit d9c4c3e into dotnet:main Apr 21, 2025
100 of 102 checks passed
@MichalStrehovsky MichalStrehovsky deleted the fix114355 branch April 21, 2025 09:32
@github-actions github-actions bot locked and limited conversation to collaborators May 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support precompiling 'ComInterfaceEntry' vtables in ILC cctor interpreter (Native AOT)

3 participants