We use our "own" assert methods which allow to pass a message but do not force it. Most of our code base use the "without message" one... Which is problematic when you have more than one assert and the code changes between the bug reporting and the bug fixing...
I would like to print, in the assert message, the caller line in plain text. Something like:
int toto = 1;
SomObject obj = null;
Assert(toto == 0);
Assert(obj);
Assert(toto == 0, "some useful info");
Expected output:
Assertion failed. Parameter='toto == 0'
Assertion failed. Parameter='obj'
Assertion failed. 'some useful info'
We found this thread talking about Cecil Mono.Cecil - simple example how to get method body ...
It could be a way to go, but would means we have to rebuild the line based on the ILCode. Is there a way to get the "plain text code" in an other way?
[EDIT] We are running on C# 8.