Skip to content

Commit 56389dd

Browse files
authored
feat: add support for .NET 6 (#763)
This commit switches to the .NET 6 SDK and adds a .NET 6 target framework. BREAKING CHANGE: Support for .NET Core 2.1 was removed as it has reached EOL.
1 parent 9a4457f commit 56389dd

17 files changed

Lines changed: 139 additions & 25 deletions

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "C# (.NET Core)",
3-
"image": "mcr.microsoft.com/vscode/devcontainers/dotnet:5.0",
3+
"image": "mcr.microsoft.com/vscode/devcontainers/dotnet:6.0",
44
"settings": {
55
"terminal.integrated.shell.linux": "/bin/bash"
66
},

.github/workflows/ci.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ jobs:
1717
uses: actions/checkout@v2
1818
with:
1919
fetch-depth: 0
20-
- name: Setup .NET Core 2.1
21-
uses: actions/setup-dotnet@v1
22-
with:
23-
dotnet-version: "2.1.x"
24-
- name: Setup .NET Core 3.1
25-
uses: actions/setup-dotnet@v1
26-
with:
27-
dotnet-version: "3.1.x"
2820
- name: Setup .NET
2921
uses: actions/setup-dotnet@v1
22+
with:
23+
dotnet-version: |
24+
3.1.x
25+
5.0.x
26+
6.0.x
3027
- name: Run tests
3128
run: dotnet test --collect:"XPlat Code Coverage" --logger "GitHubActions"
3229
- name: Upload coverage

Directory.Build.props

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
<PackageProjectUrl>https://github.com/System-IO-Abstractions/System.IO.Abstractions</PackageProjectUrl>
1515
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1616
<PackageReadmeFile>README.md</PackageReadmeFile>
17-
<DefineConstants Condition="'$(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</DefineConstants>
18-
<DefineConstants Condition="'$(TargetFramework)' == 'net5.0'">$(DefineConstants);FEATURE_FILE_MOVE_WITH_OVERWRITE</DefineConstants>
19-
<DefineConstants Condition="'$(TargetFramework)' == 'net5.0'">$(DefineConstants);FEATURE_SUPPORTED_OS_ATTRIBUTE</DefineConstants>
20-
<DefineConstants Condition="'$(TargetFramework)' == 'net5.0'">$(DefineConstants);FEATURE_FILE_SYSTEM_WATCHER_FILTERS</DefineConstants>
17+
<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</DefineConstants>
18+
<DefineConstants Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net5.0'">$(DefineConstants);FEATURE_FILE_MOVE_WITH_OVERWRITE</DefineConstants>
19+
<DefineConstants Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net5.0'">$(DefineConstants);FEATURE_SUPPORTED_OS_ATTRIBUTE</DefineConstants>
20+
<DefineConstants Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net5.0'">$(DefineConstants);FEATURE_FILE_SYSTEM_WATCHER_FILTERS</DefineConstants>
2121
</PropertyGroup>
2222
<ItemGroup>
23-
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.231">
23+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.244">
2424
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
2525
<PrivateAssets>all</PrivateAssets>
2626
</PackageReference>
@@ -29,5 +29,6 @@
2929
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3030
<PrivateAssets>all</PrivateAssets>
3131
</PackageReference>
32+
<None Include="$(MSBuildThisFileDirectory)README.md" Pack="true" PackagePath=""/>
3233
</ItemGroup>
3334
</Project>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "5.0.100",
3+
"version": "6.0.100",
44
"rollForward": "latestFeature"
55
}
66
}

src/System.IO.Abstractions/DriveInfoWrapper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ public override string VolumeLabel
154154
get { return instance.VolumeLabel; }
155155

156156
[SupportedOSPlatform("windows")]
157+
#pragma warning disable CA1416
157158
set { instance.VolumeLabel = value; }
159+
#pragma warning restore CA1416
158160
}
159161

160162
public override string ToString()

tests/System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using System.Linq;
3+
using System.Runtime.Versioning;
34
using System.Security.AccessControl;
45
using NUnit.Framework;
56

@@ -1946,6 +1947,7 @@ public void MockDirectory_GetAccessControl_ShouldThrowExceptionOnDirectoryNotFou
19461947

19471948
[Test]
19481949
[WindowsOnly(WindowsSpecifics.AccessControlLists)]
1950+
[SupportedOSPlatform("windows")]
19491951
public void MockDirectory_GetAccessControl_ShouldReturnNewDirectorySecurity()
19501952
{
19511953
// Arrange

tests/System.IO.Abstractions.TestingHelpers.Tests/System.IO.Abstractions.TestingHelpers.Tests.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>net5.0;netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
3+
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1</TargetFrameworks>
44
<TargetFrameworks Condition="!$([MSBuild]::IsOsUnixLike())">$(TargetFrameworks);net461</TargetFrameworks>
55
<Description>The unit tests for our pre-built mocks</Description>
66
<AssemblyName>System.IO.Abstractions.TestingHelpers.Tests</AssemblyName>

tests/System.IO.Abstractions.Tests/ApiParityTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ public ApiDiff(IEnumerable<string> extraMembers, IEnumerable<string> missingMemb
103103
private const string snapshotSuffix = ".NET Framework 4.6.1";
104104
#elif NET5_0
105105
private const string snapshotSuffix = ".NET 5.0";
106+
#elif NET6_0
107+
private const string snapshotSuffix = ".NET 6.0";
106108
#else
107109
#error Unknown target framework.
108110
#endif

tests/System.IO.Abstractions.Tests/System.IO.Abstractions.Tests.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net5.0;netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
3+
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1</TargetFrameworks>
44
<TargetFrameworks Condition="!$([MSBuild]::IsOsUnixLike())">$(TargetFrameworks);net461</TargetFrameworks>
55
<Description>The unit tests for our the core abstractions</Description>
66
<AssemblyName>System.IO.Abstractions.Tests</AssemblyName>
77
<RootNamespace>System.IO.Abstractions.Tests</RootNamespace>
88
<IsPackable>false</IsPackable>
99
<IsTestable>true</IsTestable>
1010
</PropertyGroup>
11-
<PropertyGroup>
12-
<!--
13-
Ensure that test logger is copied to output directory, see
14-
https://github.com/Tyrrrz/GitHubActionsTestLogger/issues/5
15-
-->
16-
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
17-
</PropertyGroup>
1811
<ItemGroup>
1912
<ProjectReference Include="../../src/System.IO.Abstractions/System.IO.Abstractions.csproj" />
2013
</ItemGroup>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"ExtraMembers": [
3+
"System.Security.AccessControl.DirectorySecurity GetAccessControl()",
4+
"System.Security.AccessControl.DirectorySecurity GetAccessControl(System.Security.AccessControl.AccessControlSections)",
5+
"Void Create(System.Security.AccessControl.DirectorySecurity)",
6+
"Void SetAccessControl(System.Security.AccessControl.DirectorySecurity)"
7+
],
8+
"MissingMembers": [
9+
"System.IO.Abstractions.IFileSystemInfo ResolveLinkTarget(Boolean)",
10+
"System.Object GetLifetimeService()",
11+
"System.Object InitializeLifetimeService()",
12+
"System.String LinkTarget",
13+
"System.String get_LinkTarget()",
14+
"Void .ctor(System.String)",
15+
"Void CreateAsSymbolicLink(System.String)",
16+
"Void GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)"
17+
]
18+
}

0 commit comments

Comments
 (0)