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

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -