fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: [System.Diagnostics.DebuggerHidden()]; unreachable?

[System.Diagnostics.DebuggerHidden()]; unreachable? 1 year 3 weeks ago #4827

  ic2's Avatar Topic Author ic2 Offline Posts: 499
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

Please Log in or Create an account to join the conversation.

[System.Diagnostics.DebuggerHidden()]; unreachable? 1 year 3 weeks ago #4828

  FFF's Avatar FFF Away Posts: 577
Wouldn't that has to be placed in front of the method?

Karl

Please Log in or Create an account to join the conversation.

[System.Diagnostics.DebuggerHidden()]; unreachable? 1 year 3 weeks ago #4829

  ic2's Avatar Topic Author ic2 Offline Posts: 499
Hello Karl,

Yes you are right, I mixed 2 methods up. But the question remains unchanged...

Dick

Please Log in or Create an account to join the conversation.

[System.Diagnostics.DebuggerHidden()]; unreachable? 1 year 3 weeks ago #4830

  Chris's Avatar Chris Away Posts: 1181
Hi Dick,

That warning most probably refers to other part of the code, for example something like
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
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

Last edit: by Chris.

[System.Diagnostics.DebuggerHidden()]; unreachable? 1 year 3 weeks ago #4833

  ic2's Avatar Topic Author ic2 Offline Posts: 499
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

Please Log in or Create an account to join the conversation.

[System.Diagnostics.DebuggerHidden()]; unreachable? 1 year 3 weeks ago #4838

  Chris's Avatar Chris Away Posts: 1181
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
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • Page:
  • 1