C
C#2y ago
an.c.

✅ 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
Aaron
Aaron2y ago
maybe try HasConstant?
canton7
canton72y ago
If you've got a method:
void MyMethod(bool x = false);
void MyMethod(bool x = false);
And you call it:
MyMethod();
MyMethod();
That gets compiled to:
MyMethod(false);
MyMethod(false);
There's no way to tell from the IL whether someone did MyMethod() or MyMethod(false), because they're compiled to the same thing
an.c.
an.c.OP2y ago
I 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?
Accord
Accord2y ago
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.
an.c.
an.c.OP2y ago
up I figured it out, just look for instructions that load a bool -> ldc.i4.1
Want results from more Discord servers?
Add your server