Skip to content

Commit f1c07c7

Browse files
authored
refactor: add .NET9 target (#1191)
* Add .NET9 target * Add .NET9 SDK to ci.yml
1 parent fab80f9 commit f1c07c7

24 files changed

+119
-15
lines changed

Diff for: .github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
6.0.x
2525
7.0.x
2626
8.0.x
27+
9.0.x
2728
- name: Run tests
2829
run: dotnet test --collect:"XPlat Code Coverage" --logger "GitHubActions"
2930
- name: Upload coverage

Diff for: Directory.Build.props

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
<Authors>Tatham Oddie &amp; friends</Authors>
66
<SignAssembly Condition="'$(Configuration)' == 'Release'">True</SignAssembly>
77
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)StrongName.snk</AssemblyOriginatorKeyFile>
8-
<LangVersion>9.0</LangVersion>
8+
<LangVersion>latest</LangVersion>
99
<PackageTags>testing</PackageTags>
1010
<PackageProjectUrl>https://github.com/TestableIO/System.IO.Abstractions</PackageProjectUrl>
1111
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1212
<PackageReadmeFile>README.md</PackageReadmeFile>
1313
<DefineConstants Condition="'$(TargetFramework)' != 'net462'">$(DefineConstants);FEATURE_FILE_SYSTEM_ACL_EXTENSIONS</DefineConstants>
14-
<DefineConstants Condition="'$(TargetFramework)' == 'net8.0' OR '$(TargetFramework)' == 'net7.0' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'netstandard2.1'">$(DefineConstants);FEATURE_ASYNC_FILE;FEATURE_ENUMERATION_OPTIONS;FEATURE_ADVANCED_PATH_OPERATIONS;FEATURE_PATH_JOIN_WITH_SPAN;FEATURE_SPAN</DefineConstants>
15-
<DefineConstants Condition="'$(TargetFramework)' == 'net8.0' OR '$(TargetFramework)' == 'net7.0' OR '$(TargetFramework)' == 'net6.0'">$(DefineConstants);FEATURE_FILE_MOVE_WITH_OVERWRITE;FEATURE_SUPPORTED_OS_ATTRIBUTE;FEATURE_FILE_SYSTEM_WATCHER_FILTERS;FEATURE_ENDS_IN_DIRECTORY_SEPARATOR;FEATURE_PATH_JOIN_WITH_PARAMS;FEATURE_PATH_JOIN_WITH_FOUR_PATHS;FEATURE_FILE_SYSTEM_INFO_LINK_TARGET;FEATURE_CREATE_SYMBOLIC_LINK;FEATURE_FILESTREAM_OPTIONS</DefineConstants>
16-
<DefineConstants Condition="'$(TargetFramework)' == 'net8.0' OR '$(TargetFramework)' == 'net7.0'">$(DefineConstants);FEATURE_PATH_EXISTS;FEATURE_FILE_SYSTEM_WATCHER_WAIT_WITH_TIMESPAN;FEATURE_FILE_ATTRIBUTES_VIA_HANDLE;FEATURE_CREATE_TEMP_SUBDIRECTORY;FEATURE_READ_LINES_ASYNC;FEATURE_UNIX_FILE_MODE</DefineConstants>
14+
<DefineConstants Condition="'$(TargetFramework)' == 'net9.0' OR '$(TargetFramework)' == 'net8.0' OR '$(TargetFramework)' == 'net7.0' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'netstandard2.1'">$(DefineConstants);FEATURE_ASYNC_FILE;FEATURE_ENUMERATION_OPTIONS;FEATURE_ADVANCED_PATH_OPERATIONS;FEATURE_PATH_JOIN_WITH_SPAN;FEATURE_SPAN</DefineConstants>
15+
<DefineConstants Condition="'$(TargetFramework)' == 'net9.0' OR '$(TargetFramework)' == 'net8.0' OR '$(TargetFramework)' == 'net7.0' OR '$(TargetFramework)' == 'net6.0'">$(DefineConstants);FEATURE_FILE_MOVE_WITH_OVERWRITE;FEATURE_SUPPORTED_OS_ATTRIBUTE;FEATURE_FILE_SYSTEM_WATCHER_FILTERS;FEATURE_ENDS_IN_DIRECTORY_SEPARATOR;FEATURE_PATH_JOIN_WITH_PARAMS;FEATURE_PATH_JOIN_WITH_FOUR_PATHS;FEATURE_FILE_SYSTEM_INFO_LINK_TARGET;FEATURE_CREATE_SYMBOLIC_LINK;FEATURE_FILESTREAM_OPTIONS</DefineConstants>
16+
<DefineConstants Condition="'$(TargetFramework)' == 'net9.0' OR '$(TargetFramework)' == 'net8.0' OR '$(TargetFramework)' == 'net7.0'">$(DefineConstants);FEATURE_PATH_EXISTS;FEATURE_FILE_SYSTEM_WATCHER_WAIT_WITH_TIMESPAN;FEATURE_FILE_ATTRIBUTES_VIA_HANDLE;FEATURE_CREATE_TEMP_SUBDIRECTORY;FEATURE_READ_LINES_ASYNC;FEATURE_UNIX_FILE_MODE</DefineConstants>
1717
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZABLE</DefineConstants>
1818
</PropertyGroup>
1919
<ItemGroup>

Diff for: System.IO.Abstractions.sln

+10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{BBF7AD8D-5522-48
3030
version.json = version.json
3131
EndProjectSection
3232
EndProject
33+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{2BE9161B-A3F3-4511-81DB-DB1DCB6375C9}"
34+
EndProject
35+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{D905E09D-6DC3-4F7C-8E83-82FADAE2C9E5}"
36+
ProjectSection(SolutionItems) = preProject
37+
.github\workflows\ci.yml = .github\workflows\ci.yml
38+
.github\workflows\pr.yml = .github\workflows\pr.yml
39+
EndProjectSection
40+
EndProject
3341
Global
3442
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3543
Debug|Any CPU = Debug|Any CPU
@@ -78,6 +86,8 @@ Global
7886
{015B3812-E01D-479C-895D-BDDF16E798CA} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}
7987
{7105D748-1253-409F-A624-4879412EF3C2} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}
8088
{919888D2-E37D-40E7-8AD0-600F9429316D} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}
89+
{2BE9161B-A3F3-4511-81DB-DB1DCB6375C9} = {BBF7AD8D-5522-48C0-A906-00CBB72308A0}
90+
{D905E09D-6DC3-4F7C-8E83-82FADAE2C9E5} = {2BE9161B-A3F3-4511-81DB-DB1DCB6375C9}
8191
EndGlobalSection
8292
GlobalSection(ExtensibilityGlobals) = postSolution
8393
SolutionGuid = {8885C59C-F6A0-4C2F-A3BC-B720E9BD161F}

Diff for: global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.405",
3+
"version": "9.0.102",
44
"rollForward": "latestMinor"
55
}
66
}

Diff for: src/System.IO.Abstractions.TestingHelpers/System.IO.Abstractions.TestingHelpers.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<AssemblyName>System.IO.Abstractions.TestingHelpers</AssemblyName>
44
<RootNamespace>System.IO.Abstractions.TestingHelpers</RootNamespace>
55
<Description>A set of pre-built mocks to help when testing file system interactions.</Description>
6-
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net462</TargetFrameworks>
6+
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net462</TargetFrameworks>
77
<PackageIcon>icon_256x256.png</PackageIcon>
88
</PropertyGroup>
99
<ItemGroup>

Diff for: src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileStream.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ private void InternalFlush()
291291
Seek(0, SeekOrigin.Begin);
292292
/* .. read everything out */
293293
var data = new byte[Length];
294-
Read(data, 0, (int)Length);
294+
_ = Read(data, 0, (int)Length);
295295
/* restore to original position */
296296
Seek(position, SeekOrigin.Begin);
297297
/* .. put it in the mock system */

Diff for: src/TestableIO.System.IO.Abstractions.TestingHelpers/TestableIO.System.IO.Abstractions.TestingHelpers.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<AssemblyName>TestableIO.System.IO.Abstractions.TestingHelpers</AssemblyName>
44
<RootNamespace>System.IO.Abstractions.TestingHelpers</RootNamespace>
55
<Description>A set of pre-built mocks to help when testing file system interactions.</Description>
6-
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net462</TargetFrameworks>
6+
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net462</TargetFrameworks>
77
<PackageIcon>icon_256x256.png</PackageIcon>
88
</PropertyGroup>
99
<ItemGroup>

Diff for: src/TestableIO.System.IO.Abstractions.Wrappers/TestableIO.System.IO.Abstractions.Wrappers.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<AssemblyName>TestableIO.System.IO.Abstractions.Wrappers</AssemblyName>
44
<RootNamespace>System.IO.Abstractions</RootNamespace>
55
<Description>A set of abstractions to help make file system interactions testable.</Description>
6-
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net462</TargetFrameworks>
6+
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net462</TargetFrameworks>
77
<PackageIcon>icon_256x256.png</PackageIcon>
88
</PropertyGroup>
99
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1' OR '$(TargetFramework)' == 'netstandard2.0'">

Diff for: src/TestableIO.System.IO.Abstractions/TestableIO.System.IO.Abstractions.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<AssemblyName>TestableIO.System.IO.Abstractions</AssemblyName>
44
<RootNamespace>System.IO.Abstractions</RootNamespace>
55
<Description>A set of abstractions to help make file system interactions testable.</Description>
6-
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net462</TargetFrameworks>
6+
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net462</TargetFrameworks>
77
<PackageIcon>icon_256x256.png</PackageIcon>
88
<Nullable>enable</Nullable>
99
<LangVersion>preview</LangVersion>

Diff for: tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockFileSystemSerializationTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if !NET9_0_OR_GREATER
12
namespace System.IO.Abstractions.TestingHelpers.Tests
23
{
34
using NUnit.Framework;
@@ -38,3 +39,4 @@ public void SerializationBytes()
3839
}
3940
}
4041
}
42+
#endif

Diff for: tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockFileSystemTests.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ public void MockFileSystem_AddDirectory_ShouldExist()
162162

163163
Assert.That(path.Exists, Is.True);
164164
}
165-
165+
166+
#if !NET9_0_OR_GREATER
166167
[Test]
167168
public void MockFileSystem_ByDefault_IsSerializable()
168169
{
@@ -182,6 +183,7 @@ public void MockFileSystem_ByDefault_IsSerializable()
182183

183184
Assert.That(memoryStream.Length > 0, "Length didn't increase after serialization task.");
184185
}
186+
#endif
185187

186188
[Test]
187189
public void MockFileSystem_AddDirectory_ShouldCreateDirectory()

Diff for: tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockFileTests.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,8 @@ public void MockFile_AppendText_CreatesNewFileForAppendToNonExistingFile()
547547
Assert.That(file.TextContents, Is.EqualTo("New too!"));
548548
Assert.That(filesystem.FileExists(filepath));
549549
}
550-
550+
551+
#if !NET9_0_OR_GREATER
551552
[Test]
552553
public void Serializable_works()
553554
{
@@ -565,7 +566,9 @@ public void Serializable_works()
565566
//Assert
566567
Assert.Pass();
567568
}
568-
569+
#endif
570+
571+
#if !NET9_0_OR_GREATER
569572
[Test]
570573
public void Serializable_can_deserialize()
571574
{
@@ -588,6 +591,7 @@ public void Serializable_can_deserialize()
588591
//Assert
589592
Assert.That(deserialized.TextContents, Is.EqualTo(textContentStr));
590593
}
594+
#endif
591595

592596
[Test]
593597
public void MockFile_Encrypt_ShouldSetEncryptedAttribute()

Diff for: tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
3+
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
44
<TargetFrameworks Condition="!$([MSBuild]::IsOsUnixLike())">$(TargetFrameworks);net462</TargetFrameworks>
55
<Description>The unit tests for our pre-built mocks</Description>
66
<AssemblyName>System.IO.Abstractions.TestingHelpers.Tests</AssemblyName>

Diff for: tests/TestableIO.System.IO.Abstractions.Wrappers.Tests/ApiParityTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public ApiDiff(IEnumerable<string> extraMembers, IEnumerable<string> missingMemb
113113
private const string snapshotSuffix = ".NET 7.0";
114114
#elif NET8_0
115115
private const string snapshotSuffix = ".NET 8.0";
116+
#elif NET9_0
117+
private const string snapshotSuffix = ".NET 9.0";
116118
#else
117119
#error Unknown target framework.
118120
#endif

Diff for: tests/TestableIO.System.IO.Abstractions.Wrappers.Tests/FileSystemTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace System.IO.Abstractions.Tests
66
[TestFixture]
77
public class FileSystemTests
88
{
9+
#if !NET9_0_OR_GREATER
910
[Test]
1011
public void Is_Serializable()
1112
{
@@ -20,6 +21,7 @@ public void Is_Serializable()
2021

2122
Assert.That(memoryStream.Length > 0, "Length didn't increase after serialization task.");
2223
}
24+
#endif
2325

2426
[Test]
2527
public void Mock_File_Succeeds()

Diff for: tests/TestableIO.System.IO.Abstractions.Wrappers.Tests/TestableIO.System.IO.Abstractions.Wrappers.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
3+
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
44
<TargetFrameworks Condition="!$([MSBuild]::IsOsUnixLike())">$(TargetFrameworks);net462</TargetFrameworks>
55
<Description>The unit tests for our the core abstractions</Description>
66
<AssemblyName>System.IO.Abstractions.Tests</AssemblyName>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"ExtraMembers": [],
3+
"MissingMembers": [
4+
"System.Object GetLifetimeService()",
5+
"System.Object InitializeLifetimeService()",
6+
"Void .ctor(System.String)",
7+
"Void GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)"
8+
]
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"ExtraMembers": [],
3+
"MissingMembers": []
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"ExtraMembers": [],
3+
"MissingMembers": [
4+
"System.IO.Abstractions.IDriveInfo[] GetDrives()",
5+
"Void .ctor(System.String)"
6+
]
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"ExtraMembers": [],
3+
"MissingMembers": [
4+
"System.Object GetLifetimeService()",
5+
"System.Object InitializeLifetimeService()",
6+
"Void .ctor(System.String)",
7+
"Void GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)"
8+
]
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"ExtraMembers": [
3+
"Void Dispose(Boolean)"
4+
],
5+
"MissingMembers": [
6+
"System.EventHandler Disposed",
7+
"System.Object GetLifetimeService()",
8+
"System.Object InitializeLifetimeService()",
9+
"Void .ctor()",
10+
"Void .ctor(System.String)",
11+
"Void .ctor(System.String, System.String)",
12+
"Void add_Disposed(System.EventHandler)",
13+
"Void remove_Disposed(System.EventHandler)"
14+
]
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"ExtraMembers": [],
3+
"MissingMembers": []
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"ExtraMembers": [],
3+
"MissingMembers": [
4+
"Microsoft.Win32.SafeHandles.SafeFileHandle OpenHandle(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, System.IO.FileOptions, Int64)",
5+
"System.Threading.Tasks.Task AppendAllBytesAsync(System.String, Byte[], System.Threading.CancellationToken)",
6+
"System.Threading.Tasks.Task AppendAllBytesAsync(System.String, System.ReadOnlyMemory`1[System.Byte], System.Threading.CancellationToken)",
7+
"System.Threading.Tasks.Task AppendAllTextAsync(System.String, System.ReadOnlyMemory`1[System.Char], System.Text.Encoding, System.Threading.CancellationToken)",
8+
"System.Threading.Tasks.Task AppendAllTextAsync(System.String, System.ReadOnlyMemory`1[System.Char], System.Threading.CancellationToken)",
9+
"System.Threading.Tasks.Task WriteAllBytesAsync(System.String, System.ReadOnlyMemory`1[System.Byte], System.Threading.CancellationToken)",
10+
"System.Threading.Tasks.Task WriteAllTextAsync(System.String, System.ReadOnlyMemory`1[System.Char], System.Text.Encoding, System.Threading.CancellationToken)",
11+
"System.Threading.Tasks.Task WriteAllTextAsync(System.String, System.ReadOnlyMemory`1[System.Char], System.Threading.CancellationToken)",
12+
"Void AppendAllBytes(System.String, Byte[])",
13+
"Void AppendAllBytes(System.String, System.ReadOnlySpan`1[System.Byte])",
14+
"Void AppendAllText(System.String, System.ReadOnlySpan`1[System.Char])",
15+
"Void AppendAllText(System.String, System.ReadOnlySpan`1[System.Char], System.Text.Encoding)",
16+
"Void WriteAllBytes(System.String, System.ReadOnlySpan`1[System.Byte])",
17+
"Void WriteAllText(System.String, System.ReadOnlySpan`1[System.Char])",
18+
"Void WriteAllText(System.String, System.ReadOnlySpan`1[System.Char], System.Text.Encoding)"
19+
]
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"ExtraMembers": [
3+
"Char get_AltDirectorySeparatorChar()",
4+
"Char get_DirectorySeparatorChar()",
5+
"Char get_PathSeparator()",
6+
"Char get_VolumeSeparatorChar()",
7+
"Char[] get_InvalidPathChars()"
8+
],
9+
"MissingMembers": [
10+
"System.String Combine(System.ReadOnlySpan`1[System.String])",
11+
"System.String Join(System.ReadOnlySpan`1[System.String])"
12+
]
13+
}

0 commit comments

Comments
 (0)