Page 1 of 1
[System.Diagnostics.DebuggerHidden()]; unreachable?
Posted: Tue May 29, 2018 9:33 pm
by ic2
In Vulcan adding this statement at the end of a method or function prevents the debugger to step through the lines ofthat code:
[System.Diagnostics.DebuggerHidden()];
(It is one of the items on my list of drawbacks VS versus VO where you can just set an attribute to a method for that which is a lot clearer)
However in X# it gives the error XS0162 Unreachable code detected
What should I do differently?
I tried it without () ( as in C#) and without ; (which gives a parser error) so I am not sure how it was changed in X#?
Dick
[System.Diagnostics.DebuggerHidden()]; unreachable?
Posted: Tue May 29, 2018 9:38 pm
by FFF
Wouldn't that has to be placed in front of the method?
Karl
[System.Diagnostics.DebuggerHidden()]; unreachable?
Posted: Tue May 29, 2018 9:41 pm
by ic2
Hello Karl,
Yes you are right, I mixed 2 methods up. But the question remains unchanged...
Dick
[System.Diagnostics.DebuggerHidden()]; unreachable?
Posted: Tue May 29, 2018 10:06 pm
by Chris
Hi Dick,
That warning most probably refers to other part of the code, for example something like
Code: Select all
Function Something(l AS LOGIC) AS INT
IF l
RETURN 1
ELSE
RETURN 2
ENDIF
RETURN 0
so in this case the compiler realizes that the last RETURN statement will never execute. I suspect it will be something similar, but if it is not clear, can you please show us the code?
Chris
[System.Diagnostics.DebuggerHidden()]; unreachable?
Posted: Wed May 30, 2018 6:27 am
by ic2
Hello Chris,
That warning most probably refers to other part of the code
Smart and your are absolutely right. I should have seen that the error pointed to the line above it - hence my mix up with "start" and "end" of the method.
It looks like it works with and without parenthesizes, correct?
[System.Diagnostics.DebuggerHidden()];
and
[System.Diagnostics.DebuggerHidden];
Dick
[System.Diagnostics.DebuggerHidden()]; unreachable?
Posted: Wed May 30, 2018 8:07 am
by Chris
Hi Dick,
Yeah, you can use either versions. In some attributes you can use parameters and in this case you'd need the syntax with the parentheses, for example:
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
But for the parameterless attributes, also the "cleaner" syntax without parens is provided as well.
Chris