Skip to content

Commit 7f5854f

Browse files
authored
Merge pull request #34 from Codeuctivity/net10
Net10
2 parents 34d1f74 + 126068b commit 7f5854f

File tree

7 files changed

+30
-27
lines changed

7 files changed

+30
-27
lines changed

.github/workflows/dotnet.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ on:
77
push:
88
paths-ignore:
99
- '*.md'
10-
pull_request:
11-
paths-ignore:
12-
- '*.md'
1310

1411
jobs:
1512
build:
@@ -25,6 +22,7 @@ jobs:
2522
dotnet-version: |
2623
8.0.x
2724
9.0.x
25+
10.0.x
2826
- name: Print OS name
2927
shell: bash
3028
run: |
@@ -59,6 +57,7 @@ jobs:
5957
dotnet-version: |
6058
8.0.x
6159
9.0.x
60+
10.0.x
6261
- name: Restore dependencies
6362
run: dotnet restore
6463
- name: Build
@@ -89,6 +88,7 @@ jobs:
8988
dotnet-version: |
9089
8.0.x
9190
9.0.x
91+
10.0.x
9292
- name: Restore dependencies
9393
run: dotnet restore
9494
- name: Build

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# SanitizeFilename
22

3-
Sanitizes file and directory names to ensure compatibility with Windows (NTFS), Linux (ext4), and macOS (APFS).
3+
Sanitizes file and directory names to ensure compatibility with Windows (NTFS & exFat), Linux (ext4), and macOS (APFS).
44

55
[![.NET build and test](https://github.com/Codeuctivity/SanitizeFilename/actions/workflows/dotnet.yml/badge.svg)](https://github.com/Codeuctivity/SanitizeFilename/actions/workflows/dotnet.yml) [![NuGet](https://img.shields.io/nuget/v/Codeuctivity.SanitizeFilename.svg)](https://www.nuget.org/packages/Codeuctivity.SanitizeFilename/) [![Donate](https://img.shields.io/static/v1?label=Paypal&message=Donate&color=informational)](https://www.paypal.com/donate?hosted_button_id=7M7UFMMRTS7UE)
66

7-
Implements rules documented by [Microsoft](https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions) + file name length truncation to 255 bytes - common on [many modern](https://en.wikipedia.org/wiki/Comparison_of_file_systems) file systems. Runs on any .NET platform.
7+
Implements rules documented by [Microsoft](https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions) + file name length truncation to 255 bytes, which is common on [many modern](https://en.wikipedia.org/wiki/Comparison_of_file_systems) file systems. Runs on any .NET platform.
88

99
## Example
1010

@@ -25,19 +25,19 @@ Console.WriteLine($"SafeFileNameOptionalReplacementChar: {safeFileNameOptionalRe
2525

2626
## Rules
2727

28-
Restrictions of Windows, Linux and OsX are alle combined to an replacement pattern, that will sanitize any filename to be compatible with any of the OS and common filesystem restrictions.
28+
Restrictions of Windows, Linux and macOS are all combined to an replacement pattern, that will sanitize any filename to be compatible with any of the OS and common filesystem restrictions.
2929

3030
| Pattern | OS that don't support pattern | OS that support pattern | Example |
3131
| ----------------------------- | ----------------------------- | ----------------------- | ------------------ |
32-
| Reserved keywords | Windows | Linux, OsX | CON, PRN, AUX, ... |
33-
| Reserved chars | Linux, Windows, OsX | | '/', '\0' |
34-
| Reserved chars windows | Windows | Linux, OsX | '\\\', '""', ... |
35-
| Invalid trailing chars | Windows | Linux, OsX | ' ', ',' |
36-
| Max length Linux | Linux, | [Windows, OsX](https://github.com/Codeuctivity/SanitizeFilename/blob/387103492098cd9cef0f8596a96dc6c2dfe2eba3/SanitizeFilenameTests/FilenameTests/LinuxSpecificTests.cs#L20) | 255 bytes |
37-
| Max length | Linux, Windows, OsX | | 255 chars |
38-
| Unpaired Unicode surrogates | OsX, Linux | Windows | U+D800 - U+DFFF |
39-
| NotAssigned to Unicode | OsX | Linux, Windows | U+67803, ... |
40-
| "New" Unicode (today 16 + 17) | OsX | Linux, Windows | 🫩 (U+1FAE9), ... |
32+
| Reserved keywords | Windows | Linux, macOS | CON, PRN, AUX, ... |
33+
| Reserved chars | Linux, Windows, macOS | | '/', '\0' |
34+
| Reserved chars windows | Windows | Linux, macOS | '\\\', '""', ... |
35+
| Invalid trailing chars | Windows | Linux, macOS | ' ', ',' |
36+
| Max length Linux | Linux, | [Windows, macOS](https://github.com/Codeuctivity/SanitizeFilename/blob/387103492098cd9cef0f8596a96dc6c2dfe2eba3/SanitizeFilenameTests/FilenameTests/LinuxSpecificTests.cs#L20) | 255 bytes |
37+
| Max length | Linux, Windows, macOS | | 255 chars |
38+
| Unpaired Unicode surrogates | macOS, Linux | Windows | U+D800 - U+DFFF |
39+
| NotAssigned to Unicode | macOS | Linux, Windows | U+67803, ... |
40+
| "New" Unicode (today 17+) | macOS | Linux, Windows | 🫩 (U+1FAE9), ... |
4141

4242
## .NET framework support
4343

@@ -49,12 +49,15 @@ Restrictions of Windows, Linux and OsX are alle combined to an replacement patte
4949

5050
## Test setup
5151

52-
The ExFat specific tests are skipped as long as no ExFat filesystem is available. Use this snippet to enable them:
52+
The exFat specific tests are skipped as long as no exFat filesystem is available. Use this snippet to enable them:
53+
54+
### Windows
5355

5456
```powershell
55-
$vhdpath = 'C:\temp\ExFatTestContainer.vhd'
57+
$vhdpath = [System.IO.Path]::Combine($env:TEMP, 'ExFatTestContainer.vhd')
58+
Remove-Item $vhdpath -ErrorAction SilentlyContinue
5659
$vhdsize = 100MB
5760
New-VHD -Path $vhdpath -Dynamic -SizeBytes $vhdsize | Mount-VHD -Passthru |Initialize-Disk -Passthru |New-Partition -AssignDriveLetter -UseMaximumSize |Format-Volume -FileSystem 'exFAT' -Confirm:$false -NewFileSystemLabel '{exfatLabel}' -Force|Out-Null
5861
```
5962

60-
Running as admin will automaticly create and mount a Exfat drive while tests are running.
63+
Running as admin will automatically create and mount a exFat drive while tests are running.

SanitizeFilename.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1515
.github\dependabot.yml = .github\dependabot.yml
1616
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
1717
README.md = README.md
18+
testenvironments.json = testenvironments.json
1819
EndProjectSection
1920
EndProject
2021
Global

SanitizeFilename/SanitizeFilename.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net8.0;net9.0;netstandard2.0</TargetFrameworks>
3+
<TargetFrameworks>net8.0;net9.0;net10.0;netstandard2.0</TargetFrameworks>
44
<LangVersion>latest</LangVersion>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>

SanitizeFilename/docs/nugetReadme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Sanitizes file and directory names to ensure compatibility with Windows (NTFS), Linux (ext4), and macOS (APFS).
44

5-
Implements rules documented by [Microsoft](https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions) + file name length truncation to 255 bytes - common on [many modern](https://en.wikipedia.org/wiki/Comparison_of_file_systems) file systems. Runs on any .net8 target platform.
5+
Implements rules documented by [Microsoft](https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions) + file name length truncation to 255 bytes - common on [many modern](https://en.wikipedia.org/wiki/Comparison_of_file_systems) file systems. Runs on any target platform.
66

77
## Example
88

SanitizeFilenameTests/FilenameTests/SanitizeFilenamesTests.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,16 @@ public void ShouldNotBeTouchedBySanitizer(string unicodeSpecificEmoticon, int? u
207207
// Unicode examples https://emojipedia.org/unicode-17.0
208208
[TestCase("😀", "Unicode 6.1 example https://emojipedia.org/grinning-face")]
209209
[TestCase("🚴", "Unicode 6 example https://emojipedia.org/person-biking")]
210-
[TestCase("🙂", "Unicode 8 example https://emojipedia.org/person-biking")]
210+
[TestCase("🙃", "Unicode 8 example https://emojipedia.org/upside-down-face")]
211211
[TestCase("🤩", "Unicode 10 example https://emojipedia.org/star-struck#emoji")]
212212
[TestCase("🥰", "Unicode 11 example https://emojipedia.org/smiling-face-with-hearts")]
213213
[TestCase("🦿", "Unicode 12 example https://emojipedia.org/mechanical-leg")]
214214
[TestCase("🫀", "Unicode 13.1 example https://emojipedia.org/anatomical-heart")]
215215
[TestCase("🫠", "Unicode 14 example https://emojipedia.org/melting-face")]
216216
[TestCase("🫥", "Unicode 14 example https://emojipedia.org/dotted-line-face")]
217217
[TestCase("🪿", "Unicode 15 example https://emojipedia.org/goose")]
218-
#pragma warning disable IDE0060 // unicodeVersionNote is used for documentation purposes only
219-
public void ShouldSanitizeUnicodeVersion9Plus(string unicodeSpecificEmoticon, string unicodeVersion)
218+
[TestCase("🫩", "Unicode 16 example https://emojipedia.org/face-with-bags-under-eyes")]
219+
public void SanitizesUnicodeCodePointsThatAreSupportedByEveryOs(string unicodeSpecificEmoticon, string unicodeVersion)
220220
{
221221
var sanitizedFilename = unicodeSpecificEmoticon.SanitizeFilename();
222222
Assert.That(sanitizedFilename, Is.Not.EqualTo(unicodeSpecificEmoticon));
@@ -226,9 +226,8 @@ public void ShouldSanitizeUnicodeVersion9Plus(string unicodeSpecificEmoticon, st
226226

227227
// This emoticons are supported by every OS/FS tested, except macOS, because unicode 16 and 17 specific code points are not supported by macOS today
228228
// Behavior on macos is expected to change over time
229-
[TestCase("🫩", "Unicode 16 example https://emojipedia.org/face-with-bags-under-eyes")]
230229
[TestCase("🫝", "Unicdoe 17 example https://emojipedia.org/apple-core")]
231-
public void Unicode17SpecificMacoOsBehavior(string unicodeSpecificEmoticon, string unicodeVersion)
230+
public void UnicodeSpecificMacoOsBehavior(string unicodeSpecificEmoticon, string unicodeVersion)
232231
{
233232
var sanitizedFilename = unicodeSpecificEmoticon.SanitizeFilename();
234233
Assert.That(sanitizedFilename, Is.Not.EqualTo(unicodeSpecificEmoticon));

SanitizeFilenameTests/SanitizeFilenameTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT' ">net8.0;net9.0;net48</TargetFrameworks>
5-
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT' ">net8.0;net9.0</TargetFrameworks>
4+
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT' ">net8.0;net10.0;net48</TargetFrameworks>
5+
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT' ">net10.0</TargetFrameworks>
66
<LangVersion>latest</LangVersion>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>

0 commit comments

Comments
 (0)