diff --git a/Source/Testably.Abstractions.Interface/Helpers/PathSystemBase.cs b/Source/Testably.Abstractions.Interface/Helpers/PathSystemBase.cs index 577b029f4..2e24039a5 100644 --- a/Source/Testably.Abstractions.Interface/Helpers/PathSystemBase.cs +++ b/Source/Testably.Abstractions.Interface/Helpers/PathSystemBase.cs @@ -15,6 +15,7 @@ namespace Testably.Abstractions.Helpers; #else [Obsolete("Will be removed in a future version!")] #endif +[ExcludeFromCodeCoverage] public abstract class PathSystemBase : IPath { /// diff --git a/Source/Testably.Abstractions.Testing/FileSystem/DirectoryInfoFactoryMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/DirectoryInfoFactoryMock.cs index 1395c23c4..821be5b7b 100644 --- a/Source/Testably.Abstractions.Testing/FileSystem/DirectoryInfoFactoryMock.cs +++ b/Source/Testably.Abstractions.Testing/FileSystem/DirectoryInfoFactoryMock.cs @@ -23,6 +23,7 @@ public IFileSystem FileSystem /// [Obsolete("Use `IDirectoryInfoFactory.New(string)` instead")] + [ExcludeFromCodeCoverage] public IDirectoryInfo FromDirectoryName(string directoryName) { using IDisposable registration = RegisterMethod(nameof(FromDirectoryName), diff --git a/Source/Testably.Abstractions.Testing/FileSystem/DriveInfoFactoryMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/DriveInfoFactoryMock.cs index 4366a3537..f4709200a 100644 --- a/Source/Testably.Abstractions.Testing/FileSystem/DriveInfoFactoryMock.cs +++ b/Source/Testably.Abstractions.Testing/FileSystem/DriveInfoFactoryMock.cs @@ -24,6 +24,7 @@ public IFileSystem FileSystem /// [Obsolete("Use `IDriveInfoFactory.New(string)` instead")] + [ExcludeFromCodeCoverage] public IDriveInfo FromDriveName(string driveName) { using IDisposable registration = RegisterMethod(nameof(FromDriveName), diff --git a/Source/Testably.Abstractions.Testing/FileSystem/FileInfoFactoryMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/FileInfoFactoryMock.cs index f41dfc685..3c65a6df4 100644 --- a/Source/Testably.Abstractions.Testing/FileSystem/FileInfoFactoryMock.cs +++ b/Source/Testably.Abstractions.Testing/FileSystem/FileInfoFactoryMock.cs @@ -23,6 +23,7 @@ public IFileSystem FileSystem /// [Obsolete("Use `IFileInfoFactory.New(string)` instead")] + [ExcludeFromCodeCoverage] public IFileInfo FromFileName(string fileName) { using IDisposable registration = RegisterMethod(nameof(FromFileName), diff --git a/Source/Testably.Abstractions.Testing/FileSystem/FileStreamFactoryMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/FileStreamFactoryMock.cs index 0489143e7..1a481aa42 100644 --- a/Source/Testably.Abstractions.Testing/FileSystem/FileStreamFactoryMock.cs +++ b/Source/Testably.Abstractions.Testing/FileSystem/FileStreamFactoryMock.cs @@ -1,11 +1,9 @@ using Microsoft.Win32.SafeHandles; using System; +using System.Diagnostics.CodeAnalysis; using System.IO; using Testably.Abstractions.Testing.Helpers; using Testably.Abstractions.Testing.Statistics; -#if NET6_0_OR_GREATER -using System.Diagnostics.CodeAnalysis; -#endif namespace Testably.Abstractions.Testing.FileSystem; @@ -29,21 +27,25 @@ public IFileSystem FileSystem /// [Obsolete("Use `IFileStreamFactory.New(string, FileMode)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(string path, FileMode mode) => New(path, mode); /// [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(string path, FileMode mode, FileAccess access) => New(path, mode, access); /// [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(string path, FileMode mode, FileAccess access, FileShare share) => New(path, mode, access, share); /// [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize) => New(path, mode, access, share, bufferSize); @@ -51,6 +53,7 @@ public Stream Create(string path, FileMode mode, FileAccess access, FileShare sh /// [Obsolete( "Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int, FileOptions)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options) @@ -59,6 +62,7 @@ public Stream Create(string path, FileMode mode, FileAccess access, FileShare sh /// [Obsolete( "Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int, bool)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync) @@ -66,40 +70,47 @@ public Stream Create(string path, FileMode mode, FileAccess access, FileShare sh /// [Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(SafeFileHandle handle, FileAccess access) => New(handle, access); /// [Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess, int)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize) => New(handle, access, bufferSize); /// [Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess, int, bool)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync) => New(handle, access, bufferSize, isAsync); /// [Obsolete( "This method has been deprecated. Please use New(SafeFileHandle, FileAccess) instead. http://go.microsoft.com/fwlink/?linkid=14202")] + [ExcludeFromCodeCoverage] public Stream Create(IntPtr handle, FileAccess access) => throw new NotImplementedException(); /// [Obsolete( "This method has been deprecated. Please use New(SafeFileHandle, FileAccess) instead. http://go.microsoft.com/fwlink/?linkid=14202")] + [ExcludeFromCodeCoverage] public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle) => throw new NotImplementedException(); /// [Obsolete( "This method has been deprecated. Please use New(SafeFileHandle, FileAccess, int) instead. http://go.microsoft.com/fwlink/?linkid=14202")] + [ExcludeFromCodeCoverage] public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize) => throw new NotImplementedException(); /// [Obsolete( "This method has been deprecated. Please use New(SafeFileHandle, FileAccess, int, bool) instead. http://go.microsoft.com/fwlink/?linkid=14202")] + [ExcludeFromCodeCoverage] public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync) => throw new NotImplementedException(); diff --git a/Source/Testably.Abstractions.Testing/FileSystem/FileSystemWatcherFactoryMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/FileSystemWatcherFactoryMock.cs index e2c85bba8..56680cba9 100644 --- a/Source/Testably.Abstractions.Testing/FileSystem/FileSystemWatcherFactoryMock.cs +++ b/Source/Testably.Abstractions.Testing/FileSystem/FileSystemWatcherFactoryMock.cs @@ -24,16 +24,19 @@ public IFileSystem FileSystem /// [Obsolete("Use `IFileSystemWatcherFactory.New()` instead")] + [ExcludeFromCodeCoverage] public IFileSystemWatcher CreateNew() => New(); /// [Obsolete("Use `IFileSystemWatcherFactory.New(string)` instead")] + [ExcludeFromCodeCoverage] public IFileSystemWatcher CreateNew(string path) => New(path); /// [Obsolete("Use `IFileSystemWatcherFactory.New(string, string)` instead")] + [ExcludeFromCodeCoverage] public IFileSystemWatcher CreateNew(string path, string filter) => New(path, filter); diff --git a/Source/Testably.Abstractions.Testing/FileSystem/PathMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/PathMock.cs index 69d8e24b1..766d20053 100644 --- a/Source/Testably.Abstractions.Testing/FileSystem/PathMock.cs +++ b/Source/Testably.Abstractions.Testing/FileSystem/PathMock.cs @@ -304,6 +304,7 @@ public string GetRelativePath(string relativeTo, string path) #if !NETSTANDARD2_0 [Obsolete( "Insecure temporary file creation methods should not be used. Use `Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())` instead.")] + [ExcludeFromCodeCoverage] #endif public string GetTempFileName() { diff --git a/Source/Testably.Abstractions/FileSystem/DirectoryInfoFactory.cs b/Source/Testably.Abstractions/FileSystem/DirectoryInfoFactory.cs index 76819e798..77afad9e6 100644 --- a/Source/Testably.Abstractions/FileSystem/DirectoryInfoFactory.cs +++ b/Source/Testably.Abstractions/FileSystem/DirectoryInfoFactory.cs @@ -18,6 +18,7 @@ internal DirectoryInfoFactory(RealFileSystem fileSystem) /// [Obsolete("Use `IDirectoryInfoFactory.New(string)` instead")] + [ExcludeFromCodeCoverage] public IDirectoryInfo FromDirectoryName(string directoryName) => New(directoryName); diff --git a/Source/Testably.Abstractions/FileSystem/DriveInfoFactory.cs b/Source/Testably.Abstractions/FileSystem/DriveInfoFactory.cs index ecd69ec91..3f5e3de27 100644 --- a/Source/Testably.Abstractions/FileSystem/DriveInfoFactory.cs +++ b/Source/Testably.Abstractions/FileSystem/DriveInfoFactory.cs @@ -19,6 +19,7 @@ internal DriveInfoFactory(RealFileSystem fileSystem) /// [Obsolete("Use `IDriveInfoFactory.New(string)` instead")] + [ExcludeFromCodeCoverage] public IDriveInfo FromDriveName(string driveName) => New(driveName); diff --git a/Source/Testably.Abstractions/FileSystem/FileInfoFactory.cs b/Source/Testably.Abstractions/FileSystem/FileInfoFactory.cs index be1289c5b..d6fa20932 100644 --- a/Source/Testably.Abstractions/FileSystem/FileInfoFactory.cs +++ b/Source/Testably.Abstractions/FileSystem/FileInfoFactory.cs @@ -18,6 +18,7 @@ internal FileInfoFactory(RealFileSystem fileSystem) /// [Obsolete("Use `IFileInfoFactory.New(string)` instead")] + [ExcludeFromCodeCoverage] public IFileInfo FromFileName(string fileName) => New(fileName); diff --git a/Source/Testably.Abstractions/FileSystem/FileStreamFactory.cs b/Source/Testably.Abstractions/FileSystem/FileStreamFactory.cs index 8edd8c403..c40fa05ce 100644 --- a/Source/Testably.Abstractions/FileSystem/FileStreamFactory.cs +++ b/Source/Testably.Abstractions/FileSystem/FileStreamFactory.cs @@ -1,9 +1,7 @@ using Microsoft.Win32.SafeHandles; using System; -using System.IO; -#if NET6_0_OR_GREATER using System.Diagnostics.CodeAnalysis; -#endif +using System.IO; namespace Testably.Abstractions.FileSystem; @@ -21,21 +19,25 @@ internal FileStreamFactory(RealFileSystem fileSystem) /// [Obsolete("Use `IFileStreamFactory.New(string, FileMode)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(string path, FileMode mode) => New(path, mode); /// [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(string path, FileMode mode, FileAccess access) => New(path, mode, access); /// [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(string path, FileMode mode, FileAccess access, FileShare share) => New(path, mode, access, share); /// [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int)` instead")] + [ExcludeFromCodeCoverage] public Stream Create( string path, FileMode mode, @@ -47,6 +49,7 @@ public Stream Create( /// [Obsolete( "Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int, FileOptions)` instead")] + [ExcludeFromCodeCoverage] public Stream Create( string path, FileMode mode, @@ -59,6 +62,7 @@ public Stream Create( /// [Obsolete( "Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int, bool)` instead")] + [ExcludeFromCodeCoverage] public Stream Create( string path, FileMode mode, @@ -70,40 +74,47 @@ public Stream Create( /// [Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(SafeFileHandle handle, FileAccess access) => New(handle, access); /// [Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess, int)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize) => New(handle, access, bufferSize); /// [Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess, int, bool)` instead")] + [ExcludeFromCodeCoverage] public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync) => New(handle, access, bufferSize, isAsync); /// [Obsolete( "This method has been deprecated. Please use New(SafeFileHandle, FileAccess) instead. http://go.microsoft.com/fwlink/?linkid=14202")] + [ExcludeFromCodeCoverage] public Stream Create(IntPtr handle, FileAccess access) => throw new NotImplementedException(); /// [Obsolete( "This method has been deprecated. Please use New(SafeFileHandle, FileAccess) instead. http://go.microsoft.com/fwlink/?linkid=14202")] + [ExcludeFromCodeCoverage] public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle) => throw new NotImplementedException(); /// [Obsolete( "This method has been deprecated. Please use New(SafeFileHandle, FileAccess, int) instead. http://go.microsoft.com/fwlink/?linkid=14202")] + [ExcludeFromCodeCoverage] public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize) => throw new NotImplementedException(); /// [Obsolete( "This method has been deprecated. Please use New(SafeFileHandle, FileAccess, int, bool) instead. http://go.microsoft.com/fwlink/?linkid=14202")] + [ExcludeFromCodeCoverage] public Stream Create( IntPtr handle, FileAccess access, diff --git a/Source/Testably.Abstractions/FileSystem/FileSystemWatcherFactory.cs b/Source/Testably.Abstractions/FileSystem/FileSystemWatcherFactory.cs index b171bfcd9..42e5615f8 100644 --- a/Source/Testably.Abstractions/FileSystem/FileSystemWatcherFactory.cs +++ b/Source/Testably.Abstractions/FileSystem/FileSystemWatcherFactory.cs @@ -18,16 +18,19 @@ internal FileSystemWatcherFactory(RealFileSystem fileSystem) /// [Obsolete("Use `IFileSystemWatcherFactory.New()` instead")] + [ExcludeFromCodeCoverage] public IFileSystemWatcher CreateNew() => New(); /// [Obsolete("Use `IFileSystemWatcherFactory.New(string)` instead")] + [ExcludeFromCodeCoverage] public IFileSystemWatcher CreateNew(string path) => New(path); /// [Obsolete("Use `IFileSystemWatcherFactory.New(string, string)` instead")] + [ExcludeFromCodeCoverage] public IFileSystemWatcher CreateNew(string path, string filter) => New(path, filter); diff --git a/Source/Testably.Abstractions/FileSystem/PathWrapper.cs b/Source/Testably.Abstractions/FileSystem/PathWrapper.cs index cb25f106e..39be75f82 100644 --- a/Source/Testably.Abstractions/FileSystem/PathWrapper.cs +++ b/Source/Testably.Abstractions/FileSystem/PathWrapper.cs @@ -160,6 +160,7 @@ public string GetRelativePath(string relativeTo, string path) #if !NETSTANDARD2_0 [Obsolete( "Insecure temporary file creation methods should not be used. Use `Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())` instead.")] + [ExcludeFromCodeCoverage] #endif public string GetTempFileName() => Path.GetTempFileName(); diff --git a/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_net6.0.txt b/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_net6.0.txt index 7a422a6e0..bbcc10fb7 100644 --- a/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_net6.0.txt +++ b/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_net6.0.txt @@ -24,6 +24,7 @@ namespace Testably.Abstractions.Helpers void StoreMetadata(string key, T? value); bool TryGetWrappedInstance([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T? wrappedInstance); } + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [System.Obsolete("Will be removed in a future version!")] public abstract class PathSystemBase : System.IO.Abstractions.IFileSystemEntity, System.IO.Abstractions.IPath { diff --git a/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_net7.0.txt b/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_net7.0.txt index c6772ff12..e66e57bd9 100644 --- a/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_net7.0.txt +++ b/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_net7.0.txt @@ -28,6 +28,7 @@ namespace Testably.Abstractions.Helpers void StoreMetadata(string key, T? value); bool TryGetWrappedInstance([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T? wrappedInstance); } + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [System.Obsolete("Will be removed in a future version!")] public abstract class PathSystemBase : System.IO.Abstractions.IFileSystemEntity, System.IO.Abstractions.IPath { diff --git a/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_net8.0.txt b/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_net8.0.txt index cee8a781e..b2ab1de99 100644 --- a/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_net8.0.txt +++ b/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_net8.0.txt @@ -28,6 +28,7 @@ namespace Testably.Abstractions.Helpers void StoreMetadata(string key, T? value); bool TryGetWrappedInstance([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T? wrappedInstance); } + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [System.Obsolete("Will be removed in a future version!")] public abstract class PathSystemBase : System.IO.Abstractions.IFileSystemEntity, System.IO.Abstractions.IPath { diff --git a/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_netstandard2.0.txt b/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_netstandard2.0.txt index 52d7b650a..e0a620412 100644 --- a/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_netstandard2.0.txt +++ b/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_netstandard2.0.txt @@ -16,6 +16,7 @@ namespace Testably.Abstractions.Helpers void StoreMetadata(string key, T? value); bool TryGetWrappedInstance([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T? wrappedInstance); } + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [System.Obsolete] public abstract class PathSystemBase : System.IO.Abstractions.IFileSystemEntity, System.IO.Abstractions.IPath { diff --git a/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_netstandard2.1.txt b/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_netstandard2.1.txt index 2f0b70542..76fd92a8c 100644 --- a/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_netstandard2.1.txt +++ b/Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Interface_netstandard2.1.txt @@ -24,6 +24,7 @@ namespace Testably.Abstractions.Helpers void StoreMetadata(string key, T? value); bool TryGetWrappedInstance([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T? wrappedInstance); } + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [System.Obsolete("Will be removed in a future version!")] public abstract class PathSystemBase : System.IO.Abstractions.IFileSystemEntity, System.IO.Abstractions.IPath {