Skip to content

Commit f1fd023

Browse files
authored
feat: enable .NET 7.0 support (#923)
Update interfaces to support new functionality from .NET 7. The implementation in the testing helper is not part of this PR!
1 parent 24d1d07 commit f1fd023

File tree

46 files changed

+863
-473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+863
-473
lines changed

.github/workflows/ci.yml

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

Directory.Build.props

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1212
<PackageReadmeFile>README.md</PackageReadmeFile>
1313
<DefineConstants Condition="'$(TargetFramework)' != 'net461'">$(DefineConstants);FEATURE_FILE_SYSTEM_ACL_EXTENSIONS</DefineConstants>
14-
<DefineConstants Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'netcoreapp3.1' 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)' == 'net6.0' OR '$(TargetFramework)' == 'net5.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</DefineConstants>
16-
<DefineConstants Condition="'$(TargetFramework)' == 'net6.0'">$(DefineConstants);FEATURE_FILE_SYSTEM_INFO_LINK_TARGET;FEATURE_CREATE_SYMBOLIC_LINK;FEATURE_FILESTREAM_OPTIONS</DefineConstants>
14+
<DefineConstants Condition="'$(TargetFramework)' == 'net7.0' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'netcoreapp3.1' 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)' == 'net7.0' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net5.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</DefineConstants>
16+
<DefineConstants Condition="'$(TargetFramework)' == 'net7.0' OR '$(TargetFramework)' == 'net6.0'">$(DefineConstants);FEATURE_FILE_SYSTEM_INFO_LINK_TARGET;FEATURE_CREATE_SYMBOLIC_LINK;FEATURE_FILESTREAM_OPTIONS</DefineConstants>
17+
<DefineConstants Condition="'$(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>
1718
</PropertyGroup>
1819
<ItemGroup>
1920
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.119">

System.IO.Abstractions.sln

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Microsoft Visual Studio Solution File, Format Version 12.00
32
# Visual Studio Version 17
43
VisualStudioVersion = 17.3.32825.248
@@ -19,9 +18,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestableIO.System.IO.Abstra
1918
EndProject
2019
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "meta", "meta", "{C078E0B6-9747-475F-A999-B9E775DF6643}"
2120
EndProject
22-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestableIO.System.IO.Abstractions.TestingHelpers", "src\TestableIO.System.IO.Abstractions.TestingHelpers\TestableIO.System.IO.Abstractions.TestingHelpers.csproj", "{DE22AA55-408F-4041-B85D-26D6D6A158A4}"
21+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestableIO.System.IO.Abstractions.TestingHelpers", "src\TestableIO.System.IO.Abstractions.TestingHelpers\TestableIO.System.IO.Abstractions.TestingHelpers.csproj", "{DE22AA55-408F-4041-B85D-26D6D6A158A4}"
2322
EndProject
24-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestableIO.System.IO.Abstractions.TestingHelpers.Tests", "tests\TestableIO.System.IO.Abstractions.TestingHelpers.Tests\TestableIO.System.IO.Abstractions.TestingHelpers.Tests.csproj", "{919888D2-E37D-40E7-8AD0-600F9429316D}"
23+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestableIO.System.IO.Abstractions.TestingHelpers.Tests", "tests\TestableIO.System.IO.Abstractions.TestingHelpers.Tests\TestableIO.System.IO.Abstractions.TestingHelpers.Tests.csproj", "{919888D2-E37D-40E7-8AD0-600F9429316D}"
24+
EndProject
25+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{BBF7AD8D-5522-48C0-A906-00CBB72308A0}"
26+
ProjectSection(SolutionItems) = preProject
27+
Directory.Build.props = Directory.Build.props
28+
EndProjectSection
2529
EndProject
2630
Global
2731
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -66,8 +70,8 @@ Global
6670
HideSolutionNode = FALSE
6771
EndGlobalSection
6872
GlobalSection(NestedProjects) = preSolution
69-
{0103D32A-6124-4A1A-AD6C-30EB957F09B0} = {C078E0B6-9747-475F-A999-B9E775DF6643}
7073
{B7DA254D-496F-4C50-969C-CF925758E2ED} = {C078E0B6-9747-475F-A999-B9E775DF6643}
74+
{0103D32A-6124-4A1A-AD6C-30EB957F09B0} = {C078E0B6-9747-475F-A999-B9E775DF6643}
7175
{015B3812-E01D-479C-895D-BDDF16E798CA} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}
7276
{7105D748-1253-409F-A624-4879412EF3C2} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}
7377
{919888D2-E37D-40E7-8AD0-600F9429316D} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}

src/System.IO.Abstractions.TestingHelpers/System.IO.Abstractions.TestingHelpers.csproj

Lines changed: 1 addition & 1 deletion
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>net6.0;net5.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
6+
<TargetFrameworks>net7.0;net6.0;net5.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
77
<PackageIcon>icon_256x256.png</PackageIcon>
88
</PropertyGroup>
99
<ItemGroup>

src/System.IO.Abstractions/System.IO.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<AssemblyName>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>net6.0;net5.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
6+
<TargetFrameworks>net7.0;net6.0;net5.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
77
<PackageIcon>icon_256x256.png</PackageIcon>
88
</PropertyGroup>
99
<ItemGroup>

src/TestableIO.System.IO.Abstractions.TestingHelpers/CommonExceptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,8 @@ public static IOException ProcessCannotAccessFileInUse(string paramName = null)
6464

6565
public static IOException FileAlreadyExists(string paramName) =>
6666
new IOException(string.Format(StringResources.Manager.GetString("FILE_ALREADY_EXISTS"), paramName));
67+
68+
public static NotImplementedException NotImplemented() =>
69+
new NotImplementedException(StringResources.Manager.GetString("NOT_IMPLEMENTED_EXCEPTION"));
6770
}
6871
}

src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDirectory.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ public override IDirectoryInfo CreateDirectory(string path)
3939
return CreateDirectoryInternal(path);
4040
}
4141

42+
#if FEATURE_UNIX_FILE_MODE
43+
/// <inheritdoc />
44+
public override IDirectoryInfo CreateDirectory(string path, UnixFileMode unixCreateMode)
45+
{
46+
throw CommonExceptions.NotImplemented();
47+
}
48+
#endif
49+
4250
private IDirectoryInfo CreateDirectoryInternal(string path)
4351
{
4452
if (path == null)
@@ -98,6 +106,14 @@ public override IFileSystemInfo CreateSymbolicLink(string path, string pathToTar
98106
}
99107
#endif
100108

109+
#if FEATURE_CREATE_TEMP_SUBDIRECTORY
110+
/// <inheritdoc />
111+
public override IDirectoryInfo CreateTempSubdirectory(string prefix = null)
112+
{
113+
throw CommonExceptions.NotImplemented();
114+
}
115+
#endif
116+
101117
/// <inheritdoc />
102118
public override void Delete(string path)
103119
{
@@ -514,7 +530,7 @@ public override void Move(string sourceDirName, string destDirName)
514530
/// <inheritdoc />
515531
public override IFileSystemInfo ResolveLinkTarget(string linkPath, bool returnFinalTarget)
516532
{
517-
throw new NotImplementedException();
533+
throw CommonExceptions.NotImplemented();
518534
}
519535

520536
#endif

src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDirectoryInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public MockDirectoryInfo(IMockFileDataAccessor mockFileDataAccessor, string dire
5252
/// <inheritdoc />
5353
public override void CreateAsSymbolicLink(string pathToTarget)
5454
{
55-
throw new NotImplementedException();
55+
throw CommonExceptions.NotImplemented();
5656
}
5757
#endif
5858

@@ -74,7 +74,7 @@ public override void Refresh()
7474
/// <inheritdoc />
7575
public override IFileSystemInfo ResolveLinkTarget(bool returnFinalTarget)
7676
{
77-
throw new NotImplementedException();
77+
throw CommonExceptions.NotImplemented();
7878
}
7979
#endif
8080

src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFile.Async.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ public override Task<string> ReadAllTextAsync(string path, Encoding encoding, Ca
6565
return Task.FromResult(ReadAllText(path, encoding));
6666
}
6767

68+
#if FEATURE_READ_LINES_ASYNC
69+
/// <inheritdoc />
70+
public override IAsyncEnumerable<string> ReadLinesAsync(string path,
71+
CancellationToken cancellationToken = default)
72+
{
73+
throw CommonExceptions.NotImplemented();
74+
}
75+
76+
/// <inheritdoc />
77+
public override IAsyncEnumerable<string> ReadLinesAsync(string path, Encoding encoding,
78+
CancellationToken cancellationToken = default)
79+
{
80+
throw CommonExceptions.NotImplemented();
81+
}
82+
#endif
83+
6884
/// <inheritdoc />
6985
public override Task WriteAllBytesAsync(string path, byte[] bytes, CancellationToken cancellationToken)
7086
{

0 commit comments

Comments
 (0)