Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vstest.console: CommandLineOptions: preserve stacktrace on re-throw (CA2200) #2606

Merged
merged 3 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/vstest.console/CommandLine/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,10 @@ public void AddSource(string source)
// Get matching files from file pattern parser
matchingFiles = FilePatternParser.GetMatchingFiles(source);
}
catch(TestSourceException ex)
catch(TestSourceException ex) when (source.StartsWith("-") || source.StartsWith("/"))
{
if(source.StartsWith("-") || source.StartsWith("/"))
{
throw new TestSourceException(
string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidArgument, source));
}
throw ex;
Haplois marked this conversation as resolved.
Show resolved Hide resolved
throw new TestSourceException(
string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidArgument, source), ex);
}
// Add the matching files to source list
this.sources = this.sources.Union(matchingFiles).ToList();
Expand Down
12 changes: 11 additions & 1 deletion src/vstest.console/CommandLine/TestSourceException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@ public TestSourceException()
/// </summary>
/// <param name="message">Message for the exception.</param>
public TestSourceException(string message)
: base(message)
: this(message, innerException: null)
{
}

/// <summary>
/// Initializes with the message and innerException.
/// </summary>
/// <param name="message">Message for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference.</param>
public TestSourceException(string message, Exception innerException)
: base(message, innerException)
{
}

Expand Down