Skip to content

Commit 10c6477

Browse files
authored
Backslash mapping breaking change (#33790)
1 parent a9029ec commit 10c6477

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

docs/core/compatibility/8.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ If you're migrating an app to .NET 8, the breaking changes listed here might aff
1919
| Title | Type of change | Introduced |
2020
| --------------------------------------------------------------------------------------- | ----------------- | ---------- |
2121
| [Activity operation name when null](core-libraries/8.0/activity-operation-name.md) | Behavioral change | Preview 1 |
22+
| [Backslash mapping in Unix file paths](core-libraries/8.0/file-path-backslash.md) | Behavioral change | Preview 1 |
2223
| [FileStream writes when pipe is closed](core-libraries/8.0/filestream-disposed-pipe.md) | Behavioral change | Preview 1 |
2324
| [GetFolderPath behavior on Unix](core-libraries/8.0/getfolderpath-unix.md) | Behavioral change | Preview 1 |
2425
| [Legacy Console.ReadKey removed](core-libraries/8.0/console-readkey-legacy.md) | Behavioral change | Preview 1 |
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: ".NET 8 breaking change: Backslash mapping in Unix file paths"
3+
description: Learn about the .NET 8 breaking change in core .NET libraries where the CoreCLR native runtime no longer maps backslashes to forward slashes in file paths on Unix.
4+
ms.date: 01/30/2023
5+
---
6+
# Backslash mapping in Unix file paths
7+
8+
Backslash (`\`) characters are valid in directory and file names on Unix. Starting in .NET 8, the native CoreCLR runtime no longer converts `\` characters to directory separators—forward slashes (`/`)—on Unix. This change enables .NET applications to be located on paths with names that contain backslash characters. It also allows the native runtime, `dotnet` host, and the `ilasm` and `ildasm` tools to access files on paths that contain backslash characters.
9+
10+
## Previous behavior
11+
12+
The native CoreCLR runtime automatically converted backslash (`\`) characters in file paths to forward slashes (`/`) on Unix.
13+
14+
## New behavior
15+
16+
The native CoreCLR runtime doesn't convert any file path characters on Unix.
17+
18+
## Version introduced
19+
20+
.NET 8 Preview 1
21+
22+
## Type of breaking change
23+
24+
This change is a [behavioral change](../../categories.md#behavioral-change).
25+
26+
## Reason for change
27+
28+
Without this change, .NET apps located in directories that contain backslash characters fail to start.
29+
30+
## Recommended action
31+
32+
- Use <xref:System.IO.Path.DirectorySeparatorChar?displayProperty=nameWithType> as a directory separator in your app instead of hardcoding it to `\` or `/`.
33+
- Use `/` as a directory separator on Unix in file paths that you pass to the `dotnet` host, hosting APIs, and `ilasm` and `ildasm` tools.
34+
- Use `/` as a directory separator on Unix in file paths in various `DOTNET_xxx` [environment variables](../../../tools/dotnet-environment-variables.md).
35+
36+
## Affected APIs
37+
38+
- Hosting APIs
39+
- <xref:System.Runtime.InteropServices.DllImportAttribute.Value?displayProperty=fullName>
40+
- <xref:System.Runtime.InteropServices.NativeLibrary.Load%2A?displayProperty=fullName>
41+
- <xref:System.Runtime.InteropServices.NativeLibrary.TryLoad%2A?displayProperty=fullName>
42+
- <xref:System.Reflection.Assembly.LoadFrom%2A?displayProperty=fullName>
43+
- <xref:System.Reflection.Assembly.LoadFile%2A?displayProperty=fullName>
44+
- <xref:System.Reflection.Assembly.UnsafeLoadFrom(System.String)?displayProperty=fullName>
45+
- <xref:System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(System.String)?displayProperty=fullName>
46+
- <xref:System.Runtime.Loader.AssemblyLoadContext.LoadFromNativeImagePath(System.String,System.String)?displayProperty=fullName>
47+
- <xref:System.Runtime.Loader.AssemblyLoadContext.LoadUnmanagedDllFromPath(System.String)?displayProperty=fullName>

docs/core/compatibility/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ items:
1212
items:
1313
- name: Activity operation name when null
1414
href: core-libraries/8.0/activity-operation-name.md
15+
- name: Backslash mapping in Unix file paths
16+
href: core-libraries/8.0/file-path-backslash.md
1517
- name: FileStream writes when pipe is closed
1618
href: core-libraries/8.0/filestream-disposed-pipe.md
1719
- name: GetFolderPath behavior on Unix
@@ -892,6 +894,8 @@ items:
892894
items:
893895
- name: Activity operation name when null
894896
href: core-libraries/8.0/activity-operation-name.md
897+
- name: Backslash mapping in Unix file paths
898+
href: core-libraries/8.0/file-path-backslash.md
895899
- name: FileStream writes when pipe is closed
896900
href: core-libraries/8.0/filestream-disposed-pipe.md
897901
- name: GetFolderPath behavior on Unix

0 commit comments

Comments
 (0)