Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
8.0.x
9.0.x
10.0.x
global-json-file: global.json
- name: Run unit tests (windows)
if: matrix.os == 'windows-latest'
run: ./build.ps1 CodeCoverage
Expand Down Expand Up @@ -58,6 +59,7 @@ jobs:
8.0.x
9.0.x
10.0.x
global-json-file: global.json
- name: API checks
run: ./build.sh ApiChecks
- name: Upload artifacts
Expand Down Expand Up @@ -89,6 +91,7 @@ jobs:
8.0.x
9.0.x
10.0.x
global-json-file: global.json
- name: Run sonarcloud analysis
run: ./build.sh CodeAnalysis

Expand Down Expand Up @@ -130,6 +133,7 @@ jobs:
8.0.x
9.0.x
10.0.x
global-json-file: global.json
- name: Pack nuget packages
run: ./build.sh Pack
- name: Upload packages
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
8.0.x
9.0.x
10.0.x
global-json-file: global.json
- name: Run unit tests (windows)
if: matrix.os == 'windows-latest'
run: ./build.ps1 CodeCoverage
Expand Down Expand Up @@ -58,6 +59,7 @@ jobs:
8.0.x
9.0.x
10.0.x
global-json-file: global.json
- name: API checks
run: ./build.sh ApiChecks
- name: Upload artifacts
Expand Down Expand Up @@ -90,6 +92,7 @@ jobs:
8.0.x
9.0.x
10.0.x
global-json-file: global.json
- name: Run sonarcloud analysis
run: ./build.sh CodeAnalysis

Expand Down
9 changes: 5 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<DefineConstants Condition="'$(TargetFramework)' != 'net472'">$(DefineConstants);FEATURE_FILE_SYSTEM_ACL_EXTENSIONS</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'net10.0' OR '$(TargetFramework)' == 'net9.0' OR '$(TargetFramework)' == 'net8.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>
<DefineConstants Condition="'$(TargetFramework)' == 'net10.0' OR '$(TargetFramework)' == 'net9.0' OR '$(TargetFramework)' == 'net8.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;FEATURE_RANDOM_ACCESS</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'net10.0' OR '$(TargetFramework)' == 'net9.0' OR '$(TargetFramework)' == 'net8.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;FEATURE_RANDOM_ACCESS_FLUSH_TO_DISK</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'net10.0' OR '$(TargetFramework)' == 'net9.0'">$(DefineConstants);FEATURE_PATH_SPAN;FEATURE_FILE_SPAN</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'net11.0' OR '$(TargetFramework)' == 'net10.0' OR '$(TargetFramework)' == 'net9.0' OR '$(TargetFramework)' == 'net8.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>
<DefineConstants Condition="'$(TargetFramework)' == 'net11.0' OR '$(TargetFramework)' == 'net10.0' OR '$(TargetFramework)' == 'net9.0' OR '$(TargetFramework)' == 'net8.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;FEATURE_RANDOM_ACCESS</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'net11.0' OR '$(TargetFramework)' == 'net10.0' OR '$(TargetFramework)' == 'net9.0' OR '$(TargetFramework)' == 'net8.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;FEATURE_RANDOM_ACCESS_FLUSH_TO_DISK</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'net11.0' OR '$(TargetFramework)' == 'net10.0' OR '$(TargetFramework)' == 'net9.0'">$(DefineConstants);FEATURE_PATH_SPAN;FEATURE_FILE_SPAN</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'net11.0'">$(DefineConstants);FEATURE_CREATE_HARD_LINK;FEATURE_OPEN_NULL_HANDLE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZABLE</DefineConstants>
</PropertyGroup>
<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageVersion Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
<PackageVersion Include="IsExternalInit" Version="1.0.3" />
<PackageVersion Include="Nullable" Version="1.3.1" />
<PackageVersion Include="Testably.Abstractions.FileSystem.Interface" Version="10.4.0" />
<PackageVersion Include="Testably.Abstractions.FileSystem.Interface" Version="11.0.0-pre.1" />
Comment thread
vbreuss marked this conversation as resolved.
Resolved
</ItemGroup>
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "10.0.403",
"version": "11.0.100-rc.3.26522.148",
"rollForward": "latestMinor"
}
}
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Condition="Exists('$(MSBuildThisFileDirectory)/../Directory.Build.props')"/>

<PropertyGroup>
<TargetFrameworks>net472;netstandard2.0;netstandard2.1;net6.0;net8.0;net9.0;net10.0</TargetFrameworks>
<TargetFrameworks>net472;netstandard2.0;netstandard2.1;net6.0;net8.0;net9.0;net10.0;net11.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public static NotImplementedException NotImplemented() =>
public static NotSupportedException RandomAccessNotSupported() =>
new NotSupportedException(StringResources.Manager.GetString("RANDOM_ACCESS_NOT_SUPPORTED_EXCEPTION"));

public static NotSupportedException HardLinkNotSupported() =>
new NotSupportedException(StringResources.Manager.GetString("HARD_LINK_NOT_SUPPORTED_EXCEPTION"));

public static NotSupportedException NullHandleNotSupported() =>
new NotSupportedException(StringResources.Manager.GetString("NULL_HANDLE_NOT_SUPPORTED_EXCEPTION"));

public static IOException CannotCreateBecauseSameNameAlreadyExists(string path) =>
new IOException(
string.Format(
Expand Down
16 changes: 16 additions & 0 deletions src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ private FileSystemStream CreateInternal(string path, FileAccess access, FileOpti
return OpenInternal(path, FileMode.Open, access, options);
}

#if FEATURE_CREATE_HARD_LINK
/// <inheritdoc />
public override IFileSystemInfo CreateHardLink(string path, string pathToTarget)
{
throw CommonExceptions.HardLinkNotSupported();
}
#endif

#if FEATURE_CREATE_SYMBOLIC_LINK
/// <inheritdoc />
public override IFileSystemInfo CreateSymbolicLink(string path, string pathToTarget)
Expand Down Expand Up @@ -647,6 +655,14 @@ public override SafeFileHandle OpenHandle(string path, FileMode mode = FileMode.
}
#endif

#if FEATURE_OPEN_NULL_HANDLE
/// <inheritdoc />
public override SafeFileHandle OpenNullHandle()
{
throw CommonExceptions.NullHandleNotSupported();
}
#endif

private FileSystemStream OpenInternal(
string path,
FileMode mode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public MockFileInfo(IMockFileDataAccessor mockFileSystem, string path) : base(mo
refreshOnNextRead = true;
}

#if FEATURE_CREATE_HARD_LINK
/// <inheritdoc />
public override void CreateAsHardLink(string pathToTarget)
{
throw CommonExceptions.HardLinkNotSupported();
}
#endif

#if FEATURE_CREATE_SYMBOLIC_LINK
/// <inheritdoc />
public override void CreateAsSymbolicLink(string pathToTarget)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,10 @@
<data name="RANDOM_ACCESS_NOT_SUPPORTED_EXCEPTION" xml:space="preserve">
<value>MockFileSystem does not support File.OpenHandle or RandomAccess, because it cannot provide a SafeFileHandle for its in-memory files.</value>
</data>
<data name="HARD_LINK_NOT_SUPPORTED_EXCEPTION" xml:space="preserve">
<value>MockFileSystem does not support hard links.</value>
</data>
<data name="NULL_HANDLE_NOT_SUPPORTED_EXCEPTION" xml:space="preserve">
<value>MockFileSystem does not support File.OpenNullHandle, because it cannot provide a SafeFileHandle.</value>
</data>
</root>
10 changes: 10 additions & 0 deletions src/TestableIO.System.IO.Abstractions.Wrappers/FileBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ internal FileBase() { }
/// <inheritdoc cref="IFile.Create(string,int,FileOptions)"/>
public abstract FileSystemStream Create(string path, int bufferSize, FileOptions options);

#if FEATURE_CREATE_HARD_LINK
/// <inheritdoc cref="IFile.CreateHardLink(string, string)"/>
public abstract IFileSystemInfo CreateHardLink(string path, string pathToTarget);
#endif

#if FEATURE_CREATE_SYMBOLIC_LINK
/// <inheritdoc cref="IFile.CreateSymbolicLink(string, string)"/>
public abstract IFileSystemInfo CreateSymbolicLink(string path, string pathToTarget);
Expand Down Expand Up @@ -186,6 +191,11 @@ public abstract SafeFileHandle OpenHandle(string path, FileMode mode = FileMode.
FileOptions options = FileOptions.None, long preallocationSize = 0);
#endif

#if FEATURE_OPEN_NULL_HANDLE
/// <inheritdoc cref="IFile.OpenNullHandle()"/>
public abstract SafeFileHandle OpenNullHandle();
#endif

/// <inheritdoc cref="IFile.OpenRead"/>
public abstract FileSystemStream OpenRead(string path);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ internal FileInfoBase() { }
/// <inheritdoc cref="IFileInfo.Create"/>
public abstract FileSystemStream Create();

#if FEATURE_CREATE_HARD_LINK
/// <inheritdoc cref="IFileInfo.CreateAsHardLink(string)"/>
public abstract void CreateAsHardLink(string pathToTarget);
#endif

/// <inheritdoc cref="IFileInfo.CreateText"/>
public abstract StreamWriter CreateText();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ public FileInfoWrapper(IFileSystem fileSystem, FileInfo instance) : base(fileSys
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
}

#if FEATURE_CREATE_HARD_LINK
/// <inheritdoc />
public override void CreateAsHardLink(string pathToTarget)
{
instance.CreateAsHardLink(pathToTarget);
}
#endif

#if FEATURE_CREATE_SYMBOLIC_LINK
/// <inheritdoc />
public override void CreateAsSymbolicLink(string pathToTarget)
Expand Down
17 changes: 17 additions & 0 deletions src/TestableIO.System.IO.Abstractions.Wrappers/FileWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ public override FileSystemStream Create(string path, int bufferSize, FileOptions
return new FileStreamWrapper(File.Create(path, bufferSize, options));
}

#if FEATURE_CREATE_HARD_LINK
/// <inheritdoc />
public override IFileSystemInfo CreateHardLink(string path, string pathToTarget)
{
return File.CreateHardLink(path, pathToTarget)
.WrapFileSystemInfo(FileSystem);
}
#endif

#if FEATURE_CREATE_SYMBOLIC_LINK
/// <inheritdoc />
public override IFileSystemInfo CreateSymbolicLink(string path, string pathToTarget)
Expand Down Expand Up @@ -312,6 +321,14 @@ public override SafeFileHandle OpenHandle(string path, FileMode mode = FileMode.
}
#endif

#if FEATURE_OPEN_NULL_HANDLE
/// <inheritdoc />
public override SafeFileHandle OpenNullHandle()
{
return File.OpenNullHandle();
}
#endif

/// <inheritdoc />
public override FileSystemStream OpenRead(string path)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Condition="Exists('$(MSBuildThisFileDirectory)/../Directory.Build.props')"/>

<PropertyGroup>
<TargetFrameworks>net10.0;net9.0;net8.0</TargetFrameworks>
<TargetFrameworks>net11.0;net10.0;net9.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOsUnixLike())">$(TargetFrameworks);net472</TargetFrameworks>
<NoWarn>$(NoWarn);S2699</NoWarn>
<IsPackable>false</IsPackable>
Expand Down
Loading
Loading