Refactor character validation to use char.IsAsciiLetter#26270
Closed
xtqqczze wants to merge 1 commit into
Closed
Conversation
iSazonov
reviewed
Oct 22, 2025
Collaborator
iSazonov
left a comment
There was a problem hiding this comment.
Please use one PR per change.
| // The drive pointing to VHD in session 'B' gets detected as DriveType.NoRootDirectory | ||
| // after the VHD is removed in session 'A'. | ||
| if (drive != null && !string.IsNullOrEmpty(drive.Name) && drive.Name.Length == 1) | ||
| if (drive is { Name.Length: 1 }) |
Collaborator
There was a problem hiding this comment.
I'd prefer to avoid using patterns since we haven't nullability check enabled.
I guess something classic like drive?.Name?.Length == 1 would work here.
| if (char.IsAsciiLetterUpper((char)c)) | ||
| { | ||
| c = (char) (c | 0x20); | ||
| c |= 0x20; |
Collaborator
There was a problem hiding this comment.
Please don't change non-compiled code.
| } | ||
|
|
||
| return isSupportedDriveForPersistence; | ||
| return drive is { Name.Length: 1 } && char.IsAsciiLetter(drive.Name[0]); |
| // To match old behavior we'll check the drive character for validity as the path is technically | ||
| // not qualified if you don't have a valid drive. "=:\" is the "=" file's default data stream. | ||
| && IsValidDriveChar(path[0])); | ||
| && char.IsAsciiLetter(path[0])); |
Collaborator
There was a problem hiding this comment.
Please keep old method name for readability but update implementation.
9a196f5 to
19ae822
Compare
Contributor
|
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.