-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 Type.GetMethod overload that takes Name, BindingFlags, and Parameter Types #42753
Labels
Milestone
Comments
eerhardt
added
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-System.Reflection
labels
Sep 25, 2020
Dotnet-GitSync-Bot
added
the
untriaged
New issue has not been triaged by the area owner
label
Sep 25, 2020
Seems like a reasonable request. |
eerhardt
added
api-ready-for-review
API is ready for review, it is NOT ready for implementation
and removed
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
labels
Nov 9, 2020
Looks good as proposed namespace System
{
public partial class Type
{
public System.Reflection.MethodInfo? GetMethod(string name, System.Reflection.BindingFlags bindingAttr, System.Type[] types) { throw null; }
public System.Reflection.ConstructorInfo? GetConstructor(System.Reflection.BindingFlags bindingAttr, System.Type[] types) { throw null; }
}
} |
bartonjs
added
api-approved
API was approved in API review, it can be implemented
and removed
api-ready-for-review
API is ready for review, it is NOT ready for implementation
labels
Nov 10, 2020
eerhardt
added a commit
to eerhardt/linker
that referenced
this issue
Nov 10, 2020
With dotnet/runtime#42753, we are adding a new overload to Type.GetConstructor that only takes BindingFlags and Type[]. However, this new overload exposes a bug in the ILLinker where it is using the wrong parameter count to find how many constructor parameters are being used. Fixing the issue by using the correct parameter count in the switch statement.
vitek-karas
pushed a commit
to dotnet/linker
that referenced
this issue
Nov 10, 2020
With dotnet/runtime#42753, we are adding a new overload to Type.GetConstructor that only takes BindingFlags and Type[]. However, this new overload exposes a bug in the ILLinker where it is using the wrong parameter count to find how many constructor parameters are being used. Fixing the issue by using the correct parameter count in the switch statement.
eerhardt
added a commit
to eerhardt/runtime
that referenced
this issue
Nov 11, 2020
…ter Types Adding overloads to GetConstructor and GetMethod that don't take a Binder or parameter modifiers. Fix dotnet#42753
ghost
locked as resolved and limited conversation to collaborators
Dec 12, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Background and Motivation
When trying to specify which method you want to find in Reflection, often you want to supply a name, BindingFlags, and parameter Types. However, there is no overload today that takes those 3 inputs, and only those 3 inputs. Similarly, when trying to find a constructor,
GetConstructor
has no overload that just takes BindingFlags and parameter Types.Proposed API
Usage Examples
We already have extensions for these today in DataContractSerialization, with it's own implementations:
runtime/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatGeneratorStatics.cs
Line 48 in e17d818
runtime/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatGeneratorStatics.cs
Line 617 in e17d818
runtime/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs
Line 444 in 4c3d759
Alternative Designs
We could just tell people to call
Type.GetMethod(string, BindingFlags, null, Type[], null)
themselves. But that seems too verbose.Risks
None
cc @steveharter @GrabYourPitchforks
The text was updated successfully, but these errors were encountered: