Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 12, 2025

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original issue description:

On windows, when calling dotnet test C:/path/to/my/tests/*_Tests.dll we get the following errors :

Unhandled exception. System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value. (Parameter 'length')
Actual value was -1.
   at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName)
   at System.ArgumentOutOfRangeException.ThrowIfNegative[T](T value, String paramName)
   at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
   at System.String.Substring(Int32 startIndex, Int32 length)
   at vstest.console.Internal.FilePatternParser.SplitFilePatternOnWildCard(String filePattern) in /_/src/vstest.console/Internal/FilePatternParser.cs:line 101
   at vstest.console.Internal.FilePatternParser.GetMatchingFiles(String filePattern) in /_/src/vstest.console/Internal/FilePatternParser.cs:line 75
   at Microsoft.VisualStudio.TestPlatform.CommandLine.CommandLineOptions.AddSource(String source) in /_/src/vstest.console/CommandLine/CommandLineOptions.cs:line 283
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.ArgumentProcessorFactory.<>c__DisplayClass18_0.<WrapLazyProcessorToInitializeOnInstantiation>b__0() in /_/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs:line 280
   at System.Lazy`1.CreateValue()
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Executor.GetArgumentProcessors(String[] args, List`1& processors) in /_/src/vstest.console/CommandLine/Executor.cs:line 283
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Executor.Execute(String[] args) in /_/src/vstest.console/CommandLine/Executor.cs:line 173
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Program.Main(String[] args) in /_/src/vstest.console/Program.cs:line 22

This works when using backward slashes.

I think that since forward slashes work in general when doing other Windows CLI tools, or well, in dotnet test when not using globbing.

I feel like it could be addressed by changing the SplitFilePatternOnWildCard to take into account Path.AltDirectorySeparatorChar

https://learn.microsoft.com/en-us/dotnet/api/system.io.path.altdirectoryseparatorchar?view=net-9.0

That said I don't know how Path.AltDirectorySeparatorChar would affect other platforms?

Fixes #14993.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@nohwnd
Copy link
Member

nohwnd commented Jun 12, 2025

looks like your session timed out. Try again.

@nohwnd
Copy link
Member

nohwnd commented Jun 13, 2025

@copilot try one more time.

Copy link
Contributor Author

Copilot AI commented Jun 13, 2025

@copilot try one more time.

I've implemented the fix for the FilePatternParser issue. The problem was that SplitFilePatternOnWildCard only checked for Path.DirectorySeparatorChar (backslash on Windows) but ignored Path.AltDirectorySeparatorChar (forward slash on Windows).

The fix uses Math.Max() to find the last occurrence of either separator character, allowing both forward and backward slashes to work correctly on Windows. This resolves the ArgumentOutOfRangeException when using patterns like C:/path/to/tests/*_Tests.dll.

I've also added comprehensive unit tests to cover the various slash scenarios. The fix is in commit 41a347a.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • c50vsblobprodcus330.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/vstest/vstest/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/vstest/vstest/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/vstest/vstest/artifacts/toolset/9.0.0-beta.25302.2.txt (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of nohwnd June 13, 2025 15:55
Comment on lines 104 to 106
var directorySeparatorIndex = Math.Max(
pathBeforeWildCard.LastIndexOf(Path.DirectorySeparatorChar),
pathBeforeWildCard.LastIndexOf(Path.AltDirectorySeparatorChar));
Copy link
Member

Choose a reason for hiding this comment

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

use just the appropriate separator depending on OS. On linux use just forward DirectorySeparatorChar

Copy link
Member

Choose a reason for hiding this comment

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

@copilot address this feedback if you did not already

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feedback has been addressed in commit 0ab1d4b. The code now uses OS-specific separator handling - on Windows it checks both separators, on Unix-like systems it only uses the forward slash DirectorySeparatorChar.


// Test with forward slashes - this should work on all platforms
// This specifically tests the fix for issue #14993
_filePatternParser.GetMatchingFiles("C:/Users/vanidhi/Desktop/a/c/*bc.dll");
Copy link
Member

Choose a reason for hiding this comment

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

don't use vanidhi in the examples, use someUser instead.

Copy link
Member

Choose a reason for hiding this comment

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

@copilot address this feedback if you did not already

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feedback has been addressed in commit 0ab1d4b. The test now uses "someUser" instead of "vanidhi" in the example path.

@nohwnd
Copy link
Member

nohwnd commented Jun 19, 2025

@copilot try one more time .

Copy link
Contributor Author

Copilot AI commented Jun 19, 2025

@copilot try one more time .

I've addressed the feedback from the PR reviews. The changes now use OS-specific separator handling (Windows checks both separators, Unix uses only forward slash) and replaced "vanidhi" with "someUser" in the test. Fixed in commit 0ab1d4b.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 1s1vsblobprodcus386.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • 2zrvsblobprodcus388.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • 51yvsblobprodcus36.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • 7tjvsblobprodcus341.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • 80zvsblobprodcus35.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • 8xbvsblobprodcus382.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • c50vsblobprodcus330.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/vstest/vstest/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/vstest/vstest/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/vstest/vstest/artifacts/toolset/9.0.0-beta.25302.2.txt (dns block)
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • imzvsblobprodcus368.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • jd4vsblobprodcus366.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • jrqvsblobprodcus343.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • kmuvsblobprodcus389.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • l49vsblobprodcus358.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • lylvsblobprodcus31.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)
  • o3svsblobprodcus318.vsblob.vsassets.io
    • Triggering command: dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Copilot Copilot AI requested a review from nohwnd June 19, 2025 12:20
Copilot finished work on behalf of nohwnd June 19, 2025 12:20
@nohwnd
Copy link
Member

nohwnd commented Jun 30, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor Author

Copilot AI commented Jul 2, 2025

@nohwnd Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 91e309db-c566-407a-85e4-acfab751bb30

Sorry for the inconvenience!

Copilot finished work on behalf of nohwnd July 2, 2025 09:52
This was referenced Oct 15, 2025
jas88 pushed a commit to jas88/SynthEHR that referenced this pull request Oct 16, 2025
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some
time.

Note: if you make any changes to this PR yourself, they will take
precedence over the rebase.

---

[//]: # (dependabot-end)

Updated [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest)
from 17.13.0 to 18.0.0.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.NET.Test.Sdk's
releases](https://github.com/microsoft/vstest/releases)._

## 18.0.0

## What's Changed

* Update reporting formatting by @​martincostello in
microsoft/vstest#15082
* Fix stack trace for Trace.Fail and Debug.Fail by @​nohwnd in
microsoft/vstest#15103
* Add documentation of environment variables by @​Copilot in
microsoft/vstest#15095
* IFrameworkHandle.LaunchProcessWithDebuggerAttached allows null for
workingDirectory in signature but throws by @​Copilot in
microsoft/vstest#15091
* Add Dependabot configuration for .NET SDK updates by @​JamieMagee in
microsoft/vstest#15114
* Handle dotnet_root in testhost version aware way by @​nohwnd in
microsoft/vstest#15184
* Add magic bytes validation for Mach-O binaries in DotnetHostHelper by
@​Copilot in microsoft/vstest#15230
* using globbing pattern doesn't work on windows with forward slashes by
@​Copilot in microsoft/vstest#15088
* Remove tpv0 by @​nohwnd in
microsoft/vstest#15247
* Cache AssemblyName in ManagedNameHelper by @​Youssef1313 in
microsoft/vstest#15259
* Add ARM64 support to GetArchitectureForSource methods by @​Copilot in
microsoft/vstest#15278

### Internal fixes and updates

* Fix formatting in two files by @​ViktorHofer in
microsoft/vstest#15047
* Build TestPlatform packages in VMR by @​ViktorHofer in
microsoft/vstest#15055
* Condition property on .NET FX MSBuild by @​jaredpar in
microsoft/vstest#15054
* Migrate to awesome assertions by @​nohwnd in
microsoft/vstest#15056
* Revert "Build TestPlatform packages in VMR" by @​ViktorHofer in
microsoft/vstest#15057
* Update package Category by @​ViktorHofer in
microsoft/vstest#15058
* Revert "Write props of tests into trx" by @​nohwnd in
microsoft/vstest#15080
* Error on unsupported tfms (#​15072) by @​nohwnd in
microsoft/vstest#15073
* Use policies from testfx to align by @​nohwnd in
microsoft/vstest#15085
* Update enable-auto-merge.yml by @​nohwnd in
microsoft/vstest#15102
* Revert ignoring environment test by @​Copilot in
microsoft/vstest#15094
* unignore tests by @​Copilot in
microsoft/vstest#15093
* Update MSTest by @​Youssef1313 in
microsoft/vstest#15108
* Bump dotnet-sdk from 9.0.106 to 9.0.301 by @​dependabot[bot] in
microsoft/vstest#15179
* Use Assert.Equals by @​nohwnd in
microsoft/vstest#15181
* Run VSTest tests with MTP by @​Youssef1313 in
microsoft/vstest#15079
* Use the standard sdk for architecture switch test by @​nohwnd in
microsoft/vstest#15188
* Remove CUIT (Coded UI Test) from NuGet packages and test projects by
@​Copilot in microsoft/vstest#15177
* dump-logs? by @​nohwnd in
microsoft/vstest#15187
* Moving to version 18 by @​nohwnd in
microsoft/vstest#15209
* Update fakes version by @​drognanar in
microsoft/vstest#15227
* Microsoft.Intellitrace.Core should be taken from nuget by @​nohwnd in
microsoft/vstest#15229
* Remove MSTest.Assert.Extensions by @​Youssef1313 in
microsoft/vstest#15178
* Sourcebuild fix by @​nohwnd in
microsoft/vstest#15239
* Set dotnet_root_<arch> only when the architecture of dotnet in the
path is the same by @​nohwnd in
microsoft/vstest#15250
* Remove fakes v1 from FakesUtilities by @​drognanar in
microsoft/vstest#15251
* Update fakes dependencies by @​drognanar in
microsoft/vstest#15254
* Do half the work in GetManagedName by @​Youssef1313 in
microsoft/vstest#15255
* check Vsix only when produced by @​nohwnd in
microsoft/vstest#15261
* Set dotnet_root_<arch> always by @​nohwnd in
microsoft/vstest#15266
* Don't hardcode old vswhere version in global.json by @​akoeplinger in
microsoft/vstest#15267
* Revert dowgrade of fakes by @​nohwnd in
microsoft/vstest#15263
* Update VSSDK to version with code flow guard by @​nohwnd in
microsoft/vstest#15279
* Update Fakes to version with code flow guard by @​nohwnd in
microsoft/vstest#15273
 ... (truncated)

## 17.14.1

## What's Changed
* Error on unsupported target frameworks to prevent silently not running
tests by @​nohwnd in microsoft/vstest#15072 and
microsoft/vstest#15078
* Revert writing additional properties to TRX by @​nohwnd in
microsoft/vstest@47eb51b

**Full Changelog**:
microsoft/vstest@v17.14.0...v17.14.1

## 17.14.0

## What's Changed

### .NET versions updated

This version of VS Test upgraded .NET to net8 and net9. All projects
targeting net6.0 (or other end-of-life .NET target frameworks) should
pin their version of Microsoft.NET.Test.SDK to 17.13.0, or update the
projects to net8 or newer. We remain backwards compatible with previous
versions of Microsoft.NET.Test.SDK. This change does **NOT** prevent you
from:

- Updating to the latest VS, and running tests from net6.0 test
projects.
- Updating to the latest .NET SDK, and running tests from net6.0 test
projects.

It also has no impact on .NET Framework projects, where we continue
targeting .NET Framework 4.6.2.

* Drop unsupported frameworks by @​nohwnd in
microsoft/vstest#10565

### Changes

* Adding Process Query Flag For UWP .NET 9 Support by @​adstep in
microsoft/vstest#15003
* Fix builds on WinUI and UWP .NET 9 projects by @​Sergio0694 in
microsoft/vstest#15004
* don't report communication error on discovery abort by @​nohwnd in
microsoft/vstest#14992
* Add dump minitool to vsix by @​nohwnd in
microsoft/vstest#14707
* Make test runners long-path aware (#​5179) by @​peetw in
microsoft/vstest#15014
* Fix trace in DataCollectionRequestSender.cs by @​stan-sz in
microsoft/vstest#15025
* Fix/readme grammar parallelism by @​dellch in
microsoft/vstest#15030
* Add binding redirects by @​nohwnd in
microsoft/vstest#15041
* Write props of tests into trx by @​nohwnd in
microsoft/vstest#14905

### Internal version updates and fixes

* Update io.redist by @​nohwnd in
microsoft/vstest#13872
* Use preview image for public build by @​nohwnd in
microsoft/vstest#13888
* Remove xcopy-msbuild by @​nohwnd in
microsoft/vstest#14138
* Move to macos14 by @​nohwnd in
microsoft/vstest#14137
* Update diagnose.md by @​nohwnd in
microsoft/vstest#14776
* hash with sha2 for mutex lock by @​nohwnd in
microsoft/vstest#14777
* Update test projects for vmr by @​nohwnd in
microsoft/vstest#14894
* 17.14 branding by @​nohwnd in
microsoft/vstest#14903
* Update filter.md for NUnit by @​OsirisTerje in
microsoft/vstest#14987
* Flag netstandard1.x dependencies in source-build by @​ViktorHofer in
microsoft/vstest#14986
* Use VS dependencies versions from release VS to have archived symbols
by @​nohwnd in microsoft/vstest#14991
* Remove extra ; by @​nohwnd in
microsoft/vstest#14995
* Use dependencymodel 6.0.2 by @​nohwnd in
microsoft/vstest#14996
* Make Testhost packable only on Windows by @​mmitche in
microsoft/vstest#15001
* Add system text json to vsix by @​nohwnd in
microsoft/vstest#15034
* Add more files to vsix by @​nohwnd in
microsoft/vstest#15038
* Remove unnecessary CA2022 suppressions by @​Winniexu01 in
microsoft/vstest#15035
* Update package project url by @​mmitche in
microsoft/vstest#15040
 
## New Contributors

* @​OsirisTerje made their first contribution in
microsoft/vstest#14987
* @​adstep made their first contribution in
microsoft/vstest#15003
 ... (truncated)

## 17.14.0-preview-25107-01

## What's Changed

### .NET versions updated

This version of VS Test upgraded .NET to net8 and net9. All projects
targeting net6.0 (or other end-of-life .NET target frameworks) should
pin their version of Microsoft.NET.Test.SDK to 17.13.0, or update the
projects to net8 or newer. We remain backwards compatible with previous
versions of Microsoft.NET.Test.SDK. This change does **NOT** prevent you
from:

- Updating to the latest VS, and running tests from net6.0 test
projects.
- Updating to the latest .NET SDK, and running tests from net6.0 test
projects.

It also has no impact on .NET Framework projects, where we continue
targeting .NET Framework 4.6.2.

* Drop unsupported frameworks by @​nohwnd in
microsoft/vstest#10565


### Changes

* Adding Process Query Flag For UWP .NET 9 Support by @​adstep in
microsoft/vstest#15003
* Fix builds on WinUI and UWP .NET 9 projects by @​Sergio0694 in
microsoft/vstest#15004
* don't report communication error on discovery abort by @​nohwnd in
microsoft/vstest#14992
* Add dump minitool to vsix by @​nohwnd in
microsoft/vstest#14707

### Internal version updates and fixes

* Update io.redist by @​nohwnd in
microsoft/vstest#13872
* Use preview image for public build by @​nohwnd in
microsoft/vstest#13888
* Remove xcopy-msbuild by @​nohwnd in
microsoft/vstest#14138
* Move to macos14 by @​nohwnd in
microsoft/vstest#14137
* Update diagnose.md by @​nohwnd in
microsoft/vstest#14776
* hash with sha2 for mutex lock by @​nohwnd in
microsoft/vstest#14777
* Update test projects for vmr by @​nohwnd in
microsoft/vstest#14894
* 17.14 branding by @​nohwnd in
microsoft/vstest#14903
* Update filter.md for NUnit by @​OsirisTerje in
microsoft/vstest#14987
* Flag netstandard1.x dependencies in source-build by @​ViktorHofer in
microsoft/vstest#14986
* Use VS dependencies versions from release VS to have archived symbols
by @​nohwnd in microsoft/vstest#14991
* Remove extra ; by @​nohwnd in
microsoft/vstest#14995
* Use dependencymodel 6.0.2 by @​nohwnd in
microsoft/vstest#14996
* Make Testhost packable only on Windows by @​mmitche in
microsoft/vstest#15001


### Will probably revert before release:

* Write props of tests into trx by @​nohwnd in
microsoft/vstest#14905
 
## New Contributors

* @​OsirisTerje made their first contribution in
microsoft/vstest#14987
* @​adstep made their first contribution in
microsoft/vstest#15003
* @​Sergio0694 made their first contribution in
microsoft/vstest#15004

**Full Changelog**:
microsoft/vstest@v17.13.0...v17.14.0-preview-25107-01

Commits viewable in [compare
view](microsoft/vstest@v17.13.0...v18.0.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Microsoft.NET.Test.Sdk&package-manager=nuget&previous-version=17.13.0&new-version=18.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

using globbing pattern doesn't work on windows with forward slashes

3 participants