Bug 29916

Summary: System.Reflection.ParameterInfo.GetCustomAttributes always throws NullReference exception.
Product: [Mono] Class Libraries Reporter: sornakumar
Component: mscorlibAssignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: masafa, mono-bugs+monomac, mono-bugs+mono
Priority: ---    
Version: unspecified   
Target Milestone: Untriaged   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description sornakumar 2015-05-10 12:53:07 UTC
Whenever I try to do something like,

foreach (var parameter in methodInfo.GetParameters())
{
  // ...
  var attrs = parameter.GetCustomAttributes();
  // ...
}

I get the following exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: attributeType
  at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) <0x1b25450 + 0x007f0> in <filename unknown>:0 
  at System.Reflection.MonoParameterInfo.GetCustomAttributes (System.Type attributeType, Boolean inherit) <0x1a14e60 + 0x0002c> in <filename unknown>:0 
  at System.Attribute.InternalParamGetCustomAttributes (System.Reflection.ParameterInfo parameter, System.Type attributeType, Boolean inherit) <0x17854c0 + 0x000b5> in <filename unknown>:0 
  at System.Attribute.GetCustomAttributes (System.Reflection.ParameterInfo element, Boolean inherit) <0x1786380 + 0x00081> in <filename unknown>:0 
  at System.Attribute.GetCustomAttributes (System.Reflection.ParameterInfo element) <0x1786120 + 0x00025> in <filename unknown>:0 
  at System.Reflection.CustomAttributeExtensions.GetCustomAttributes (System.Reflection.ParameterInfo element) <0x185ded0 + 0x0001d> in <filename unknown>:0 
  at MethodInfoExample.Program.Main () <0x780ec0 + 0x000a3> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null.
Parameter name: attributeType
  at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) <0x1b25450 + 0x007f0> in <filename unknown>:0 
  at System.Reflection.MonoParameterInfo.GetCustomAttributes (System.Type attributeType, Boolean inherit) <0x1a14e60 + 0x0002c> in <filename unknown>:0 
  at System.Attribute.InternalParamGetCustomAttributes (System.Reflection.ParameterInfo parameter, System.Type attributeType, Boolean inherit) <0x17854c0 + 0x000b5> in <filename unknown>:0 
  at System.Attribute.GetCustomAttributes (System.Reflection.ParameterInfo element, Boolean inherit) <0x1786380 + 0x00081> in <filename unknown>:0 
  at System.Attribute.GetCustomAttributes (System.Reflection.ParameterInfo element) <0x1786120 + 0x00025> in <filename unknown>:0 
  at System.Reflection.CustomAttributeExtensions.GetCustomAttributes (System.Reflection.ParameterInfo element) <0x185ded0 + 0x0001d> in <filename unknown>:0 
  at MethodInfoExample.Program.Main () <0x780ec0 + 0x000a3> in <filename unknown>:0
Comment 1 Marek Safar 2015-05-12 10:30:17 UTC
Fixed in master