Skip to content

Commit

Permalink
Replace linker descriptor for AssemblyBuilder with DynamicDependency (d…
Browse files Browse the repository at this point in the history
…otnet#38710)

* Replace linker descriptor for AssemblyBuilder with DynamicDependency

for better linking when AssemblyBuilder is not instantiated.

Contributes to dotnet#38692

* Review feedback
  • Loading branch information
marek-safar authored Jul 3, 2020
1 parent 80fe5bb commit 054fb2e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,6 @@
<method signature="System.Void .ctor(System.String)" />
</type>

<type fullname="System.Reflection.Emit.AssemblyBuilder" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.ConstructorBuilder" preserve="fields" required="false" feature="sre"/>
<type fullname="System.Reflection.Emit.DynamicMethod" preserve="fields" required="false" feature="sre" />
<!-- mono_dynamic_image_register_token -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,10 @@ public sealed class AssemblyBuilder : Assembly
//
// AssemblyBuilder inherits from Assembly, but the runtime thinks its layout inherits from RuntimeAssembly
//
#region Sync with RuntimeAssembly.cs and ReflectionAssembly in object-internals.h
#pragma warning disable 649
#region Sync with RuntimeAssembly.cs and ReflectionAssembly in object-internals.h
internal IntPtr _mono_assembly;
#pragma warning restore 649
private object? _evidence;
#endregion

#pragma warning disable 169, 414, 649
#region Sync with object-internals.h
private UIntPtr dynamic_assembly; /* GC-tracked */
private MethodInfo? entry_point;
private ModuleBuilder[] modules;
Expand All @@ -202,13 +197,12 @@ public sealed class AssemblyBuilder : Assembly
private object? permissions_minimum;
private object? permissions_optional;
private object? permissions_refused;
private PortableExecutableKinds peKind;
private ImageFileMachine machine;
private int peKind;
private int machine;
private bool corlib_internal;
private Type[]? type_forwarders;
private byte[]? pktoken;
#endregion
#pragma warning restore 169, 414, 649
#endregion

private AssemblyName aname;
private string? assemblyName;
Expand All @@ -224,7 +218,8 @@ public sealed class AssemblyBuilder : Assembly
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void UpdateNativeCustomAttributes(AssemblyBuilder ab);

internal AssemblyBuilder(AssemblyName n, string? directory, AssemblyBuilderAccess access, bool corlib_internal)
[DynamicDependency(nameof(pktoken))] // Automatically keeps all previous fields too due to StructLayout
private AssemblyBuilder(AssemblyName n, string? directory, AssemblyBuilderAccess access, bool corlib_internal)
{
aname = (AssemblyName)n.Clone();

Expand Down

0 comments on commit 054fb2e

Please sign in to comment.