Skip to content
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

[mono] Fix detecting [DisableRuntimeMarshalling] in MarshalingPInvokeScanner. #112981

Merged
merged 3 commits into from
Mar 7, 2025

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 Copilot bot review requested due to automatic review settings February 27, 2025 09:41

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants