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

Fixes #8671 - Add .NET 5 breaking change for string comparisons #8672

Merged
merged 1 commit into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-71.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ The following experimental features were added in this release:

## Breaking Changes and Improvements

- String comparison behavior changed in .NET 5.0

PowerShell 7.1 is built on .NET 5.0, which introduced the following breaking change:

- [Behavior changes when comparing strings on .NET 5+](/dotnet/standard/base-types/string-comparison-net-5-plus)

As of .NET 5.0, culture invariant string comparisons ignore non-printing control characters.

For example, the following two strings are considered to be identical:

```powershell
# Escape sequence "`a" is Ctrl-G or [char]7
'Food' -eq "Foo`ad"
```

```Output
True
```

- Fix `$?` to not be `$false` when native command writes to `stderr`
([#13395](https://github.com/PowerShell/PowerShell/pull/13395))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ article is to present the current state of PowerShell and how that is different
PowerShell. For a detailed discussion of changes between versions and the addition of new features,
see the **What's New** articles for each version.

- [What's new in PowerShell 7.x](What-s-New-in-PowerShell-71.md)
- [What's new in PowerShell 7.3](What-s-New-in-PowerShell-73.md)
- [What's new in PowerShell 7.2](What-s-New-in-PowerShell-72.md)
- [What's new in PowerShell 7.1](What-s-New-in-PowerShell-71.md)
- [What's new in PowerShell 7.0](What-s-New-in-PowerShell-70.md)
- [What's new in PowerShell 6.x](/previous-versions/powershell/scripting/whats-new/what-s-new-in-powershell-core-62?view=powershell-6&preserve-view=true)

## .NET Framework vs .NET Core
Expand All @@ -35,6 +38,17 @@ platforms because of the differences in the frameworks. For more information abo
Core, see
[Breaking changes for migration from .NET Framework to .NET Core](/dotnet/core/compatibility/fx-core).

Each new release of PowerShell is built on a newer version of .NET. There can be breaking changes in
.NET that affect PowerShell.

- PowerShell 7.3 (preview) - Built on .NET 7.0 (preview)
- PowerShell 7.2 (LTS-current) - Built on .NET 6.0 (LTS-current)
- PowerShell 7.1 - Built on .NET 5.0
- PowerShell 7.0 (LTS) - Built on .NET Core 3.1 (LTS)
- PowerShell 6.2 - Built on .NET Core 2.1
- PowerShell 6.1 - Built on .NET Core 2.1
- PowerShell 6.0 - Built on .NET Core 2.0

With the advent of
[.NET Standard 2.0](https://devblogs.microsoft.com/dotnet/introducing-net-standard/), PowerShell can
load many traditional Windows PowerShell modules without modification. Additionally, PowerShell 7
Expand Down Expand Up @@ -441,6 +455,25 @@ class M {
[M]::AggregateString((gci).Name, [M]::DoubleStrLen)
```

### String comparison behavior changed in PowerShell 7.1

PowerShell 7.1 is built on .NET 5.0, which introduced the following breaking change:

- [Behavior changes when comparing strings on .NET 5+](/dotnet/standard/base-types/string-comparison-net-5-plus)

As of .NET 5.0, culture invariant string comparisons ignore non-printing control characters.

For example, the following two strings are considered to be identical:

```powershell
# Escape sequence "`a" is Ctrl-G or [char]7
'Food' -eq "Foo`ad"
```

```Output
True
```

## Cmdlet changes

### Check `system32` for compatible built-in modules on Windows
Expand Down