forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add implementations for MakePointerType(), MakeArrayType() for Generi…
…cTypeParameterBuilder (dotnet#97350) * Add implementations for MakePointerType(), MakeArrayType() for GenericTypeParameterBuilder * Fix issue in loading constructed generic method, apply feedbacks * Fix valdiations bugs, issue in constructed generic constuctor reference * Fix more issues related to generic method/type validations and reference, add more test and other implementations * Fix bug with setting constant value for a enum field * Add MethodBuilder.GetArrayMethodCore(...) implementation * Fix bug in Array method, MethodOnTypeBuilderInstantiation and ConstructorInfo reference, remove abstract method validation * Fix token issue with nested generic type, add test for derived type returning different type on method override * Apply suggestions from code review Co-authored-by: Aaron Robinson <arobins@microsoft.com> * Use ActiveIssue attribute for failing test on mono, add comment for enum type case * Rename Get***Handle methods into TryGet***Handle --------- Co-authored-by: Aaron Robinson <arobins@microsoft.com>
- Loading branch information
1 parent
d31ce26
commit e87d5d9
Showing
20 changed files
with
932 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ArrayMethod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// 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; | ||
|
||
namespace System.Reflection.Emit | ||
{ | ||
internal sealed class ArrayMethod : MethodInfo | ||
{ | ||
#region Private Data Members | ||
private readonly ModuleBuilder _module; | ||
private readonly Type _containingType; | ||
private readonly string _name; | ||
private readonly CallingConventions _callingConvention; | ||
private readonly Type _returnType; | ||
private readonly Type[] _parameterTypes; | ||
#endregion | ||
|
||
#region Constructor | ||
// This is a kind of MethodInfo to represent methods for array type of unbaked type | ||
internal ArrayMethod(ModuleBuilder module, Type arrayClass, string methodName, | ||
CallingConventions callingConvention, Type? returnType, Type[]? parameterTypes) | ||
{ | ||
_returnType = returnType ?? typeof(void); | ||
if (parameterTypes != null) | ||
{ | ||
_parameterTypes = new Type[parameterTypes.Length]; | ||
for (int i = 0; i < parameterTypes.Length; i++) | ||
{ | ||
ArgumentNullException.ThrowIfNull(_parameterTypes[i] = parameterTypes[i], nameof(parameterTypes)); | ||
} | ||
} | ||
else | ||
{ | ||
_parameterTypes = Type.EmptyTypes; | ||
} | ||
|
||
_module = module; | ||
_containingType = arrayClass; | ||
_name = methodName; | ||
_callingConvention = callingConvention; | ||
} | ||
#endregion | ||
|
||
#region Internal Members | ||
internal Type[] ParameterTypes => _parameterTypes; | ||
#endregion | ||
|
||
#region MemberInfo Overrides | ||
public override Module Module => _module; | ||
|
||
public override Type? ReflectedType => _containingType; | ||
|
||
public override string Name => _name; | ||
|
||
public override Type? DeclaringType => _containingType; | ||
#endregion | ||
|
||
#region MethodBase Overrides | ||
public override ParameterInfo[] GetParameters() => throw new NotSupportedException(SR.NotSupported_SymbolMethod); | ||
|
||
public override MethodImplAttributes GetMethodImplementationFlags() => throw new NotSupportedException(SR.NotSupported_SymbolMethod); | ||
|
||
public override MethodAttributes Attributes => MethodAttributes.PrivateScope; | ||
|
||
public override CallingConventions CallingConvention => _callingConvention; | ||
|
||
public override RuntimeMethodHandle MethodHandle => throw new NotSupportedException(SR.NotSupported_SymbolMethod); | ||
#endregion | ||
|
||
#region MethodInfo Overrides | ||
public override Type ReturnType => _returnType; | ||
|
||
public override ICustomAttributeProvider ReturnTypeCustomAttributes => throw new NotSupportedException(SR.NotSupported_SymbolMethod); | ||
|
||
public override object Invoke(object? obj, BindingFlags invokeAttr, Binder? binder, object?[]? parameters, CultureInfo? culture) | ||
=> throw new NotSupportedException(SR.NotSupported_SymbolMethod); | ||
|
||
public override MethodInfo GetBaseDefinition() => this; | ||
#endregion | ||
|
||
#region ICustomAttributeProvider Implementation | ||
public override object[] GetCustomAttributes(bool inherit) => throw new NotSupportedException(SR.NotSupported_SymbolMethod); | ||
|
||
public override object[] GetCustomAttributes(Type attributeType, bool inherit) => throw new NotSupportedException(SR.NotSupported_SymbolMethod); | ||
|
||
public override bool IsDefined(Type attributeType, bool inherit) => throw new NotSupportedException(SR.NotSupported_SymbolMethod); | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.