Skip to content

Refactor IsComputerNameValid character validation#26274

Merged
iSazonov merged 8 commits into
PowerShell:masterfrom
xtqqczze:char-IsAscii-p1
Nov 14, 2025
Merged

Refactor IsComputerNameValid character validation#26274
iSazonov merged 8 commits into
PowerShell:masterfrom
xtqqczze:char-IsAscii-p1

Conversation

@xtqqczze
Copy link
Copy Markdown
Contributor

@xtqqczze xtqqczze commented Oct 22, 2025

Simplify and modernize the implementation of IsComputerNameValid by using built-in char classification helpers instead of manual character range checks.

The boolean logic was clarified by replacing allDigits (with negated return) with a hasNonDigit variable.

Subset of #26270

Contributes to #26275

@iSazonov iSazonov requested a review from Copilot October 22, 2025 16:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Refactors the IsComputerNameValid method to modernize character validation by replacing manual ASCII range checks with built-in .NET helpers (char.IsAsciiLetter and char.IsAsciiDigit). The logic is also clarified by using a positive hasNonDigit flag instead of the negated allDigits variable.

Key changes:

  • Replaced manual character range comparisons with char.IsAsciiLetter() and char.IsAsciiDigit()
  • Simplified control flow by combining letter and hyphen checks
  • Renamed allDigits to hasNonDigit for clearer boolean logic

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@iSazonov iSazonov added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Oct 22, 2025
@iSazonov

This comment was marked as off-topic.

@iSazonov iSazonov self-requested a review October 22, 2025 16:59
@iSazonov

This comment was marked as outdated.

Comment thread src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs Outdated
@xtqqczze xtqqczze marked this pull request as ready for review October 22, 2025 18:24
Comment thread src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs Outdated
@iSazonov iSazonov self-assigned this Oct 27, 2025
Comment thread src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@iSazonov iSazonov enabled auto-merge (squash) November 14, 2025 10:45
@iSazonov iSazonov merged commit 250e18c into PowerShell:master Nov 14, 2025
36 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot removed the Review - Needed The PR is being reviewed label Nov 14, 2025
@xtqqczze xtqqczze deleted the char-IsAscii-p1 branch November 14, 2025 19:58
SIRMARGIN pushed a commit to SIRMARGIN/PowerShell that referenced this pull request Dec 12, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
kilasuit pushed a commit to kilasuit/PowerShell that referenced this pull request Jan 2, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants