c# - How do I know that a parameter uses ref or params modifier? -


in mono.cecil, parameterdefinition of out parameter has property isout set true.

what ref , params? how determine, parameterdefinition, 1 of modifiers used method parameter?

while parameterdefinition doesn't contain isref or isparams, it's easy determine both 2 other properties.

when parameter contains ref modifier, value of parameterdefinition.parametertype.isbyreference true. otherwise, false, if actual parameter reference type.

as params, customattributes collection contains element corresponding system.paramarrayattribute.

the following piece of code illustrates how determine 4 states:

using system; using system.linq; using mono.cecil;  ...  if (definition.isout) {     // there `out` modifier. } else if (definition.parametertype.isbyreference) {     // there `ref` modifier. } else if (definition.customattributes.any(attribute =>      attribute.attributetype.fullname == typeof(paramarrayattribute).fullname)) {     // there `params` modifier. } else {     // there no modifiers. } 

Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -