-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add implementations for MakePointerType(), MakeArrayType() for GenericTypeParameterBuilder #97350
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9365155
Add implementations for MakePointerType(), MakeArrayType() for Generi…
buyaa-n 456dac8
Fix issue in loading constructed generic method, apply feedbacks
buyaa-n 5143dc6
Fix valdiations bugs, issue in constructed generic constuctor reference
buyaa-n eccf74e
Merge branch 'main' of github.com:dotnet/runtime into generic_pointer
buyaa-n d07377c
Fix more issues related to generic method/type validations and refere…
buyaa-n 11b7abf
Apply feedbacks
buyaa-n 20fc24d
Fix bug with setting constant value for a enum field
buyaa-n d11e06c
Add MethodBuilder.GetArrayMethodCore(...) implementation
buyaa-n 80acc53
Fix bug in Array method, MethodOnTypeBuilderInstantiation and Constru…
buyaa-n 184f85e
Fix token issue with nested generic type, add test for derived type r…
buyaa-n 256b3a2
Apply suggestions from code review
buyaa-n d68d676
Use ActiveIssue attribute for failing test on mono, add comment for e…
buyaa-n 199b124
Apply feedbacks
buyaa-n 3738891
Added comment was not saved with previous commit
buyaa-n 62edee7
Rename Get***Handle methods into TryGet***Handle
buyaa-n File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)); | ||
buyaa-n marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This defers to
_method.IsGenericMethod
, which seems close to_method.ContainsGenericParameters
. Does the latter inform the former?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No,
_method.ContainsGenericParameters
could be true when method is not generic, but the containing type has any open generic parameter.