Skip to content

Commit

Permalink
Add AssemblyExtensions.GetApplyUpdateCapabilities method (#51954)
Browse files Browse the repository at this point in the history
* Add AssemblyExtensions.GetApplyUpdateCapabilities method

* add linker descriptor

* fix whitespace

* assert result is a string
  • Loading branch information
lambdageek authored Apr 28, 2021
1 parent a0c1fca commit 636988a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,10 @@ public static void ApplyUpdate(Assembly assembly, ReadOnlySpan<byte> metadataDel
}
}
}

internal static string GetApplyUpdateCapabilities()
{
return "Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,13 @@
<method signature="System.Void Initialize()" />
</type>
</assembly>

<!-- methods used by hot reload.
TODO: once there's a feature flag, add it to the linker descriptor
-->
<assembly fullname="System.Private.CoreLib">
<type fullname="System.Reflection.Metadata.AssemblyExtensions">
<method name="GetApplyUpdateCapabilities" />
</type>
</assembly>
</linker>
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,19 @@ public static void ApplyUpdateInvalidParameters()
Assert.Throws<InvalidOperationException>(() =>
AssemblyExtensions.ApplyUpdate(typeof(AssemblyExtensions).Assembly, new ReadOnlySpan<byte>(metadataDelta), new ReadOnlySpan<byte>(ilDelta), ReadOnlySpan<byte>.Empty));
}

[Fact]
public void GetApplyUpdateCapabilitiesIsCallable()
{
var ty = typeof(System.Reflection.Metadata.AssemblyExtensions);
var mi = ty.GetMethod("GetApplyUpdateCapabilities", BindingFlags.NonPublic | BindingFlags.Static, Array.Empty<Type>());

Assert.NotNull(mi);

var result = mi.Invoke(null, null);

Assert.NotNull(result);
Assert.Equal(typeof(string), result.GetType());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ public static void ApplyUpdate(Assembly assembly, ReadOnlySpan<byte> metadataDel
#endif
}

internal static void ApplyUpdateSdb(Assembly assembly, byte[] metadataDelta, byte[] ilDelta, byte[]? pdbDelta)
internal static string GetApplyUpdateCapabilities()
{
ReadOnlySpan<byte> md = metadataDelta;
ReadOnlySpan<byte> il = ilDelta;
ReadOnlySpan<byte> dpdb = pdbDelta == null ? default : pdbDelta;
ApplyUpdate (assembly, md, il, dpdb);
#if !FEATURE_METADATA_UPDATE
return string.Empty;
#else
return "Baseline";
#endif
}

#if FEATURE_METADATA_UPDATE
Expand Down

0 comments on commit 636988a

Please sign in to comment.