✅ Mono.Cecil.ParameterDefinition.HasDefault
in mono.cecil in a ParameterDefinition, what does HasDefault mean? I was hoping for it to be that if a method signature looks like MyMethod(bool x = false) x was left to its default or not. That isn't the case.
I'm asking this because I need to know if a param of a MethodSpecification, say MyMethod, has a param assigned or left to its default. Is it even possible?
5 Replies
maybe try HasConstant?
If you've got a method:
And you call it:
That gets compiled to:
There's no way to tell from the IL whether someone did
MyMethod()
or MyMethod(false)
, because they're compiled to the same thingI was afraid exactly about this.
but then, I only care about what's different from default. How do I read the value of the compiled variable?
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.up
I figured it out, just look for instructions that load a bool -> ldc.i4.1