Skip to content

Fix crash in VSTestForwardingApp when trace is enabled with empty args#53307

Draft
Evangelink wants to merge 1 commit intomainfrom
fix/vstest-trace-empty-args-crash
Draft

Fix crash in VSTestForwardingApp when trace is enabled with empty args#53307
Evangelink wants to merge 1 commit intomainfrom
fix/vstest-trace-empty-args-crash

Conversation

@Evangelink
Copy link
Member

Summary

Fixes a potential crash in VSTestForwardingApp constructor when VSTest trace logging is enabled and argsToForward is an empty sequence.

Problem

The trace logging line uses Aggregate() to join args:

argsToForward?.Aggregate((a, b) => $"{a} | {b}")

Aggregate() throws InvalidOperationException on an empty sequence. If argsToForward is non-null but empty and VSTEST_TRACE is enabled, the constructor crashes before the forwarding app can even start.

Fix

Replace Aggregate with string.Join, which handles empty sequences safely and produces equivalent output.

Changes

  • src/Cli/dotnet/Commands/Test/VSTest/VSTestForwardingApp.cs

Aggregate() throws InvalidOperationException on an empty sequence. If
argsToForward is non-null but empty and VSTest trace logging is enabled,
the constructor would crash. Replace with string.Join which handles
empty sequences safely.
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.

1 participant