Skip to content

Commit ba59ebe

Browse files
feat: Add LinkTarget to FileSystemInfo for .NET 6 targets (#790)
Resolves #789
1 parent 5216e0d commit ba59ebe

File tree

13 files changed

+60
-12
lines changed

13 files changed

+60
-12
lines changed

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<DefineConstants Condition="'$(TargetFramework)' != 'net461'">$(DefineConstants);FEATURE_FILE_SYSTEM_ACL_EXTENSIONS</DefineConstants>
1414
<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>
1515
<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</DefineConstants>
1617
</PropertyGroup>
1718
<ItemGroup>
1819
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.255">

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ public override DateTime LastWriteTimeUtc
134134
set { GetMockFileDataForWrite().LastWriteTime = value.ToLocalTime(); }
135135
}
136136

137+
#if FEATURE_FILE_SYSTEM_INFO_LINK_TARGET
138+
/// <inheritdoc />
139+
public override string LinkTarget
140+
{
141+
get { return GetMockFileDataForRead().LinkTarget; }
142+
}
143+
#endif
144+
137145
/// <inheritdoc />
138146
public override string Name
139147
{

src/System.IO.Abstractions.TestingHelpers/MockFileData.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ public MockFileData(MockFileData template)
101101
CreationTime = template.CreationTime;
102102
LastAccessTime = template.LastAccessTime;
103103
LastWriteTime = template.LastWriteTime;
104+
#if FEATURE_FILE_SYSTEM_INFO_LINK_TARGET
105+
LinkTarget = template.LinkTarget;
106+
#endif
104107
}
105108

106109
/// <summary>
@@ -135,6 +138,13 @@ public string TextContents
135138
/// </summary>
136139
public DateTimeOffset LastWriteTime { get; set; } = new DateTimeOffset(2010, 01, 04, 00, 00, 00, TimeSpan.FromHours(4));
137140

141+
#if FEATURE_FILE_SYSTEM_INFO_LINK_TARGET
142+
/// <summary>
143+
/// Gets or sets the link target of the <see cref="MockFileData"/>.
144+
/// </summary>
145+
public string LinkTarget { get; set; }
146+
#endif
147+
138148
/// <summary>
139149
/// Casts a string into <see cref="MockFileData"/>.
140150
/// </summary>

src/System.IO.Abstractions.TestingHelpers/MockFileInfo.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,18 @@ public override DateTime LastWriteTimeUtc
167167
}
168168
}
169169

170+
#if FEATURE_FILE_SYSTEM_INFO_LINK_TARGET
171+
/// <inheritdoc />
172+
public override string LinkTarget
173+
{
174+
get
175+
{
176+
var mockFileData = GetMockFileDataForRead();
177+
return mockFileData.LinkTarget;
178+
}
179+
}
180+
#endif
181+
170182
/// <inheritdoc />
171183
public override string Name
172184
{

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

Lines changed: 2 additions & 2 deletions
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>net5.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
6+
<TargetFrameworks>net6.0;net5.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
77
<PackageIcon>icon_256x256.png</PackageIcon>
88
</PropertyGroup>
99
<ItemGroup>
@@ -16,6 +16,6 @@
1616
</PackageReference>
1717
</ItemGroup>
1818
<ItemGroup>
19-
<None Include="..\..\images\icon_256x256.png" Pack="true" PackagePath="\"/>
19+
<None Include="..\..\images\icon_256x256.png" Pack="true" PackagePath="\" />
2020
</ItemGroup>
2121
</Project>

src/System.IO.Abstractions/DirectoryInfoWrapper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ public override DateTime LastWriteTimeUtc
9696
set { instance.LastWriteTimeUtc = value; }
9797
}
9898

99+
#if FEATURE_FILE_SYSTEM_INFO_LINK_TARGET
100+
/// <inheritdoc />
101+
public override string LinkTarget
102+
{
103+
get { return instance.LinkTarget; }
104+
}
105+
#endif
106+
99107
/// <inheritdoc />
100108
public override string Name
101109
{

src/System.IO.Abstractions/FileInfoWrapper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ public override DateTime LastWriteTimeUtc
9494
set { instance.LastWriteTimeUtc = value; }
9595
}
9696

97+
#if FEATURE_FILE_SYSTEM_INFO_LINK_TARGET
98+
/// <inheritdoc />
99+
public override string LinkTarget
100+
{
101+
get { return instance.LinkTarget; }
102+
}
103+
#endif
104+
97105
/// <inheritdoc />
98106
public override string Name
99107
{

src/System.IO.Abstractions/FileSystemInfoBase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ internal FileSystemInfoBase() { }
5454
/// <inheritdoc cref="FileSystemInfo.LastWriteTimeUtc"/>
5555
public abstract DateTime LastWriteTimeUtc { get; set; }
5656

57+
#if FEATURE_FILE_SYSTEM_INFO_LINK_TARGET
58+
/// <inheritdoc cref="FileSystemInfo.LinkTarget"/>
59+
public abstract string LinkTarget { get; }
60+
#endif
61+
5762
/// <inheritdoc cref="FileSystemInfo.Name"/>
5863
public abstract string Name { get; }
5964
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
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>net5.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
6+
<TargetFrameworks>net6.0;net5.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
77
<PackageIcon>icon_256x256.png</PackageIcon>
88
</PropertyGroup>
99
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1' OR '$(TargetFramework)' == 'netstandard2.0'">
10-
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.7.0"/>
10+
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.7.0" />
1111
</ItemGroup>
1212
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
13-
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0"/>
13+
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
1414
</ItemGroup>
1515
<ItemGroup>
1616
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.2">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private static IEnumerable<Action<IDirectory>> GetFileSystemActionsForArgumentNu
2828
yield return ds => ds.EnumerateDirectories(null, "foo", SearchOption.AllDirectories);
2929
}
3030

31-
[TestCaseSource("GetFileSystemActionsForArgumentNullException")]
31+
[TestCaseSource(nameof(GetFileSystemActionsForArgumentNullException))]
3232
public void Operations_ShouldThrowArgumentNullExceptionIfPathIsNull(Action<IDirectory> action)
3333
{
3434
// Arrange

0 commit comments

Comments
 (0)