Skip to content

Commit 4733ab5

Browse files
authored
feat!: remove obsolete factory methods (#1104)
* Remove obsolete factory methods * Increment major version * Fixbuild errors
1 parent 809a18e commit 4733ab5

18 files changed

+8
-304
lines changed

Diff for: System.IO.Abstractions.sln

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{BBF7AD8D-5522-48
2727
Directory.Build.props = Directory.Build.props
2828
global.json = global.json
2929
README.md = README.md
30+
version.json = version.json
3031
EndProjectSection
3132
EndProject
3233
Global

Diff for: src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDirectoryInfoFactory.cs

-8
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ public MockDirectoryInfoFactory(IMockFileDataAccessor mockFileSystem)
1818
public IFileSystem FileSystem
1919
=> mockFileSystem;
2020

21-
22-
/// <inheritdoc />
23-
[Obsolete("Use `IDirectoryInfoFactory.New(string)` instead")]
24-
public IDirectoryInfo FromDirectoryName(string directoryName)
25-
{
26-
return New(directoryName);
27-
}
28-
2921
/// <inheritdoc />
3022
public IDirectoryInfo New(string path)
3123
{

Diff for: src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDriveInfoFactory.cs

-7
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ public IDriveInfo Wrap(DriveInfo driveInfo)
5959
return New(driveInfo.Name);
6060
}
6161

62-
/// <inheritdoc />
63-
[Obsolete("Use `IDirectoryInfoFactory.New(string)` instead")]
64-
public IDriveInfo FromDriveName(string driveName)
65-
{
66-
return New(driveName);
67-
}
68-
6962
private string NormalizeDriveName(string driveName)
7063
{
7164
if (driveName.Length == 3 && mockFileSystem.StringOperations.EndsWith(driveName, @":\"))

Diff for: src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileInfoFactory.cs

-7
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ public MockFileInfoFactory(IMockFileDataAccessor mockFileSystem)
1818
public IFileSystem FileSystem
1919
=> mockFileSystem;
2020

21-
/// <inheritdoc />
22-
[Obsolete("Use `IFileInfoFactory.New(string)` instead")]
23-
public IFileInfo FromFileName(string fileName)
24-
{
25-
return New(fileName);
26-
}
27-
2821
/// <inheritdoc />
2922
public IFileInfo New(string fileName)
3023
{

Diff for: src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileStreamFactory.cs

-65
Original file line numberDiff line numberDiff line change
@@ -19,71 +19,6 @@ public MockFileStreamFactory(IMockFileDataAccessor mockFileSystem)
1919
public IFileSystem FileSystem
2020
=> mockFileSystem;
2121

22-
/// <inheritdoc />
23-
[Obsolete("Use `IFileStreamFactory.New(string, FileMode)` instead.")]
24-
public Stream Create(string path, FileMode mode)
25-
=> New(path, mode);
26-
27-
/// <inheritdoc />
28-
[Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess)` instead.")]
29-
public Stream Create(string path, FileMode mode, FileAccess access)
30-
=> New(path, mode, access);
31-
32-
/// <inheritdoc />
33-
[Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.")]
34-
public Stream Create(string path, FileMode mode, FileAccess access, FileShare share)
35-
=> New(path, mode, access, share);
36-
37-
/// <inheritdoc />
38-
[Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int)` instead.")]
39-
public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)
40-
=> New(path, mode, access, share, bufferSize);
41-
42-
/// <inheritdoc />
43-
[Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int, FileOptions)` instead.")]
44-
public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options)
45-
=> New(path, mode, access, share, bufferSize, options);
46-
47-
/// <inheritdoc />
48-
[Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int, bool)` instead.")]
49-
public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync)
50-
=> New(path, mode, access, share, bufferSize, useAsync);
51-
52-
/// <inheritdoc />
53-
[Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
54-
public Stream Create(IntPtr handle, FileAccess access)
55-
=> new MockFileStream(mockFileSystem, handle.ToString(), FileMode.Open, access: access);
56-
57-
/// <inheritdoc />
58-
[Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access) instead, and optionally make a new SafeFileHandle with ownsHandle=false if needed. http://go.microsoft.com/fwlink/?linkid=14202")]
59-
public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle)
60-
=> new MockFileStream(mockFileSystem, handle.ToString(), FileMode.Open, access: access);
61-
62-
/// <inheritdoc />
63-
[Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access, int bufferSize) instead, and optionally make a new SafeFileHandle with ownsHandle=false if needed. http://go.microsoft.com/fwlink/?linkid=14202")]
64-
public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize)
65-
=> new MockFileStream(mockFileSystem, handle.ToString(), FileMode.Open, access: access);
66-
67-
/// <inheritdoc />
68-
[Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync) instead, and optionally make a new SafeFileHandle with ownsHandle=false if needed. http://go.microsoft.com/fwlink/?linkid=14202")]
69-
public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync)
70-
=> new MockFileStream(mockFileSystem, handle.ToString(), FileMode.Open, access: access);
71-
72-
/// <inheritdoc />
73-
[Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess)` instead.")]
74-
public Stream Create(SafeFileHandle handle, FileAccess access)
75-
=> New(handle, access);
76-
77-
/// <inheritdoc />
78-
[Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess, int)` instead.")]
79-
public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize)
80-
=> New(handle, access, bufferSize);
81-
82-
/// <inheritdoc />
83-
[Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess, int, bool)` instead.")]
84-
public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync)
85-
=> New(handle, access, bufferSize, isAsync);
86-
8722
/// <inheritdoc />
8823
public FileSystemStream New(SafeFileHandle handle, FileAccess access)
8924
=> new MockFileStream(mockFileSystem, handle.ToString(), FileMode.Open, access: access);

Diff for: src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileSystemWatcherFactory.cs

-15
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,6 @@ public MockFileSystemWatcherFactory(MockFileSystem mockFileSystem)
1616
/// <inheritdoc />
1717
public IFileSystem FileSystem { get; }
1818

19-
/// <inheritdoc />
20-
[Obsolete("Use `IFileSystemWatcherFactory.New()` instead")]
21-
public IFileSystemWatcher CreateNew()
22-
=> New();
23-
24-
/// <inheritdoc />
25-
[Obsolete("Use `IFileSystemWatcherFactory.New(string)` instead")]
26-
public IFileSystemWatcher CreateNew(string path)
27-
=> New(path);
28-
29-
/// <inheritdoc />
30-
[Obsolete("Use `IFileSystemWatcherFactory.New(string, string)` instead")]
31-
public IFileSystemWatcher CreateNew(string path, string filter)
32-
=> New(path, filter);
33-
3419
/// <inheritdoc />
3520
public IFileSystemWatcher New()
3621
=> throw new NotImplementedException(StringResources.Manager.GetString("FILE_SYSTEM_WATCHER_NOT_IMPLEMENTED_EXCEPTION"));

Diff for: src/TestableIO.System.IO.Abstractions.Wrappers/DirectoryInfoFactory.cs

-7
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ public DirectoryInfoFactory(IFileSystem fileSystem)
1717
public IFileSystem FileSystem
1818
=> fileSystem;
1919

20-
/// <inheritdoc />
21-
[Obsolete("Use `IDirectoryInfoFactory.New(string)` instead")]
22-
public IDirectoryInfo FromDirectoryName(string directoryName)
23-
{
24-
return New(directoryName);
25-
}
26-
2720
/// <inheritdoc />
2821
public IDirectoryInfo New(string path)
2922
{

Diff for: src/TestableIO.System.IO.Abstractions.Wrappers/DriveInfoFactory.cs

-10
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,5 @@ public IDriveInfo Wrap(DriveInfo driveInfo)
4747

4848
return new DriveInfoWrapper(fileSystem, driveInfo);
4949
}
50-
51-
/// <summary>
52-
/// Initializes a new instance of the <see cref="DriveInfoBase"/> class, which acts as a wrapper for a logical drive.
53-
/// </summary>
54-
/// <param name="driveName">A valid drive path or drive letter.</param>
55-
[Obsolete("Use `IDriveInfoFactory.New(string)` instead")]
56-
public IDriveInfo FromDriveName(string driveName)
57-
{
58-
return New(driveName);
59-
}
6050
}
6151
}

Diff for: src/TestableIO.System.IO.Abstractions.Wrappers/FileInfoFactory.cs

-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ public FileInfoFactory(IFileSystem fileSystem)
1717
public IFileSystem FileSystem
1818
=> fileSystem;
1919

20-
/// <inheritdoc />
21-
[Obsolete("Use `IFileInfoFactory.New(string)` instead")]
22-
public IFileInfo FromFileName(string fileName)
23-
{
24-
return New(fileName);
25-
}
2620

2721
/// <inheritdoc />
2822
public IFileInfo New(string fileName)

Diff for: src/TestableIO.System.IO.Abstractions.Wrappers/FileStreamFactory.cs

-60
Original file line numberDiff line numberDiff line change
@@ -15,66 +15,6 @@ public FileStreamFactory(IFileSystem fileSystem)
1515
/// <inheritdoc />
1616
public IFileSystem FileSystem { get; }
1717

18-
[Obsolete("Use `IFileStreamFactory.New(string, FileMode)` instead.")]
19-
public Stream Create(string path, FileMode mode)
20-
=> New(path, mode);
21-
22-
/// <inheritdoc />
23-
[Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess)` instead.")]
24-
public Stream Create(string path, FileMode mode, FileAccess access)
25-
=> New(path, mode, access);
26-
27-
/// <inheritdoc />
28-
[Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.")]
29-
public Stream Create(string path, FileMode mode, FileAccess access, FileShare share)
30-
=> New(path, mode, access, share);
31-
32-
/// <inheritdoc />
33-
[Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int)` instead.")]
34-
public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)
35-
=> New(path, mode, access, share, bufferSize);
36-
37-
/// <inheritdoc />
38-
[Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int, FileOptions)` instead.")]
39-
public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options)
40-
=> New(path, mode, access, share, bufferSize, options);
41-
42-
/// <inheritdoc />
43-
[Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int, bool)` instead.")]
44-
public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync)
45-
=> New(path, mode, access, share, bufferSize, useAsync);
46-
47-
/// <inheritdoc />
48-
[Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess)` instead.")]
49-
public Stream Create(SafeFileHandle handle, FileAccess access)
50-
=> New(handle, access);
51-
52-
/// <inheritdoc />
53-
[Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess, int)` instead.")]
54-
public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize)
55-
=> New(handle, access, bufferSize);
56-
57-
/// <inheritdoc />
58-
[Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess, int, bool)` instead.")]
59-
public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync)
60-
=> New(handle, access, bufferSize, isAsync);
61-
62-
[Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
63-
public Stream Create(IntPtr handle, FileAccess access)
64-
=> new FileStream(handle, access);
65-
66-
[Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access) instead, and optionally make a new SafeFileHandle with ownsHandle=false if needed. http://go.microsoft.com/fwlink/?linkid=14202")]
67-
public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle)
68-
=> new FileStream(handle, access, ownsHandle);
69-
70-
[Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access, int bufferSize) instead, and optionally make a new SafeFileHandle with ownsHandle=false if needed. http://go.microsoft.com/fwlink/?linkid=14202")]
71-
public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize)
72-
=> new FileStream(handle, access, ownsHandle, bufferSize);
73-
74-
[Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync) instead, and optionally make a new SafeFileHandle with ownsHandle=false if needed. http://go.microsoft.com/fwlink/?linkid=14202")]
75-
public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync)
76-
=> new FileStream(handle, access, ownsHandle, bufferSize, isAsync);
77-
7818
/// <inheritdoc />
7919
public FileSystemStream New(SafeFileHandle handle, FileAccess access)
8020
=> new FileStreamWrapper(new FileStream(handle, access));

Diff for: src/TestableIO.System.IO.Abstractions.Wrappers/FileSystemWatcherFactory.cs

-15
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,6 @@ public FileSystemWatcherFactory(IFileSystem fileSystem)
1515
/// <inheritdoc />
1616
public IFileSystem FileSystem { get; }
1717

18-
/// <inheritdoc />
19-
[Obsolete("Use `IFileSystemWatcherFactory.New()` instead")]
20-
public IFileSystemWatcher CreateNew()
21-
=> New();
22-
23-
/// <inheritdoc />
24-
[Obsolete("Use `IFileSystemWatcherFactory.New(string)` instead")]
25-
public IFileSystemWatcher CreateNew(string path)
26-
=> New(path);
27-
28-
/// <inheritdoc />
29-
[Obsolete("Use `IFileSystemWatcherFactory.New(string, string)` instead")]
30-
public IFileSystemWatcher CreateNew(string path, string filter)
31-
=> New(path, filter);
32-
3318
/// <inheritdoc />
3419
public IFileSystemWatcher New()
3520
=> new FileSystemWatcherWrapper(FileSystem);

Diff for: src/TestableIO.System.IO.Abstractions/IDirectoryInfoFactory.cs

-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ namespace System.IO.Abstractions
77
/// </summary>
88
public interface IDirectoryInfoFactory : IFileSystemEntity
99
{
10-
/// <summary>
11-
/// Initializes a new instance of a wrapper for <see cref="DirectoryInfo"/> which implements <see cref="IDirectoryInfo"/>.
12-
/// </summary>
13-
/// <param name="directoryName">The fully qualified name of the new directory, or the relative directory name.</param>
14-
[Obsolete("Use `IDirectoryInfoFactory.New(string)` instead")]
15-
IDirectoryInfo FromDirectoryName(string directoryName);
16-
1710
/// <summary>
1811
/// Initializes a new instance of a wrapper for <see cref="DirectoryInfo"/> which implements <see cref="IDirectoryInfo"/>.
1912
/// </summary>

Diff for: src/TestableIO.System.IO.Abstractions/IDriveInfoFactory.cs

-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ namespace System.IO.Abstractions
77
/// </summary>
88
public interface IDriveInfoFactory : IFileSystemEntity
99
{
10-
/// <summary>
11-
/// Initializes a new instance of a wrapper for <see cref="DriveInfo"/> which implements <see cref="IDriveInfo"/>.
12-
/// </summary>
13-
/// <param name="driveName">A valid drive path or drive letter.</param>
14-
[Obsolete("Use `IDriveInfoFactory.New(string)` instead")]
15-
IDriveInfo FromDriveName(string driveName);
16-
1710
/// <summary>
1811
/// Retrieves the drive names of all logical drives on a computer.
1912
/// </summary>

Diff for: src/TestableIO.System.IO.Abstractions/IFileInfoFactory.cs

-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ namespace System.IO.Abstractions
77
/// </summary>
88
public interface IFileInfoFactory : IFileSystemEntity
99
{
10-
/// <summary>
11-
/// Initializes a new instance of a wrapper for <see cref="FileInfo"/> which implements <see cref="IFileInfo"/>.
12-
/// </summary>
13-
/// <param name="fileName">The fully qualified name of the new file, or the relative file name.</param>
14-
[Obsolete("Use `IFileInfoFactory.New(string)` instead")]
15-
IFileInfo FromFileName(string fileName);
16-
1710
/// <summary>
1811
/// Initializes a new instance of a wrapper for <see cref="FileInfo"/> which implements <see cref="IFileInfo"/>.
1912
/// </summary>

0 commit comments

Comments
 (0)