As I was porting several classes to using Abstractions, i created a class like this
namespace Mocking
{
public static class FileSystemProxy
{
internal static IFileSystem FileSystem { get; set; } = new FileSystem();
internal static IFile File => FileSystem.File;
internal static IDirectory Directory => FileSystem.Directory;
}
}
and replaced using System.IO; with using static Mocking.FileSystemProxy;.
In this way, code changes per file can be minimized.
This however results in the following problem: even though File is now an IFileSystem.File from Abstractions, the analyzer still complains, and wants it to be replaced.

My Suggestion
Fix analyzers so that they don't only check by name/string. In this case, one can obtain a symbol and see, that it is in fact from Abstractions. (System.IO.File returns an empty SymbolInfo in my test)

As I was porting several classes to using Abstractions, i created a class like this
and replaced
using System.IO;withusing static Mocking.FileSystemProxy;.In this way, code changes per file can be minimized.
This however results in the following problem: even though
Fileis now anIFileSystem.Filefrom Abstractions, the analyzer still complains, and wants it to be replaced.My Suggestion

Fix analyzers so that they don't only check by name/string. In this case, one can obtain a symbol and see, that it is in fact from Abstractions. (System.IO.File returns an empty SymbolInfo in my test)