From 636988a0727d01479f9af94ef1c56bb7e79ecb24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Kliger=20=28=CE=BBgeek=29?= Date: Wed, 28 Apr 2021 12:02:13 -0400 Subject: [PATCH] Add AssemblyExtensions.GetApplyUpdateCapabilities method (#51954) * Add AssemblyExtensions.GetApplyUpdateCapabilities method * add linker descriptor * fix whitespace * assert result is a string --- .../Reflection/Metadata/AssemblyExtensions.cs | 5 +++++ .../src/ILLink/ILLink.Descriptors.Shared.xml | 9 +++++++++ .../tests/AssemblyExtensionsTest.cs | 14 ++++++++++++++ .../Reflection/Metadata/AssemblyExtensions.cs | 11 ++++++----- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Metadata/AssemblyExtensions.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Metadata/AssemblyExtensions.cs index 28a4677d45eca..15ee7bd82bf61 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Metadata/AssemblyExtensions.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Metadata/AssemblyExtensions.cs @@ -81,5 +81,10 @@ public static void ApplyUpdate(Assembly assembly, ReadOnlySpan metadataDel } } } + + internal static string GetApplyUpdateCapabilities() + { + return "Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition"; + } } } diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml index 3dfcceb59ebea..b70cb912600ec 100644 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml @@ -62,4 +62,13 @@ + + + + + + + diff --git a/src/libraries/System.Runtime.Loader/tests/AssemblyExtensionsTest.cs b/src/libraries/System.Runtime.Loader/tests/AssemblyExtensionsTest.cs index a1c7a4dd3111b..5208b573c75d2 100644 --- a/src/libraries/System.Runtime.Loader/tests/AssemblyExtensionsTest.cs +++ b/src/libraries/System.Runtime.Loader/tests/AssemblyExtensionsTest.cs @@ -30,5 +30,19 @@ public static void ApplyUpdateInvalidParameters() Assert.Throws(() => AssemblyExtensions.ApplyUpdate(typeof(AssemblyExtensions).Assembly, new ReadOnlySpan(metadataDelta), new ReadOnlySpan(ilDelta), ReadOnlySpan.Empty)); } + + [Fact] + public void GetApplyUpdateCapabilitiesIsCallable() + { + var ty = typeof(System.Reflection.Metadata.AssemblyExtensions); + var mi = ty.GetMethod("GetApplyUpdateCapabilities", BindingFlags.NonPublic | BindingFlags.Static, Array.Empty()); + + Assert.NotNull(mi); + + var result = mi.Invoke(null, null); + + Assert.NotNull(result); + Assert.Equal(typeof(string), result.GetType()); + } } } diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Metadata/AssemblyExtensions.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Metadata/AssemblyExtensions.cs index 337f1f516b1e6..471ab27922ed8 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Metadata/AssemblyExtensions.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Metadata/AssemblyExtensions.cs @@ -51,12 +51,13 @@ public static void ApplyUpdate(Assembly assembly, ReadOnlySpan metadataDel #endif } - internal static void ApplyUpdateSdb(Assembly assembly, byte[] metadataDelta, byte[] ilDelta, byte[]? pdbDelta) + internal static string GetApplyUpdateCapabilities() { - ReadOnlySpan md = metadataDelta; - ReadOnlySpan il = ilDelta; - ReadOnlySpan 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