From 97f5f606e887bca6e4532b292d495de62acdef97 Mon Sep 17 00:00:00 2001 From: Levi Broderick Date: Fri, 20 Nov 2020 00:27:57 -0800 Subject: [PATCH 1/2] Fix build breaks --- .../System/Collections/Generic/ArraySortHelper.CoreCLR.cs | 4 ++-- .../src/System/Reflection/CustomAttribute.cs | 2 +- .../src/System/Runtime/InteropServices/Marshal.CoreCLR.cs | 2 +- .../src/System/RuntimeType.CoreCLR.cs | 7 +++++-- src/coreclr/src/vm/reflectioninvocation.cpp | 4 ++++ .../src/System/Activator.RuntimeType.cs | 4 ++-- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.CoreCLR.cs index be5fc2874c56c..0422905c95679 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.CoreCLR.cs @@ -27,7 +27,7 @@ private static IArraySortHelper CreateArraySortHelper() if (typeof(IComparable).IsAssignableFrom(typeof(T))) { - defaultArraySortHelper = (IArraySortHelper)typeof(GenericArraySortHelper).TypeHandle.Instantiate(new Type[] { typeof(T) }).CreateInstanceDefaultCtor(publicOnly: false, wrapExceptions: false)!; + defaultArraySortHelper = (IArraySortHelper)typeof(GenericArraySortHelper).TypeHandle.Instantiate(new Type[] { typeof(T) }).CreateInstanceDefaultCtor(publicOnly: false, skipCheckThis: true, fillCache: false, wrapExceptions: false)!; } else { @@ -62,7 +62,7 @@ private static IArraySortHelper CreateArraySortHelper() if (typeof(IComparable).IsAssignableFrom(typeof(TKey))) { - defaultArraySortHelper = (IArraySortHelper)typeof(GenericArraySortHelper).TypeHandle.Instantiate(new Type[] { typeof(TKey), typeof(TValue) }).CreateInstanceDefaultCtor(publicOnly: false, wrapExceptions: false)!; + defaultArraySortHelper = (IArraySortHelper)typeof(GenericArraySortHelper).TypeHandle.Instantiate(new Type[] { typeof(TKey), typeof(TValue) }).CreateInstanceDefaultCtor(publicOnly: false, skipCheckThis: true, fillCache: false, wrapExceptions: false)!; } else { diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs index 33df3dfc35af8..41534ab065183 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs @@ -1228,7 +1228,7 @@ private static void AddCustomAttributes( } else { - attribute = attributeType.CreateInstanceDefaultCtor(publicOnly: false, wrapExceptions: false)!; + attribute = attributeType.CreateInstanceDefaultCtor(publicOnly: false, skipCheckThis: true, fillCache: true, wrapExceptions: false)!; // It is allowed by the ECMA spec to have an empty signature blob int blobLen = (int)((byte*)blobEnd - (byte*)blobStart); diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs index cfa743db019e2..8bf969b604081 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs @@ -200,7 +200,7 @@ private static void PrelinkCore(MethodInfo m) private static object PtrToStructureHelper(IntPtr ptr, Type structureType) { var rt = (RuntimeType)structureType; - object structure = rt.CreateInstanceDefaultCtor(publicOnly: false, wrapExceptions: true)!; + object structure = rt.CreateInstanceDefaultCtor(publicOnly: false, skipCheckThis: false, fillCache: false, wrapExceptions: true)!; PtrToStructureHelper(ptr, structure, allowValueClasses: true); return structure; } diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs index 3da5023d8215e..2dfc8295979be 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs @@ -3883,7 +3883,7 @@ private void CreateInstanceCheckThis() if (args.Length == 0 && (bindingAttr & BindingFlags.Public) != 0 && (bindingAttr & BindingFlags.Instance) != 0 && (IsGenericCOMObjectImpl() || IsValueType)) { - instance = CreateInstanceDefaultCtor(publicOnly, wrapExceptions); + instance = CreateInstanceDefaultCtor(publicOnly, skipCheckThis: false, fillCache: true, wrapExceptions); } else { @@ -3959,10 +3959,13 @@ private void CreateInstanceCheckThis() Justification = "Implementation detail of Activator that linker intrinsically recognizes")] [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2085:UnrecognizedReflectionPattern", Justification = "Implementation detail of Activator that linker intrinsically recognizes")] - internal object? CreateInstanceDefaultCtor(bool publicOnly, bool wrapExceptions) + internal object? CreateInstanceDefaultCtor(bool publicOnly, bool skipCheckThis, bool fillCache, bool wrapExceptions) { // Get or create the cached factory. Creating the cache will fail if one // of our invariant checks fails; e.g., no appropriate ctor found. + // + // n.b. In coreclr we ignore 'skipCheckThis' (assumed to be false) + // and 'fillCache' (assumed to be true). if (GenericCache is not ActivatorCache cache) { diff --git a/src/coreclr/src/vm/reflectioninvocation.cpp b/src/coreclr/src/vm/reflectioninvocation.cpp index 9cbfdd190e769..fe8fe2a6220d4 100644 --- a/src/coreclr/src/vm/reflectioninvocation.cpp +++ b/src/coreclr/src/vm/reflectioninvocation.cpp @@ -2192,7 +2192,11 @@ void QCALLTYPE RuntimeTypeHandle::AllocateComObject( if (!allocated) { +#ifdef FEATURE_COMINTEROP COMPlusThrow(kInvalidComObjectException, IDS_EE_NO_BACKING_CLASS_FACTORY); +#else // FEATURE_COMINTEROP + COMPlusThrow(kPlatformNotSupportedException, IDS_EE_NO_BACKING_CLASS_FACTORY); +#endif // FEATURE_COMINTEROP } END_QCALL; diff --git a/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs b/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs index 7607ec2ea838e..2f54f175199ee 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs @@ -92,7 +92,7 @@ public static partial class Activator throw new ArgumentNullException(nameof(type)); if (type.UnderlyingSystemType is RuntimeType rt) - return rt.CreateInstanceDefaultCtor(publicOnly: !nonPublic, wrapExceptions: wrapExceptions); + return rt.CreateInstanceDefaultCtor(publicOnly: !nonPublic, skipCheckThis: false, fillCache: true, wrapExceptions: wrapExceptions); throw new ArgumentException(SR.Arg_MustBeType, nameof(type)); } @@ -148,7 +148,7 @@ public static partial class Activator [System.Runtime.CompilerServices.Intrinsic] public static T CreateInstance<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]T>() { - return (T)((RuntimeType)typeof(T)).CreateInstanceDefaultCtor(publicOnly: true, wrapExceptions: true)!; + return (T)((RuntimeType)typeof(T)).CreateInstanceDefaultCtor(publicOnly: true, skipCheckThis: true, fillCache: true, wrapExceptions: true)!; } private static T CreateDefaultInstance() where T : struct => default; From 2e440139fe6d65813e31984f775fc425f4d31767 Mon Sep 17 00:00:00 2001 From: Levi Broderick Date: Fri, 20 Nov 2020 00:31:59 -0800 Subject: [PATCH 2/2] Fix strings.resx whitespace --- .../src/Resources/Strings.resx | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx index ae5144f7abed5..0f07171f4475a 100644 --- a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx +++ b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx @@ -1,17 +1,17 @@  -