Skip to content

Fold System.Private.Reflection.Core into CoreLib #70545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/coreclr/dlls/mscorrc/mscorrc.rc
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ BEGIN
IDS_EE_SIZECONTROLBADTYPE "Array size control parameter type not supported."
IDS_EE_SAFEARRAYSZARRAYMISMATCH "SafeArray cannot be marshaled to this array type because it has either nonzero lower bounds or more than one dimension."

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

IDS_EE_FILELOAD_ERROR_GENERIC "Could not load file or assembly '%1'. %2"
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/dlls/mscorrc/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@

#define IDS_CLASSLOAD_OVERLAPPING_INTERFACES 0x1a80
#define IDS_CLASSLOAD_32BITCLRLOADING64BITASSEMBLY 0x1a81
#define IDS_EE_ASSEMBLY_GETTYPE_CANNONT_HAVE_ASSEMBLY_SPEC 0x1a84

#define IDS_EE_NEEDS_ASSEMBLY_SPEC 0x1a87

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ The .NET Foundation licenses this file to you under the MIT license.
</ItemGroup>

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

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

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

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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace System.Runtime.CompilerServices
{
[DeveloperExperienceModeOnly]
internal static class DeveloperExperienceState
{
public static bool DeveloperExperienceModeEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
<method signature="System.Boolean get_SupportsGenericIEquatableInterfaces()" body="stub" value="true" />
</type>

<type fullname="System.Reflection.Runtime.General.TypeUnifier" feature="System.Reflection.IsTypeConstructionEagerlyValidated" featurevalue="false">
<method signature="System.Boolean get_IsTypeConstructionEagerlyValidated()" body="stub" />
</type>
</linker>
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
using System.Reflection;
using Internal.Metadata.NativeFormat;
using System.Reflection.Runtime.General;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Internal.Reflection.Core
{
// Auto StructLayout used to suppress warning that order of fields is not guaranteed in partial structs
[StructLayout(LayoutKind.Auto)]
[ReflectionBlocked]
[CLSCompliant(false)]
public partial struct AssemblyBindResult
{
public MetadataReader Reader;
Expand All @@ -25,6 +28,8 @@ public partial struct AssemblyBindResult
//
// If the binder cannot locate an assembly, it must return null and set "exception" to an exception object.
//
[ReflectionBlocked]
[CLSCompliant(false)]
public abstract class AssemblyBinder
{
public const string DefaultAssemblyNameForGetType = "System.Private.CoreLib";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#endif
using System.Reflection.Runtime.TypeParsing;
using System.Reflection.Runtime.CustomAttributes;
using System.Runtime.CompilerServices;
using Internal.Metadata.NativeFormat;
using Internal.Runtime.Augments;

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

if (methodHandle.IsNativeFormatMetadataBased)
{
Expand Down Expand Up @@ -218,7 +221,7 @@ public Type GetArrayTypeForHandle(RuntimeTypeHandle typeHandle)
{
RuntimeTypeHandle elementTypeHandle;
if (!ExecutionEnvironment.TryGetArrayTypeElementType(typeHandle, out elementTypeHandle))
throw CreateMissingMetadataException((Type)null);
throw CreateMissingMetadataException((Type?)null);

return elementTypeHandle.GetTypeForRuntimeTypeHandle().GetArrayType(typeHandle);
}
Expand All @@ -227,7 +230,7 @@ public Type GetMdArrayTypeForHandle(RuntimeTypeHandle typeHandle, int rank)
{
RuntimeTypeHandle elementTypeHandle;
if (!ExecutionEnvironment.TryGetArrayTypeElementType(typeHandle, out elementTypeHandle))
throw CreateMissingMetadataException((Type)null);
throw CreateMissingMetadataException((Type?)null);

return elementTypeHandle.GetTypeForRuntimeTypeHandle().GetMultiDimArrayType(rank, typeHandle);
}
Expand All @@ -236,7 +239,7 @@ public Type GetPointerTypeForHandle(RuntimeTypeHandle typeHandle)
{
RuntimeTypeHandle targetTypeHandle;
if (!ExecutionEnvironment.TryGetPointerTypeTargetType(typeHandle, out targetTypeHandle))
throw CreateMissingMetadataException((Type)null);
throw CreateMissingMetadataException((Type?)null);

return targetTypeHandle.GetTypeForRuntimeTypeHandle().GetPointerType(typeHandle);
}
Expand All @@ -245,7 +248,7 @@ public Type GetByRefTypeForHandle(RuntimeTypeHandle typeHandle)
{
RuntimeTypeHandle targetTypeHandle;
if (!ExecutionEnvironment.TryGetByRefTypeTargetType(typeHandle, out targetTypeHandle))
throw CreateMissingMetadataException((Type)null);
throw CreateMissingMetadataException((Type?)null);

return targetTypeHandle.GetTypeForRuntimeTypeHandle().GetByRefType(typeHandle);
}
Expand Down Expand Up @@ -284,12 +287,12 @@ public Type GetConstructedGenericTypeForHandle(RuntimeTypeHandle typeHandle)
//=======================================================================================
// MissingMetadataExceptions.
//=======================================================================================
public Exception CreateMissingMetadataException(Type pertainant)
public Exception CreateMissingMetadataException(Type? pertainant)
{
return this.ReflectionDomainSetup.CreateMissingMetadataException(pertainant);
}

public Exception CreateMissingMetadataException(TypeInfo pertainant)
public Exception CreateMissingMetadataException(TypeInfo? pertainant)
{
return this.ReflectionDomainSetup.CreateMissingMetadataException(pertainant);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Reflection.Runtime.General;
using System.Reflection.Runtime.TypeInfos;
using System.Runtime.CompilerServices;
using Internal.Metadata.NativeFormat;

using OpenMethodInvoker = System.Reflection.Runtime.MethodInfos.OpenMethodInvoker;
Expand All @@ -19,6 +20,8 @@ namespace Internal.Reflection.Core.Execution
// This class abstracts the underlying Redhawk (or whatever execution engine) runtime and exposes the services
// that I.R.Core.Execution needs.
//
[ReflectionBlocked]
[CLSCompliant(false)]
public abstract class ExecutionEnvironment
{
//==============================================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace Internal.Reflection.Core.Execution
{
//
// This class abstracts the underlying Redhawk (or whatever execution engine) runtime that sets and gets fields.
//
[ReflectionBlocked]
[CLSCompliant(false)]
public abstract class FieldAccessor
{
protected FieldAccessor() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Diagnostics;
using System.Globalization;
using System.Reflection.Runtime.General;
using System.Runtime.CompilerServices;

using Internal.Runtime.Augments;

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

[DebuggerGuidedStepThrough]
public object Invoke(object thisObject, object[] arguments, Binder binder, BindingFlags invokeAttr, CultureInfo cultureInfo)
public object? Invoke(object thisObject, object?[] arguments, Binder? binder, BindingFlags invokeAttr, CultureInfo? cultureInfo)
{
BinderBundle binderBundle = binder.ToBinderBundle(invokeAttr, cultureInfo);
bool wrapInTargetInvocationException = (invokeAttr & BindingFlags.DoNotWrapExceptions) == 0;
object result = Invoke(thisObject, arguments, binderBundle, wrapInTargetInvocationException);
object? result = Invoke(thisObject, arguments, binderBundle, wrapInTargetInvocationException);
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
return result;
}
protected abstract object Invoke(object thisObject, object[] arguments, BinderBundle binderBundle, bool wrapInTargetInvocationException);
protected abstract object? Invoke(object? thisObject, object?[] arguments, BinderBundle binderBundle, bool wrapInTargetInvocationException);
public abstract Delegate CreateDelegate(RuntimeTypeHandle delegateType, object target, bool isStatic, bool isVirtual, bool isOpen);

// This property is used to retrieve the target method pointer. It is used by the RuntimeMethodHandle.GetFunctionPointer API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
using System.Reflection;
using System.Collections.Generic;
using System.Reflection.Runtime.General;
using System.Runtime.CompilerServices;

using Internal.LowLevelLinq;
using Internal.Reflection.Augments;
using Internal.Reflection.Core.Execution;

namespace Internal.Reflection.Core.Execution
{
[ReflectionBlocked]
[CLSCompliant(false)]
public static class ReflectionCoreExecution
{
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
using System;
using System.Reflection;
using System.Reflection.Runtime.General;
using System.Runtime.CompilerServices;

namespace Internal.Reflection.Core
{
[ReflectionBlocked]
[CLSCompliant(false)]
public abstract class ReflectionDomainSetup
{
protected ReflectionDomainSetup() { }
public abstract AssemblyBinder AssemblyBinder { get; }
public abstract Exception CreateMissingMetadataException(TypeInfo pertainant);
public abstract Exception CreateMissingMetadataException(Type pertainant);
public abstract Exception CreateMissingMetadataException(TypeInfo? pertainant);
public abstract Exception CreateMissingMetadataException(Type? pertainant);
public abstract Exception CreateMissingMetadataException(TypeInfo pertainant, string nestedTypeName);
public abstract Exception CreateNonInvokabilityException(MemberInfo pertainant);
public abstract Exception CreateMissingArrayTypeException(Type elementType, bool isMultiDim, int rank);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@
using System.Collections.Generic;

using Internal.Runtime.CompilerServices;
using Internal.NativeFormat;
using Internal.Metadata.NativeFormat;

namespace Internal.Runtime.Augments
{
[CLSCompliant(false)]
[System.Runtime.CompilerServices.ReflectionBlocked]
public abstract class TypeLoaderCallbacks
{
public abstract TypeManagerHandle GetModuleForMetadataReader(MetadataReader reader);
public abstract bool TryGetConstructedGenericTypeForComponents(RuntimeTypeHandle genericTypeDefinitionHandle, RuntimeTypeHandle[] genericTypeArgumentHandles, out RuntimeTypeHandle runtimeTypeHandle);
public abstract int GetThreadStaticsSizeForDynamicType(int index, out int numTlsCells);
public abstract IntPtr GenericLookupFromContextAndSignature(IntPtr context, IntPtr signature, out IntPtr auxResult);
public abstract bool GetRuntimeMethodHandleComponents(RuntimeMethodHandle runtimeMethodHandle, out RuntimeTypeHandle declaringTypeHandle, out MethodNameAndSignature nameAndSignature, out RuntimeTypeHandle[] genericMethodArgs);
public abstract RuntimeMethodHandle GetRuntimeMethodHandleForComponents(RuntimeTypeHandle declaringTypeHandle, string methodName, RuntimeSignature methodSignature, RuntimeTypeHandle[] genericMethodArgs);
public abstract bool CompareMethodSignatures(RuntimeSignature signature1, RuntimeSignature signature2);
#if FEATURE_UNIVERSAL_GENERICS
public abstract IntPtr GetDelegateThunk(Delegate delegateObject, int thunkKind);
#endif
public abstract IntPtr TryGetDefaultConstructorForType(RuntimeTypeHandle runtimeTypeHandle);
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);
public abstract bool GetRuntimeFieldHandleComponents(RuntimeFieldHandle runtimeFieldHandle, out RuntimeTypeHandle declaringTypeHandle, out string fieldName);
public abstract RuntimeFieldHandle GetRuntimeFieldHandleForComponents(RuntimeTypeHandle declaringTypeHandle, string fieldName);
public abstract bool TryGetPointerTypeForTargetType(RuntimeTypeHandle pointeeTypeHandle, out RuntimeTypeHandle pointerTypeHandle);
public abstract bool TryGetArrayTypeForElementType(RuntimeTypeHandle elementTypeHandle, bool isMdArray, int rank, out RuntimeTypeHandle arrayTypeHandle);
public abstract IntPtr UpdateFloatingDictionary(IntPtr context, IntPtr dictionaryPtr);
Expand Down
Loading