Skip to content

Conversation

RussKie
Copy link
Member

@RussKie RussKie commented Oct 14, 2023

No description provided.

@ghost ghost assigned RussKie Oct 14, 2023
Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
Will maybe want to have some way to skip the handling also if debugger is attached

@RussKie
Copy link
Member Author

RussKie commented Oct 14, 2023

Will maybe want to have some way to skip the handling also if debugger is attached

Can you please elaborate?

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@gerhardol
Copy link
Member

Will maybe want to have some way to skip the handling also if debugger is attached

Can you please elaborate?

When in the debugger, you have to press continue several times for some reason, so it is unclear if you could ignore the exception.
It is not simple to just copy the stacktrace and continue.

Outside the debugger, you get the dialog to connect to the debugger.
If I run my dailies, I would prefer to get an exception so I could copy the stacktrace and investigate at a later time (I do not have msvs at work for instance).

None of these comments is against a merge as is.
I could make a private patch too, not sure what to do for the generic code.

@mstv
Copy link
Member

mstv commented Oct 14, 2023

I would prefer to get an exception so I could copy the stacktrace and investigate at a later time (I do not have msvs at work for instance).

I could make a private patch too, not sure what to do for the generic code.

I am going to route consumed exceptions to the GitOutputControl in addition to to Trace. The same can be done for these DebugHelpers.

Comment on lines +37 to +35
Debugger.Launch();

if (!Debugger.IsAttached)
{
throw new InvalidOperationException(message);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will prompt to attach a debugger, and if that's declined an exception will get routed to NBug... HOWEVER, if the code that triggered this was executing on a background thread it'd lead to the termination of the app.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HOWEVER, if the code that triggered this was executing on a background thread it'd lead to the termination of the app.

It terminates the app but after starting the BugReporter, isn't it?

The goal is to not have background threads without exception handling. I assume that there is (almost) no such background operation left since the recent PR for JTF.RunAsync and FileAndForget.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It terminates the app but after starting the BugReporter, isn't it?

Correct.

else if (!condition)
{
Debugger.Launch();

if (!Debugger.IsAttached)
{
throw new InvalidOperationException(message);
}
}
Copy link
Member Author

@RussKie RussKie Oct 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...the above makes me quite unhappy with this section. While nagging the dev in an invalid situation (guarded by Debug.Fail) is warranted, it's not appropriate for a "check" situaion (i.e., Debug.Assert) - an assert should not bring the app down.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the fundamental problem with Debug.Assert.
It is used for making assumptions explicit (good) - with the expectation that they will never fail.
(I see that these sanity checks are skipped in the release build for performance reasons.)
In most cases, it is wrong and unsafe to continue the execution. Sometimes, the code throws other exceptions. In many cases, it is just a lack of error handling in release builds (which is bad IMO).

@RussKie RussKie force-pushed the debughelpers branch 2 times, most recently from db0d497 to 65f5df1 Compare October 15, 2023 03:04
Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +37 to +35
Debugger.Launch();

if (!Debugger.IsAttached)
{
throw new InvalidOperationException(message);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HOWEVER, if the code that triggered this was executing on a background thread it'd lead to the termination of the app.

It terminates the app but after starting the BugReporter, isn't it?

The goal is to not have background threads without exception handling. I assume that there is (almost) no such background operation left since the recent PR for JTF.RunAsync and FileAndForget.

else if (!condition)
{
Debugger.Launch();

if (!Debugger.IsAttached)
{
throw new InvalidOperationException(message);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the fundamental problem with Debug.Assert.
It is used for making assumptions explicit (good) - with the expectation that they will never fail.
(I see that these sanity checks are skipped in the release build for performance reasons.)
In most cases, it is wrong and unsafe to continue the execution. Sometimes, the code throws other exceptions. In many cases, it is just a lack of error handling in release builds (which is bad IMO).

@RussKie RussKie force-pushed the debughelpers branch 2 times, most recently from 65f5df1 to 8c2d9cb Compare October 18, 2023 22:50
@mstv
Copy link
Member

mstv commented Oct 19, 2023

MC resolved

@mstv mstv merged commit 39655a0 into gitextensions:master Oct 19, 2023
@ghost ghost added this to the vNext milestone Oct 19, 2023
@RussKie
Copy link
Member Author

RussKie commented Oct 19, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants