File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
nanoFramework.CoreLibrary/System/Reflection Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -41,8 +41,32 @@ public static object[] GetCustomAttributesInternal(object[] rawAttributes)
41
41
// get constructor
42
42
ConstructorInfo ctor = objectType . GetConstructor ( new Type [ ] { paramType } ) ;
43
43
44
+ // get params
45
+ object [ ] ctorParams = new object [ ] { rawAttributes [ i + 1 ] } ;
46
+
47
+ if ( ctor is null )
48
+ {
49
+ // give it another try, this time with an array of the parameters types
50
+ // rebuild params list
51
+ ctorParams = ( object [ ] ) rawAttributes [ i + 1 ] ;
52
+
53
+ Type [ ] paramsTypes = new Type [ ctorParams . Length ] ;
54
+
55
+ for ( int p = 0 ; p < ctorParams . Length ; p ++ )
56
+ {
57
+ paramsTypes [ p ] = ctorParams [ p ] . GetType ( ) ;
58
+ }
59
+
60
+ ctor = objectType . GetConstructor ( paramsTypes ) ;
61
+
62
+ if ( ctor is null )
63
+ {
64
+ throw new InvalidOperationException ( ) ;
65
+ }
66
+ }
67
+
44
68
// invoke constructor with the parameter
45
- attributes [ i / 2 ] = ctor . Invoke ( new object [ ] { rawAttributes [ i + 1 ] } ) ;
69
+ attributes [ i / 2 ] = ctor . Invoke ( ctorParams ) ;
46
70
}
47
71
}
48
72
You can’t perform that action at this time.
0 commit comments