Skip to content

Conversation

@rolfbjarne
Copy link
Member

Fix detecting the [DisableRuntimeMarshalling] attribute in
MarshalingPInvokeScanner for assemblies that reference the attribute from
another assembly (i.e. any assembly except System.Runtime.dll).

Fixes #112980.

…Scanner.

Fix detecting the [DisableRuntimeMarshalling] attribute in
MarshalingPInvokeScanner for assemblies that reference the attribute from
another assembly (i.e. any assembly except System.Runtime.dll).

Fixes dotnet#112980.
Copilot AI review requested due to automatic review settings February 27, 2025 09:41
@ghost ghost added the area-Interop-coreclr label Feb 27, 2025
Copy link
Contributor

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.

PR Overview

This PR addresses the issue of detecting the [DisableRuntimeMarshalling] attribute when it is referenced from assemblies other than System.Runtime.dll. The changes refactor inline string comparisons into a new helper method and apply it in both type definition and member reference contexts.

  • Introduced the IsDisableRuntimeMarshallingAttribute helper method.
  • Replaced inline attribute checks with the new helper method for clearer logic.
  • Updated attribute checks for both direct and member reference cases.

Reviewed Changes

File Description
src/tasks/MonoTargetsTasks/MarshalingPInvokeScanner/MarshalingPInvokeScanner.cs Refactored attribute detection to improve consistency while fixing the attribute resolving issue.

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

Comments suppressed due to low confidence (1)

src/tasks/MonoTargetsTasks/MarshalingPInvokeScanner/MarshalingPInvokeScanner.cs:107

  • Ensure unit tests cover scenarios for both direct type definition and member reference attribute detections using IsDisableRuntimeMarshallingAttribute to confirm the fix works under all expected conditions.
private bool IsDisableRuntimeMarshallingAttribute (MetadataReader mdtReader, StringHandle ns, StringHandle name)

…PInvokeScanner.cs

Co-authored-by: Theodore Tsirpanis <teo@tsirpanis.gr>
@akoeplinger
Copy link
Member

lgtm but there are a few code style errors

@rolfbjarne
Copy link
Member Author

@akoeplinger looks like the failure is unrelated? is there anything else I need to do to get this in?

@akoeplinger
Copy link
Member

is there anything else I need to do to get this in?

no, I just forgot to merge, sorry :D

@akoeplinger akoeplinger merged commit d2650b6 into dotnet:main Mar 7, 2025
136 of 138 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 7, 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.

MarshalingPInvokeScanner doesn't see [DisableRuntimeMarshalling] attributes in any assembly except System.Runtime.dll

4 participants