diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj index 6b3ddff0cc868c..d005341dae6b10 100644 --- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -203,7 +203,6 @@ - @@ -231,7 +230,6 @@ - diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index b5cff2f1e42ecd..53f2690948df45 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -645,27 +645,29 @@ public override Assembly GetSatelliteAssembly(CultureInfo culture, Version? vers { ArgumentNullException.ThrowIfNull(culture); - return InternalGetSatelliteAssembly(culture, version, throwOnFileNotFound: true)!; + return InternalGetSatelliteAssembly(this, culture, version, throwOnFileNotFound: true)!; } [DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - internal Assembly? InternalGetSatelliteAssembly(CultureInfo culture, + internal static Assembly? InternalGetSatelliteAssembly(Assembly assembly, + CultureInfo culture, Version? version, bool throwOnFileNotFound) { var an = new AssemblyName(); - an.SetPublicKey(GetPublicKey()); - an.Flags = GetFlags() | AssemblyNameFlags.PublicKey; - an.Version = version ?? GetVersion(); + RuntimeAssembly runtimeAssembly = (RuntimeAssembly)assembly; + an.SetPublicKey(runtimeAssembly.GetPublicKey()); + an.Flags = runtimeAssembly.GetFlags() | AssemblyNameFlags.PublicKey; + an.Version = version ?? runtimeAssembly.GetVersion(); an.CultureInfo = culture; - an.Name = GetSimpleName() + ".resources"; + an.Name = runtimeAssembly.GetSimpleName() + ".resources"; // This stack crawl mark is never used because the requesting assembly is explicitly specified, // so the value could be anything. StackCrawlMark unused = default; - RuntimeAssembly? retAssembly = InternalLoad(an, ref unused, requestingAssembly: this, throwOnFileNotFound: throwOnFileNotFound); + RuntimeAssembly? retAssembly = InternalLoad(an, ref unused, requestingAssembly: runtimeAssembly, throwOnFileNotFound: throwOnFileNotFound); - if (retAssembly == this) + if (retAssembly == runtimeAssembly) { retAssembly = null; } diff --git a/src/coreclr/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.CoreCLR.cs deleted file mode 100644 index 05805072cd7cf3..00000000000000 --- a/src/coreclr/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.CoreCLR.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Globalization; -using System.Reflection; - -namespace System.Resources -{ - internal sealed partial class ManifestBasedResourceGroveler - { - // Internal version of GetSatelliteAssembly that avoids throwing FileNotFoundException - private static Assembly? InternalGetSatelliteAssembly(Assembly mainAssembly, - CultureInfo culture, - Version? version) - { - return ((RuntimeAssembly)mainAssembly).InternalGetSatelliteAssembly(culture, version, throwOnFileNotFound: false); - } - } -} diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj index 4ca91458c70e71..86ce820851c1d1 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -184,7 +184,6 @@ - diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index 24a10f91faa7b4..9587d6f2d67fea 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -1,10 +1,34 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Globalization; + +using Internal.Reflection.Augments; + namespace System.Reflection { // Base class for runtime implemented Assembly public abstract class RuntimeAssembly : Assembly { + internal static Assembly? InternalGetSatelliteAssembly(Assembly mainAssembly, CultureInfo culture, Version? version, bool throwOnFileNotFound) + { + AssemblyName mainAssemblyAn = mainAssembly.GetName(); + AssemblyName an = new AssemblyName(); + + an.CultureInfo = culture; + an.Name = mainAssemblyAn.Name + ".resources"; + an.SetPublicKeyToken(mainAssemblyAn.GetPublicKeyToken()); + an.Flags = mainAssemblyAn.Flags; + an.Version = version ?? mainAssemblyAn.Version; + + Assembly? retAssembly = ReflectionAugments.ReflectionCoreCallbacks.Load(an, throwOnFileNotFound); + + if (retAssembly == mainAssembly) + { + retAssembly = null; + } + + return retAssembly; + } } } diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.NativeAot.cs deleted file mode 100644 index f16c1ba3892381..00000000000000 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.NativeAot.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Reflection; -using System.Text; - -using Internal.Reflection.Augments; - -namespace System.Resources -{ - internal partial class ManifestBasedResourceGroveler - { - // Internal version of GetSatelliteAssembly that avoids throwing FileNotFoundException - private static Assembly? InternalGetSatelliteAssembly(Assembly mainAssembly, - CultureInfo culture, - Version? version) - { - AssemblyName mainAssemblyAn = mainAssembly.GetName(); - AssemblyName an = new AssemblyName(); - - an.CultureInfo = culture; - an.Name = mainAssemblyAn.Name + ".resources"; - an.SetPublicKeyToken(mainAssemblyAn.GetPublicKeyToken()); - an.Flags = mainAssemblyAn.Flags; - an.Version = version ?? mainAssemblyAn.Version; - - Assembly? retAssembly = ReflectionAugments.ReflectionCoreCallbacks.Load(an, false); - - if (retAssembly == mainAssembly) - { - retAssembly = null; - } - - return retAssembly; - } - } -} diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 671d5a3dec585c..6375de34309eb8 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -1084,6 +1084,7 @@ + diff --git a/src/libraries/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs b/src/libraries/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs index e4aa24dd7eddf5..7cfe087de94cbe 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs @@ -269,6 +269,11 @@ internal ResourceSet CreateResourceSet(Stream store, Assembly assembly) } } + private static Assembly? InternalGetSatelliteAssembly(Assembly mainAssembly, CultureInfo culture, Version? version) + { + return RuntimeAssembly.InternalGetSatelliteAssembly(mainAssembly, culture, version, throwOnFileNotFound: false); + } + [RequiresUnreferencedCode("The CustomResourceTypesSupport feature switch has been enabled for this app which is being trimmed. " + "Custom readers as well as custom objects on the resources file are not observable by the trimmer and so required assemblies, types and members may be removed.")] private static ResourceSet InternalGetResourceSetFromSerializedData(Stream store, string readerTypeName, string? resSetTypeName, ResourceManager.ResourceManagerMediator mediator) diff --git a/src/coreclr/System.Private.CoreLib/src/System/Security/DynamicSecurityMethodAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Security/DynamicSecurityMethodAttribute.cs similarity index 100% rename from src/coreclr/System.Private.CoreLib/src/System/Security/DynamicSecurityMethodAttribute.cs rename to src/libraries/System.Private.CoreLib/src/System/Security/DynamicSecurityMethodAttribute.cs diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index 1c085ed36e446e..c273e6ba4172f7 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -246,7 +246,6 @@ - @@ -264,7 +263,6 @@ Condition="'$(FeatureObjCMarshal)' == 'true'"/> - diff --git a/src/mono/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.Mono.cs deleted file mode 100644 index 54871091da0f4f..00000000000000 --- a/src/mono/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.Mono.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Globalization; -using System.Reflection; - -namespace System.Resources -{ - internal partial class ManifestBasedResourceGroveler - { - private static Assembly? InternalGetSatelliteAssembly(Assembly mainAssembly, CultureInfo culture, Version? version) - { - return (RuntimeAssembly.InternalGetSatelliteAssembly(mainAssembly, culture, version, throwOnFileNotFound: false)); - } - } -} diff --git a/src/mono/System.Private.CoreLib/src/System/Security/DynamicSecurityMethodAttribute.cs b/src/mono/System.Private.CoreLib/src/System/Security/DynamicSecurityMethodAttribute.cs deleted file mode 100644 index e3dae854517e29..00000000000000 --- a/src/mono/System.Private.CoreLib/src/System/Security/DynamicSecurityMethodAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace System.Security -{ - // DynamicSecurityMethodAttribute: - // All methods that use StackCrawlMark should be marked with this attribute. This attribute - // disables inlining of the calling method to allow stackwalking to find the exact caller. - // - // This attribute used to indicate that the target method requires space for a security object - // to be allocated on the callers stack. It is not used for this purpose anymore because of security - // stackwalks are not ever done in CoreCLR. - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, AllowMultiple = true, Inherited = false)] - internal sealed class DynamicSecurityMethodAttribute : Attribute - { - public DynamicSecurityMethodAttribute() { } - } -}