-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
area-Interop-monoin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Description
The MarshalingPInvokeScanner task doesn't see [DisableRuntimeMarshalling] attributes defined in any assembly except System.Runtime.dll (where the attribute is defined).
The problem is that this code:
runtime/src/tasks/MonoTargetsTasks/MarshalingPInvokeScanner/MarshalingPInvokeScanner.cs
Lines 116 to 131 in 035d268
| foreach (CustomAttributeHandle attrHandle in mdtReader.CustomAttributes) | |
| { | |
| CustomAttribute attr = mdtReader.GetCustomAttribute(attrHandle); | |
| if (attr.Constructor.Kind == HandleKind.MethodDefinition) | |
| { | |
| MethodDefinitionHandle mdh = (MethodDefinitionHandle)attr.Constructor; | |
| MethodDefinition md = mdtReader.GetMethodDefinition(mdh); | |
| TypeDefinitionHandle tdh = md.GetDeclaringType(); | |
| TypeDefinition td = mdtReader.GetTypeDefinition(tdh); | |
| if (mdtReader.GetString(td.Namespace) == "System.Runtime.CompilerServices" && | |
| mdtReader.GetString(td.Name) == "DisableRuntimeMarshallingAttribute") | |
| return false; | |
| } | |
| } |
does not take into account that the attribute's constructor will be a MethodReference when referencing a constructor defined in another assembly.
Repro:
- Clone https://github.com/rolfbjarne/marshalling-scanner (including submodules)
- Run
make disable-runtime-marshalling-attribute
This happens:
[...]
Assembly /Users/rolf/test/dotnet/marshalling-scanner/disable-runtime-marshalling-attribute/bin/Debug/net9.0/disable-runtime-marshalling-attribute.dll requires marshal-ilgen for method .Class1:DoSomething (first pass).
❌ Failed, because some assemblies are incompatible
make: *** [disable-runtime-marshalling-attribute] Error 1
Metadata
Metadata
Assignees
Labels
area-Interop-monoin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Type
Projects
Status
No status