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)
4141 // get constructor
4242 ConstructorInfo ctor = objectType . GetConstructor ( new Type [ ] { paramType } ) ;
4343
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+
4468 // invoke constructor with the parameter
45- attributes [ i / 2 ] = ctor . Invoke ( new object [ ] { rawAttributes [ i + 1 ] } ) ;
69+ attributes [ i / 2 ] = ctor . Invoke ( ctorParams ) ;
4670 }
4771 }
4872
You can’t perform that action at this time.
0 commit comments