Skip to content

Reject directories when validating existing FileInfo values - #2857

Open
zjdangge wants to merge 1 commit into
dotnet:mainfrom
zjdangge:fix/file-info-existence
Open

zjdangge wants to merge 1 commit into
dotnet:mainfrom
zjdangge:fix/file-info-existence

Conversation

@zjdangge

Copy link
Copy Markdown

AcceptExistingOnly() currently accepts directories for FileInfo values. Require File.Exists in the file-specific validation branch, while preserving the existing DirectoryInfo and FileSystemInfo behavior.

Adds regression coverage for scalar and collection arguments/options, plus checks that FileSystemInfo still accepts both files and directories.

Fixes #2723.

Validation on Windows:

  • Before the fix, all four new directory-rejection cases fail; the file-existence group has 22 passing and 4 failing cases.
  • Debug solution build: 0 warnings and 0 errors.
  • All five Debug test assemblies: 1,957 passed, 0 failed, 14 existing skips, including core tests on .NET 10 and .NET Framework 4.7.2.

Tests used English UI culture and disabled xUnit AppDomains. Built assemblies ran from a path without spaces to avoid existing test/script path-handling issues.

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.

AcceptExistingOnly for FileInfo accepts existing directories

1 participant