Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tools/dotnet-linker/Steps/ManagedRegistrarStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void CreateUnmanagedCallersMethod (MethodDefinition method, AssemblyTrampolineIn
}

var callback = callbackType.AddMethod (name, MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig, placeholderType);
callback.CustomAttributes.Add (CreateUnmanagedCallersAttribute (name));
callback.CustomAttributes.Add (CreateUnmanagedCallersAttribute (name, method.DeclaringType));
infos.Add (new TrampolineInfo (callback, method, name));

// If the target method is marked, then we must mark the trampoline as well.
Expand Down Expand Up @@ -1242,10 +1242,12 @@ StaticRegistrar StaticRegistrar {
get { return DerivedLinkContext.StaticRegistrar; }
}

CustomAttribute CreateUnmanagedCallersAttribute (string entryPoint)
CustomAttribute CreateUnmanagedCallersAttribute (string entryPoint, TypeReference? associatedSourceType = null)
{
var unmanagedCallersAttribute = new CustomAttribute (abr.UnmanagedCallersOnlyAttribute_Constructor);
unmanagedCallersAttribute.Fields.Add (new CustomAttributeNamedArgument ("EntryPoint", new CustomAttributeArgument (abr.System_String, entryPoint)));
if (associatedSourceType is not null)
unmanagedCallersAttribute.Fields.Add (new CustomAttributeNamedArgument ("AssociatedSourceType", new CustomAttributeArgument (abr.System_Type, associatedSourceType)));
return unmanagedCallersAttribute;
}
Comment on lines +1245 to 1252

Expand Down
Loading