Skip to content
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

MethodInfo.ReturnParameter.IsDefined(type) throws IndexOutOfRangeException #12069

Closed
StevenBonePgh opened this issue Dec 14, 2018 · 2 comments
Assignees

Comments

@StevenBonePgh
Copy link

@StevenBonePgh StevenBonePgh commented Dec 14, 2018

Steps to Reproduce

  1. MethodInfo.ReturnParameter.IsDefined(type) throws IndexOutOfRangeException
Type type = typeof(object);
MethodInfo method = type.GetMethod("ToString");
ParameterInfo paramInfo = method.ReturnParameter;
bool defined = paramInfo.IsDefined(typeof(Attribute)); //throws

Current Behavior

Exception thrown: {System.IndexOutOfRangeException} "Index was outside the bounds of the array."

Expected Behavior

For the sample above, defined should be false.

On which platforms did you notice this

[ ] macOS
[X] Linux
[ ] Windows

Version Used:
Xamarin.Android SDK 9.0.0.19 (HEAD/a8a3b0ec7)
via Xamarin.Forms

Also reported here: xamarin/xamarin-android#2175 on Sept 11, 2018

Stacktrace

{System.IndexOutOfRangeException} "Index was outside the bounds of the array."
  at System.Attribute.InternalParamIsDefined (System.Reflection.ParameterInfo parameter, System.Type attributeType, System.Boolean inherit) [0x0003b] in <43dbbdc147f2482093d8409abb04c233>:0 
  at System.Attribute.IsDefined (System.Reflection.ParameterInfo element, System.Type attributeType, System.Boolean inherit) [0x00071] in <43dbbdc147f2482093d8409abb04c233>:0 
  at System.Attribute.IsDefined (System.Reflection.ParameterInfo element, System.Type attributeType) [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0 
  at System.Reflection.CustomAttributeExtensions.IsDefined (System.Reflection.ParameterInfo element, System.Type attributeType) [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0 
@marek-safar

This comment has been minimized.

Copy link
Member

@marek-safar marek-safar commented Dec 17, 2018

@MaximLipnin could you check if this is still the case

@MaximLipnin

This comment has been minimized.

Copy link
Collaborator

@MaximLipnin MaximLipnin commented Dec 17, 2018

I have a repro in Mono 5.23.0 (d42d675b81d) and 5.16.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.