diff options
Diffstat (limited to 'src/System.Private.Reflection.Core/src')
10 files changed, 37 insertions, 30 deletions
diff --git a/src/System.Private.Reflection.Core/src/Resources/Strings.resx b/src/System.Private.Reflection.Core/src/Resources/Strings.resx index 4d7615699..820a41e26 100644 --- a/src/System.Private.Reflection.Core/src/Resources/Strings.resx +++ b/src/System.Private.Reflection.Core/src/Resources/Strings.resx @@ -150,18 +150,12 @@ <data name="TypeLoad_TypeNotFoundInAssembly" xml:space="preserve"> <value>The type '{0}' cannot be found in assembly '{1}'.</value> </data> - <data name="TypeLoad_BadEscape" xml:space="preserve"> - <value>An invalid escape sequence was found inside a type name.</value> - </data> <data name="FileNotFound_AssemblyNotFound" xml:space="preserve"> <value>Cannot load assembly '{0}'. No metadata found for this assembly.</value> </data> <data name="Arg_HTCapacityOverflow" xml:space="preserve"> <value>Hashtable's capacity overflowed and went negative. Check load factor, capacity and the current size of the table.</value> </data> - <data name="NotSupported_ByRefReturn" xml:space="preserve"> - <value>ByRef return value not supported in reflection invocation.</value> - </data> <data name="Arg_DlgtTargMeth" xml:space="preserve"> <value>Cannot bind to the target method because its signature is not compatible with that of the delegate type.</value> </data> @@ -228,9 +222,6 @@ <data name="Arg_SetMethNotFnd" xml:space="preserve"> <value>Property set method not found.</value> </data> - <data name="TypeIsNotReflectable" xml:space="preserve"> - <value>Type instance is not IReflectable.</value> - </data> <data name="Arg_EmptyArray" xml:space="preserve"> <value>Array may not be empty.</value> </data> @@ -246,12 +237,6 @@ <data name="NoMetadataTokenAvailable" xml:space="preserve"> <value>There is no metadata token available for the given member.</value> </data> - <data name="ModuleVersionIdNotSupported" xml:space="preserve"> - <value>Module version IDs (MVIDs) cannot be retrieved on this platform.</value> - </data> - <data name="FileNotFound_ResolveAssembly" xml:space="preserve"> - <value>Could not resolve assembly '{0}'.</value> - </data> <data name="MissingField" xml:space="preserve"> <value>Field not found.</value> </data> @@ -286,18 +271,12 @@ <data name="Arg_NamedParamTooBig" xml:space="preserve"> <value>Named parameter array cannot be bigger than argument array.</value> </data> - <data name="Arg_COMAccess" xml:space="preserve"> - <value>Must specify property Set or Get or method call for a COM Object.</value> - </data> <data name="Arg_PropSetGet" xml:space="preserve"> <value>Cannot specify both Get and Set on a property.</value> </data> <data name="Arg_PropSetInvoke" xml:space="preserve"> <value>Cannot specify Set on a property and Invoke on a method.</value> </data> - <data name="Arg_COMPropSetPut" xml:space="preserve"> - <value>Only one of the following binding flags can be set: BindingFlags.SetProperty, BindingFlags.PutDispProperty, BindingFlags.PutRefDispProperty.</value> - </data> <data name="Arg_NamedParamNull" xml:space="preserve"> <value>Named parameter value must not be null.</value> </data> diff --git a/src/System.Private.Reflection.Core/src/System.Private.Reflection.Core.Experimental.csproj b/src/System.Private.Reflection.Core/src/System.Private.Reflection.Core.Experimental.csproj index 75f14057a..2cc7b4b44 100644 --- a/src/System.Private.Reflection.Core/src/System.Private.Reflection.Core.Experimental.csproj +++ b/src/System.Private.Reflection.Core/src/System.Private.Reflection.Core.Experimental.csproj @@ -2,7 +2,7 @@ <PropertyGroup> <AssemblyName>System.Private.Reflection.Core.Experimental</AssemblyName> <EcmaMetadataSupport>true</EcmaMetadataSupport> - <JitSupport>true</JitSupport> + <DynamicCodeSupport>true</DynamicCodeSupport> </PropertyGroup> <Import Project="System.Private.Reflection.Core.csproj" /> diff --git a/src/System.Private.Reflection.Core/src/System.Private.Reflection.Core.csproj b/src/System.Private.Reflection.Core/src/System.Private.Reflection.Core.csproj index 696f74096..014a80f7f 100644 --- a/src/System.Private.Reflection.Core/src/System.Private.Reflection.Core.csproj +++ b/src/System.Private.Reflection.Core/src/System.Private.Reflection.Core.csproj @@ -24,14 +24,15 @@ <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties> </ProjectReference> <ProjectReference Include="..\..\System.Private.CoreLib\src\System.Private.CoreLib.csproj" /> - <ProjectReference Include="..\..\System.Private.Interop\src\System.Private.Interop.csproj" /> <ProjectReference Include="..\..\System.Private.Reflection.Metadata\src\System.Private.Reflection.Metadata.csproj" /> </ItemGroup> <ItemGroup Condition="'$(IsProjectNLibrary)' != 'true' and '$(EcmaMetadataSupport)' != 'true'"> <ProjectReference Include="..\..\System.Private.TypeLoader\src\System.Private.TypeLoader.csproj" /> + <ProjectReference Include="..\..\System.Private.Interop\src\System.Private.Interop.csproj" /> </ItemGroup> <ItemGroup Condition="'$(IsProjectNLibrary)' != 'true' and '$(EcmaMetadataSupport)' == 'true'"> <ProjectReference Include="..\..\System.Private.TypeLoader\src\System.Private.TypeLoader.Experimental.csproj" /> + <ProjectReference Include="..\..\System.Private.Interop\src\System.Private.Interop.Experimental.csproj" /> <ReferencePath Include="$(AotPackageReferencePath)\System.Private.Reflection.Metadata.Ecma335.dll" /> </ItemGroup> <ItemGroup Condition="'$(EcmaMetadataSupport)' == 'true'"> diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/BindingFlagSupport/QueriedMemberList.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/BindingFlagSupport/QueriedMemberList.cs index c8e7d3a23..2da7ffe58 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/BindingFlagSupport/QueriedMemberList.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/BindingFlagSupport/QueriedMemberList.cs @@ -30,13 +30,13 @@ namespace System.Reflection.Runtime.BindingFlagSupport _allFlagsThatMustMatch = new BindingFlags[Grow]; } - private QueriedMemberList(int totalCount, int declaredOnlyCount, M[] members, BindingFlags[] allFlagsThatMustMatch, RuntimeTypeInfo typeThatBlockedBrowing) + private QueriedMemberList(int totalCount, int declaredOnlyCount, M[] members, BindingFlags[] allFlagsThatMustMatch, RuntimeTypeInfo typeThatBlockedBrowsing) { _totalCount = totalCount; _declaredOnlyCount = declaredOnlyCount; _members = members; _allFlagsThatMustMatch = allFlagsThatMustMatch; - _typeThatBlockedBrowsing = typeThatBlockedBrowing; + _typeThatBlockedBrowsing = typeThatBlockedBrowsing; } /// <summary> diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/Dispensers.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/Dispensers.cs index 79eca8868..90d5f4803 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/Dispensers.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/Dispensers.cs @@ -97,7 +97,7 @@ namespace System.Reflection.Runtime.Assemblies AssemblyBinder binder = ReflectionCoreExecution.ExecutionDomain.ReflectionDomainSetup.AssemblyBinder; AssemblyBindResult bindResult; Exception exception; - if (!binder.Bind(assemblyRefName, out bindResult, out exception)) + if (!binder.Bind(assemblyRefName, cacheMissedLookups: true, out bindResult, out exception)) return exception; return GetRuntimeAssembly(bindResult); diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/EcmaFormat/DefaultValueProcessing.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/EcmaFormat/DefaultValueProcessing.cs index 50196d699..70b020393 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/EcmaFormat/DefaultValueProcessing.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/EcmaFormat/DefaultValueProcessing.cs @@ -60,7 +60,7 @@ namespace System.Reflection.Runtime.General.EcmaFormat private static object ConstantValueAsObject(ConstantHandle constantHandle, MetadataReader metadataReader, Type declaredType, bool raw) { object defaultValue = ConstantValueAsRawObject(constantHandle, metadataReader); - if ((!raw) && declaredType.IsEnum) + if ((!raw) && declaredType.IsEnum && defaultValue != null) defaultValue = Enum.ToObject(declaredType, defaultValue); return defaultValue; } diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/MetadataReaderExtensions.NativeFormat.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/MetadataReaderExtensions.NativeFormat.cs index 901d0f4ba..5896aa812 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/MetadataReaderExtensions.NativeFormat.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/MetadataReaderExtensions.NativeFormat.cs @@ -162,6 +162,24 @@ namespace System.Reflection.Runtime.General return customModifiers.ToArray(); } + public static Handle SkipCustomModifiers(this Handle handle, MetadataReader reader) + { + HandleType handleType = handle.HandleType; + Debug.Assert(handleType == HandleType.TypeDefinition || handleType == HandleType.TypeReference || handleType == HandleType.TypeSpecification || handleType == HandleType.ModifiedType); + if (handleType != HandleType.ModifiedType) + return handle; + + do + { + ModifiedType modifiedType = handle.ToModifiedTypeHandle(reader).GetModifiedType(reader); + handle = modifiedType.Type; + handleType = handle.HandleType; + } + while (handleType == HandleType.ModifiedType); + + return handle; + } + public static MethodSignature ParseMethodSignature(this Handle handle, MetadataReader reader) { return handle.ToMethodSignatureHandle(reader).GetMethodSignature(reader); diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/NativeFormat/DefaultValueParser.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/NativeFormat/DefaultValueParser.cs index e76be1914..244d351ad 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/NativeFormat/DefaultValueParser.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/NativeFormat/DefaultValueParser.cs @@ -14,7 +14,7 @@ namespace System.Reflection.Runtime.General.NativeFormat if (!(constantHandle.IsNull(reader))) { defaultValue = constantHandle.ParseConstantValue(reader); - if ((!raw) && declaredType.IsEnum) + if ((!raw) && declaredType.IsEnum && defaultValue != null) defaultValue = Enum.ToObject(declaredType, defaultValue); return true; } diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/RuntimeMethodInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/RuntimeMethodInfo.cs index 33d73b16a..4af12bfc9 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/RuntimeMethodInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/RuntimeMethodInfo.cs @@ -354,7 +354,12 @@ namespace System.Reflection.Runtime.MethodInfos if (methodInvoker == null) { if (ReturnType.IsByRef) - throw new NotSupportedException(SR.NotSupported_ByRefReturn); + { + // The invoker is going to dereference and box (for structs) the result of the invocation + // on behalf of the caller. Can't box byref-like types and can't box void. + if (ReturnType.GetElementType().IsByRefLike || ReturnType.GetElementType() == CommonRuntimeTypes.Void) + throw new NotSupportedException(); + } methodInvoker = _lazyMethodInvoker = this.UncachedMethodInvoker; } return methodInvoker; diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeGenericParameterTypeInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeGenericParameterTypeInfo.cs index 678577135..f027f9caa 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeGenericParameterTypeInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeGenericParameterTypeInfo.cs @@ -81,7 +81,11 @@ namespace System.Reflection.Runtime.TypeInfos.NativeFormat LowLevelList<QTypeDefRefOrSpec> constraints = new LowLevelList<QTypeDefRefOrSpec>(); foreach (Handle constraintHandle in _genericParameter.Constraints) { - constraints.Add(new QTypeDefRefOrSpec(reader, constraintHandle)); + // We're skipping custom modifiers here because Roslyn generates + // a modifier for the "unmanaged" constraint. This doesn't conform to the + // ECMA-335 spec, but we need to deal with it. The modifier is not visible + // to reflection. + constraints.Add(new QTypeDefRefOrSpec(reader, constraintHandle.SkipCustomModifiers(reader))); } return constraints.ToArray(); } |