commandline: IOException when ParserSettings loaded in WPF App
When i use the Library in my WPF App (not Console App), there will be thrown an IOException in the Constructor of ParserSettings. It will be catched and DefaultMaximumHeight will be set. But it would, in my opinion, cleaner with that code:
try
{
if (Console.IsOutputRedirected || Console.WindowWidth < 1)
{
maximumDisplayWidth = DefaultMaximumLength;
}
else
{
maximumDisplayWidth = Console.WindowWidth;
}
}
catch (IOException)
{
maximumDisplayWidth = DefaultMaximumLength;
}
If you agree, i could do a pull request and merge it.
Best regards Lord_Pinhead
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 17
Commits related to this issue
- Fix issue #409 to avoid IOException break in Debug mode in WPF app. (#589) — committed to commandlineparser/commandline by moh-hassan 4 years ago
- Fix issue #409 to avoid IOException break in Debug mode in WPF app. (#589) — committed to commandlineparser/commandline by moh-hassan 4 years ago
The exception is handled by
try ..catchand is not fired at Release Configuration. It’s caught and swallowed by settingConsole.WindowWidth=80when redirected in WPF. In debugging, you can configure the debugger to ignore breaking on the First Chance Exception of IOException and it will ignore it (because it’s handled and not re-thrown again) using Debug > Windows > Exception Settings.This issue will be fixed in the next release.