Skip to content

Commit b15ffe5

Browse files
authored
Fold System.Private.Reflection.Core into CoreLib (#70545)
1 parent 5c5e66e commit b15ffe5

File tree

161 files changed

+546
-1194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+546
-1194
lines changed

src/coreclr/dlls/mscorrc/mscorrc.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ BEGIN
415415
IDS_EE_SIZECONTROLBADTYPE "Array size control parameter type not supported."
416416
IDS_EE_SAFEARRAYSZARRAYMISMATCH "SafeArray cannot be marshaled to this array type because it has either nonzero lower bounds or more than one dimension."
417417

418-
IDS_EE_ASSEMBLY_GETTYPE_CANNONT_HAVE_ASSEMBLY_SPEC "Type names passed to Assembly.GetType() must not specify an assembly."
419418
IDS_EE_NEEDS_ASSEMBLY_SPEC "Typename needs an assembly qualifier."
420419

421420
IDS_EE_FILELOAD_ERROR_GENERIC "Could not load file or assembly '%1'. %2"

src/coreclr/dlls/mscorrc/resource.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@
305305

306306
#define IDS_CLASSLOAD_OVERLAPPING_INTERFACES 0x1a80
307307
#define IDS_CLASSLOAD_32BITCLRLOADING64BITASSEMBLY 0x1a81
308-
#define IDS_EE_ASSEMBLY_GETTYPE_CANNONT_HAVE_ASSEMBLY_SPEC 0x1a84
309308

310309
#define IDS_EE_NEEDS_ASSEMBLY_SPEC 0x1a87
311310

src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ The .NET Foundation licenses this file to you under the MIT license.
109109
</ItemGroup>
110110

111111
<ItemGroup>
112-
<_ExcludedPrivateSdkAssemblies Include="$(IlcSdkPath)System.Private.Reflection.Core.dll" Condition="$(IlcDisableReflection) == 'true'" />
113-
<PrivateSdkAssemblies Include="$(IlcSdkPath)*.dll" Exclude="@(_ExcludedPrivateSdkAssemblies)"/>
112+
<PrivateSdkAssemblies Include="$(IlcSdkPath)*.dll" />
114113

115114
<!-- Exclude unmanaged dlls -->
116115
<FrameworkAssemblies Include="$(IlcFrameworkPath)*.dll" Exclude="$(IlcFrameworkPath)*.Native.dll;$(IlcFrameworkPath)msquic.dll" />
@@ -150,8 +149,7 @@ The .NET Foundation licenses this file to you under the MIT license.
150149

151150
<!-- If running from a package these values need to be set again with the resolved IlcXYZPath -->
152151
<ItemGroup>
153-
<_ExcludedPrivateSdkAssemblies Include="$(IlcSdkPath)System.Private.Reflection.Core.dll" Condition="$(IlcDisableReflection) == 'true'" />
154-
<PrivateSdkAssemblies Include="$(IlcSdkPath)*.dll" Exclude="@(_ExcludedPrivateSdkAssemblies)"/>
152+
<PrivateSdkAssemblies Include="$(IlcSdkPath)*.dll" />
155153

156154
<!-- Exclude unmanaged dlls -->
157155
<FrameworkAssemblies Include="$(IlcFrameworkPath)*.dll" Exclude="$(IlcFrameworkPath)*.Native.dll;$(IlcFrameworkPath)msquic.dll" />

src/coreclr/nativeaot/Common/src/System/Runtime/CompilerServices/DeveloperExperienceModeOnlyAttribute.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/coreclr/nativeaot/Common/src/System/Runtime/CompilerServices/DeveloperExperienceState.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
namespace System.Runtime.CompilerServices
77
{
8-
[DeveloperExperienceModeOnly]
98
internal static class DeveloperExperienceState
109
{
1110
public static bool DeveloperExperienceModeEnabled

src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
<method signature="System.Boolean get_SupportsGenericIEquatableInterfaces()" body="stub" value="true" />
1818
</type>
1919

20+
<type fullname="System.Reflection.Runtime.General.TypeUnifier" feature="System.Reflection.IsTypeConstructionEagerlyValidated" featurevalue="false">
21+
<method signature="System.Boolean get_IsTypeConstructionEagerlyValidated()" body="stub" />
22+
</type>
2023
</linker>

src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Reflection/Core/AssemblyBinder.cs renamed to src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/AssemblyBinder.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
using System.Reflection;
77
using Internal.Metadata.NativeFormat;
88
using System.Reflection.Runtime.General;
9+
using System.Runtime.CompilerServices;
910
using System.Runtime.InteropServices;
1011

1112
namespace Internal.Reflection.Core
1213
{
1314
// Auto StructLayout used to suppress warning that order of fields is not guaranteed in partial structs
1415
[StructLayout(LayoutKind.Auto)]
16+
[ReflectionBlocked]
17+
[CLSCompliant(false)]
1518
public partial struct AssemblyBindResult
1619
{
1720
public MetadataReader Reader;
@@ -25,6 +28,8 @@ public partial struct AssemblyBindResult
2528
//
2629
// If the binder cannot locate an assembly, it must return null and set "exception" to an exception object.
2730
//
31+
[ReflectionBlocked]
32+
[CLSCompliant(false)]
2833
public abstract class AssemblyBinder
2934
{
3035
public const string DefaultAssemblyNameForGetType = "System.Private.CoreLib";
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#endif
1717
using System.Reflection.Runtime.TypeParsing;
1818
using System.Reflection.Runtime.CustomAttributes;
19+
using System.Runtime.CompilerServices;
1920
using Internal.Metadata.NativeFormat;
2021
using Internal.Runtime.Augments;
2122

@@ -24,6 +25,8 @@ namespace Internal.Reflection.Core.Execution
2425
//
2526
// This singleton class acts as an entrypoint from System.Private.Reflection.Execution to System.Private.Reflection.Core.
2627
//
28+
[ReflectionBlocked]
29+
[CLSCompliant(false)]
2730
public sealed class ExecutionDomain
2831
{
2932
internal ExecutionDomain(ReflectionDomainSetup executionDomainSetup, ExecutionEnvironment executionEnvironment)
@@ -124,7 +127,7 @@ private static CoreTypeResolver CreateCoreTypeResolver(Func<Assembly, string, bo
124127
public MethodBase GetMethod(RuntimeTypeHandle declaringTypeHandle, QMethodDefinition methodHandle, RuntimeTypeHandle[] genericMethodTypeArgumentHandles)
125128
{
126129
RuntimeTypeInfo contextTypeInfo = declaringTypeHandle.GetTypeForRuntimeTypeHandle();
127-
RuntimeNamedMethodInfo runtimeNamedMethodInfo = null;
130+
RuntimeNamedMethodInfo? runtimeNamedMethodInfo = null;
128131

129132
if (methodHandle.IsNativeFormatMetadataBased)
130133
{
@@ -218,7 +221,7 @@ public Type GetArrayTypeForHandle(RuntimeTypeHandle typeHandle)
218221
{
219222
RuntimeTypeHandle elementTypeHandle;
220223
if (!ExecutionEnvironment.TryGetArrayTypeElementType(typeHandle, out elementTypeHandle))
221-
throw CreateMissingMetadataException((Type)null);
224+
throw CreateMissingMetadataException((Type?)null);
222225

223226
return elementTypeHandle.GetTypeForRuntimeTypeHandle().GetArrayType(typeHandle);
224227
}
@@ -227,7 +230,7 @@ public Type GetMdArrayTypeForHandle(RuntimeTypeHandle typeHandle, int rank)
227230
{
228231
RuntimeTypeHandle elementTypeHandle;
229232
if (!ExecutionEnvironment.TryGetArrayTypeElementType(typeHandle, out elementTypeHandle))
230-
throw CreateMissingMetadataException((Type)null);
233+
throw CreateMissingMetadataException((Type?)null);
231234

232235
return elementTypeHandle.GetTypeForRuntimeTypeHandle().GetMultiDimArrayType(rank, typeHandle);
233236
}
@@ -236,7 +239,7 @@ public Type GetPointerTypeForHandle(RuntimeTypeHandle typeHandle)
236239
{
237240
RuntimeTypeHandle targetTypeHandle;
238241
if (!ExecutionEnvironment.TryGetPointerTypeTargetType(typeHandle, out targetTypeHandle))
239-
throw CreateMissingMetadataException((Type)null);
242+
throw CreateMissingMetadataException((Type?)null);
240243

241244
return targetTypeHandle.GetTypeForRuntimeTypeHandle().GetPointerType(typeHandle);
242245
}
@@ -245,7 +248,7 @@ public Type GetByRefTypeForHandle(RuntimeTypeHandle typeHandle)
245248
{
246249
RuntimeTypeHandle targetTypeHandle;
247250
if (!ExecutionEnvironment.TryGetByRefTypeTargetType(typeHandle, out targetTypeHandle))
248-
throw CreateMissingMetadataException((Type)null);
251+
throw CreateMissingMetadataException((Type?)null);
249252

250253
return targetTypeHandle.GetTypeForRuntimeTypeHandle().GetByRefType(typeHandle);
251254
}
@@ -284,12 +287,12 @@ public Type GetConstructedGenericTypeForHandle(RuntimeTypeHandle typeHandle)
284287
//=======================================================================================
285288
// MissingMetadataExceptions.
286289
//=======================================================================================
287-
public Exception CreateMissingMetadataException(Type pertainant)
290+
public Exception CreateMissingMetadataException(Type? pertainant)
288291
{
289292
return this.ReflectionDomainSetup.CreateMissingMetadataException(pertainant);
290293
}
291294

292-
public Exception CreateMissingMetadataException(TypeInfo pertainant)
295+
public Exception CreateMissingMetadataException(TypeInfo? pertainant)
293296
{
294297
return this.ReflectionDomainSetup.CreateMissingMetadataException(pertainant);
295298
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Diagnostics.CodeAnalysis;
99
using System.Reflection.Runtime.General;
1010
using System.Reflection.Runtime.TypeInfos;
11+
using System.Runtime.CompilerServices;
1112
using Internal.Metadata.NativeFormat;
1213

1314
using OpenMethodInvoker = System.Reflection.Runtime.MethodInfos.OpenMethodInvoker;
@@ -19,6 +20,8 @@ namespace Internal.Reflection.Core.Execution
1920
// This class abstracts the underlying Redhawk (or whatever execution engine) runtime and exposes the services
2021
// that I.R.Core.Execution needs.
2122
//
23+
[ReflectionBlocked]
24+
[CLSCompliant(false)]
2225
public abstract class ExecutionEnvironment
2326
{
2427
//==============================================================================================
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
using System.Reflection;
66
using System.Diagnostics;
77
using System.Collections.Generic;
8+
using System.Runtime.CompilerServices;
89

910
namespace Internal.Reflection.Core.Execution
1011
{
1112
//
1213
// This class abstracts the underlying Redhawk (or whatever execution engine) runtime that sets and gets fields.
1314
//
15+
[ReflectionBlocked]
16+
[CLSCompliant(false)]
1417
public abstract class FieldAccessor
1518
{
1619
protected FieldAccessor() { }
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Diagnostics;
77
using System.Globalization;
88
using System.Reflection.Runtime.General;
9+
using System.Runtime.CompilerServices;
910

1011
using Internal.Runtime.Augments;
1112

@@ -15,20 +16,21 @@ namespace Internal.Reflection.Core.Execution
1516
// This class polymorphically implements the MethodBase.Invoke() api and its close cousins. MethodInvokers are designed to be built once and cached
1617
// for maximum Invoke() throughput.
1718
//
19+
[ReflectionBlocked]
1820
public abstract class MethodInvoker
1921
{
2022
protected MethodInvoker() { }
2123

2224
[DebuggerGuidedStepThrough]
23-
public object Invoke(object thisObject, object[] arguments, Binder binder, BindingFlags invokeAttr, CultureInfo cultureInfo)
25+
public object? Invoke(object thisObject, object?[] arguments, Binder? binder, BindingFlags invokeAttr, CultureInfo? cultureInfo)
2426
{
2527
BinderBundle binderBundle = binder.ToBinderBundle(invokeAttr, cultureInfo);
2628
bool wrapInTargetInvocationException = (invokeAttr & BindingFlags.DoNotWrapExceptions) == 0;
27-
object result = Invoke(thisObject, arguments, binderBundle, wrapInTargetInvocationException);
29+
object? result = Invoke(thisObject, arguments, binderBundle, wrapInTargetInvocationException);
2830
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
2931
return result;
3032
}
31-
protected abstract object Invoke(object thisObject, object[] arguments, BinderBundle binderBundle, bool wrapInTargetInvocationException);
33+
protected abstract object? Invoke(object? thisObject, object?[] arguments, BinderBundle binderBundle, bool wrapInTargetInvocationException);
3234
public abstract Delegate CreateDelegate(RuntimeTypeHandle delegateType, object target, bool isStatic, bool isVirtual, bool isOpen);
3335

3436
// This property is used to retrieve the target method pointer. It is used by the RuntimeMethodHandle.GetFunctionPointer API
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
using System.Reflection;
66
using System.Collections.Generic;
77
using System.Reflection.Runtime.General;
8+
using System.Runtime.CompilerServices;
89

910
using Internal.LowLevelLinq;
1011
using Internal.Reflection.Augments;
1112
using Internal.Reflection.Core.Execution;
1213

1314
namespace Internal.Reflection.Core.Execution
1415
{
16+
[ReflectionBlocked]
17+
[CLSCompliant(false)]
1518
public static class ReflectionCoreExecution
1619
{
1720
//
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
using System;
55
using System.Reflection;
66
using System.Reflection.Runtime.General;
7+
using System.Runtime.CompilerServices;
78

89
namespace Internal.Reflection.Core
910
{
11+
[ReflectionBlocked]
12+
[CLSCompliant(false)]
1013
public abstract class ReflectionDomainSetup
1114
{
1215
protected ReflectionDomainSetup() { }
1316
public abstract AssemblyBinder AssemblyBinder { get; }
14-
public abstract Exception CreateMissingMetadataException(TypeInfo pertainant);
15-
public abstract Exception CreateMissingMetadataException(Type pertainant);
17+
public abstract Exception CreateMissingMetadataException(TypeInfo? pertainant);
18+
public abstract Exception CreateMissingMetadataException(Type? pertainant);
1619
public abstract Exception CreateMissingMetadataException(TypeInfo pertainant, string nestedTypeName);
1720
public abstract Exception CreateNonInvokabilityException(MemberInfo pertainant);
1821
public abstract Exception CreateMissingArrayTypeException(Type elementType, bool isMultiDim, int rank);

src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/TypeLoaderCallbacks.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,29 @@
66
using System.Collections.Generic;
77

88
using Internal.Runtime.CompilerServices;
9+
using Internal.NativeFormat;
10+
using Internal.Metadata.NativeFormat;
911

1012
namespace Internal.Runtime.Augments
1113
{
1214
[CLSCompliant(false)]
1315
[System.Runtime.CompilerServices.ReflectionBlocked]
1416
public abstract class TypeLoaderCallbacks
1517
{
18+
public abstract TypeManagerHandle GetModuleForMetadataReader(MetadataReader reader);
1619
public abstract bool TryGetConstructedGenericTypeForComponents(RuntimeTypeHandle genericTypeDefinitionHandle, RuntimeTypeHandle[] genericTypeArgumentHandles, out RuntimeTypeHandle runtimeTypeHandle);
1720
public abstract int GetThreadStaticsSizeForDynamicType(int index, out int numTlsCells);
1821
public abstract IntPtr GenericLookupFromContextAndSignature(IntPtr context, IntPtr signature, out IntPtr auxResult);
1922
public abstract bool GetRuntimeMethodHandleComponents(RuntimeMethodHandle runtimeMethodHandle, out RuntimeTypeHandle declaringTypeHandle, out MethodNameAndSignature nameAndSignature, out RuntimeTypeHandle[] genericMethodArgs);
23+
public abstract RuntimeMethodHandle GetRuntimeMethodHandleForComponents(RuntimeTypeHandle declaringTypeHandle, string methodName, RuntimeSignature methodSignature, RuntimeTypeHandle[] genericMethodArgs);
2024
public abstract bool CompareMethodSignatures(RuntimeSignature signature1, RuntimeSignature signature2);
2125
#if FEATURE_UNIVERSAL_GENERICS
2226
public abstract IntPtr GetDelegateThunk(Delegate delegateObject, int thunkKind);
2327
#endif
2428
public abstract IntPtr TryGetDefaultConstructorForType(RuntimeTypeHandle runtimeTypeHandle);
2529
public abstract bool TryGetGenericVirtualTargetForTypeAndSlot(RuntimeTypeHandle targetHandle, ref RuntimeTypeHandle declaringType, RuntimeTypeHandle[] genericArguments, ref string methodName, ref RuntimeSignature methodSignature, bool lookForDefaultImplementations, out IntPtr methodPointer, out IntPtr dictionaryPointer, out bool slotUpdated);
2630
public abstract bool GetRuntimeFieldHandleComponents(RuntimeFieldHandle runtimeFieldHandle, out RuntimeTypeHandle declaringTypeHandle, out string fieldName);
31+
public abstract RuntimeFieldHandle GetRuntimeFieldHandleForComponents(RuntimeTypeHandle declaringTypeHandle, string fieldName);
2732
public abstract bool TryGetPointerTypeForTargetType(RuntimeTypeHandle pointeeTypeHandle, out RuntimeTypeHandle pointerTypeHandle);
2833
public abstract bool TryGetArrayTypeForElementType(RuntimeTypeHandle elementTypeHandle, bool isMdArray, int rank, out RuntimeTypeHandle arrayTypeHandle);
2934
public abstract IntPtr UpdateFloatingDictionary(IntPtr context, IntPtr dictionaryPtr);

0 commit comments

Comments
 (0)