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

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

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

Post 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
FFF
Posts: 1581
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

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

Post by FFF »

Wouldn't that has to be placed in front of the method?

Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

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

Post by ic2 »

Hello Karl,

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

Dick
User avatar
Chris
Posts: 4913
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

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

Post 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
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

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

Post 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
User avatar
Chris
Posts: 4913
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

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

Post 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
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply