Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking change in .NET 5 affects string comparisons in PowerShell 7.1.2+ #8671

Closed
2 tasks done
sdwheeler opened this issue Mar 18, 2022 · 1 comment · Fixed by #8672
Closed
2 tasks done

Breaking change in .NET 5 affects string comparisons in PowerShell 7.1.2+ #8671

sdwheeler opened this issue Mar 18, 2022 · 1 comment · Fixed by #8672
Assignees
Labels
area-release-notes Area - Release notes issue-doc-idea Issue - request for new content

Comments

@sdwheeler
Copy link
Contributor

sdwheeler commented Mar 18, 2022

Prerequisites

  • Write a descriptive title.
  • Search the existing issues.

Summary of the new feature or changed behavior

With string operands, PowerShell's -eq operator (and its inverse, -ne), performs case-insensitive, culture-invariant string comparison (StringComparison.InvariantCultureIgnoreCase).

As of .NET 5.0, the runtime underlying PowerShell 7.1, this method appears to ignore non-printing control characters. Earlier versions, including up to (at least) 3.1.2 (underlying PowerShell 7.0.5) and the .NET Framework version underlying Windows PowerShell do not.

For instance:

# Escape sequence "`a" is [char] 7
'Food' -eq "Foo`ad"   # !! $true in .NET 5+ - the non-printing control character is *ignored*
// C# equivalent
"Food".Equals("Foo\ad", StringComparison.InvariantCultureIgnoreCase)

List of articles that need to be updated

Link to related PR in PowerShell/PowerShell repo

n/a

Link to related Issues in PowerShell/PowerShell repo

PowerShell/PowerShell#14956 (comment)

@sdwheeler sdwheeler added issue-doc-idea Issue - request for new content area-release-notes Area - Release notes labels Mar 18, 2022
@sdwheeler
Copy link
Contributor Author

sdwheeler commented Mar 18, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-release-notes Area - Release notes issue-doc-idea Issue - request for new content
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant