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.2y 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.2y 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
More Posts
❔ How would I replace a CSV file line by line with another array?I have a 6x8 CSV file full of 0s and 1s, and I want to replace the CSV file with another 2D array th❔ How do I resolve a 'package downgrade' if one of my dependencies needs an older version of a dll?I'm developing an app that uses the newest EntityFramework Core 7 (.NET 7) to communicate with its o❔ Will I get a performance hit if I use the Enum type as a key value for a Dictionary?See Code below: ``` public enum Tee1 { None } public enum Tee2 { None } class Program { ✅ Design decision over multiple inserts in a single commandHi, any design suggestions on how to handle an update command from a mvc form which update needs to ❔ Create a HostedService using BackgroundService to listen to requestsHello, I am currently trying to build a BankAccount project and I wrote my business logic. My next ❔ When Vpn connectivity is off don't crash the app.I have built this logic it does make a popup appear with a message about vpn not being connected if ❔ Update-Database errorGetting the following error with the following migration, is anyone able to tell why? https://pasteb❔ PDF generation library?I'm looking for a way to generate PDF file in an ASP.NET application.❔ Entity Framwork SQLite AddHello, i've a little problem there. I'm trying to add something new in my database but i do not unde❔ Linq group by with multiple columns for the outer and then 1 other column for the inner groupLets say I have a list of class Car. It has properties Id, Model, Year, Age,CarCode. A carCode is un