Skip to content

Commit

Permalink
refactor: adapt ReSharper File Layout to avoid Sonar issues during cl…
Browse files Browse the repository at this point in the history
…eanup (#499)

Adapt ReSharper File Layout to avoid Sonar issues due to method
overloads that are not adjacent.
  • Loading branch information
vbreuss authored Mar 16, 2024
1 parent aa6ea08 commit b95d7e2
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 106 deletions.
8 changes: 4 additions & 4 deletions Source/Testably.Abstractions.Compression/ZipArchiveWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ public ReadOnlyCollection<IZipArchiveEntry> Entries
public ZipArchiveMode Mode
=> _instance.Mode;

/// <inheritdoc cref="IDisposable.Dispose()" />
public void Dispose()
=> _instance.Dispose();

/// <inheritdoc cref="IZipArchive.CreateEntry(string)" />
public IZipArchiveEntry CreateEntry(string entryName)
=> ZipArchiveEntryWrapper.New(FileSystem, this, _instance.CreateEntry(entryName));
Expand Down Expand Up @@ -77,6 +73,10 @@ public IZipArchiveEntry CreateEntryFromFile(string sourceFileName, string entryN
entryName,
compressionLevel));

/// <inheritdoc cref="IDisposable.Dispose()" />
public void Dispose()
=> _instance.Dispose();

/// <inheritdoc cref="IZipArchive.ExtractToDirectory(string)" />
public void ExtractToDirectory(string destinationDirectoryName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ public void Delete(bool recursive)
ResetCache(!_fileSystem.Execute.IsNetFramework);
}

/// <inheritdoc cref="IFileSystemInfo.Delete()" />
public override void Delete()
{
using IDisposable registration = RegisterMethod(nameof(Delete));

if (!_fileSystem.Storage.DeleteContainer(Location))
{
throw ExceptionFactory.DirectoryNotFound(Location.FullPath);
}

ResetCache(!_fileSystem.Execute.IsNetFramework);
}

/// <inheritdoc cref="IDirectoryInfo.EnumerateDirectories()" />
public IEnumerable<IDirectoryInfo> EnumerateDirectories()
{
Expand Down Expand Up @@ -394,19 +407,6 @@ public void MoveTo(string destDirName)
?? throw ExceptionFactory.DirectoryNotFound(FullName);
}

/// <inheritdoc cref="IFileSystemInfo.Delete()" />
public override void Delete()
{
using IDisposable registration = RegisterMethod(nameof(Delete));

if (!_fileSystem.Storage.DeleteContainer(Location))
{
throw ExceptionFactory.DirectoryNotFound(Location.FullPath);
}

ResetCache(!_fileSystem.Execute.IsNetFramework);
}

#endregion

[return: NotNullIfNotNull("location")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ public IWaitForChangedResult WaitForChanged(

#endregion

internal static FileSystemWatcherMock New(MockFileSystem fileSystem)
=> new(fileSystem);

/// <inheritdoc cref="Component.Dispose(bool)" />
protected override void Dispose(bool disposing)
{
Expand All @@ -312,9 +315,6 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}

internal static FileSystemWatcherMock New(MockFileSystem fileSystem)
=> new(fileSystem);

private bool MatchesFilter(ChangeDescription changeDescription)
{
string fullPath = _fileSystem.Path.GetFullPath(Path);
Expand Down
20 changes: 10 additions & 10 deletions Source/Testably.Abstractions.Testing/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ public CallbackWaiter(NotificationFactory<TValue> factory,

#region IAwaitableCallback<TValue> Members

/// <inheritdoc cref="IDisposable.Dispose()" />
public void Dispose()
{
_factory.UnRegisterCallback(_key);
}

/// <inheritdoc cref="IAwaitableCallback{TValue}.Wait(Func{TValue, bool}?, int, int, Action?)" />
public void Wait(Func<TValue, bool>? filter = null,
int timeout = 30000,
Expand All @@ -117,12 +123,6 @@ public void Wait(Func<TValue, bool>? filter = null,
}
}

/// <inheritdoc cref="IDisposable.Dispose()" />
public void Dispose()
{
_factory.UnRegisterCallback(_key);
}

#endregion

/// <summary>
Expand Down Expand Up @@ -241,6 +241,10 @@ public CallbackWaiterWithValue(IAwaitableCallback<TValue> awaitableCallback,

#region IAwaitableCallback<TValue,TFunc> Members

/// <inheritdoc cref="IDisposable.Dispose()" />
public void Dispose()
=> _awaitableCallback.Dispose();

/// <inheritdoc cref="IAwaitableCallback{TValue, TFunc}.Wait(Func{TValue, bool}?,int,int, Action?)" />
public TFunc Wait(Func<TValue, bool>? filter = null,
int timeout = 30000,
Expand Down Expand Up @@ -269,10 +273,6 @@ void IAwaitableCallback<TValue>.Wait(Func<TValue, bool>? filter,
});
}

/// <inheritdoc cref="IDisposable.Dispose()" />
public void Dispose()
=> _awaitableCallback.Dispose();

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ public ISynchronizeInvoke? SynchronizingObject
set => _instance.SynchronizingObject = value;
}

/// <inheritdoc cref="IDisposable.Dispose()" />
public void Dispose()
=> _instance.Dispose();

/// <inheritdoc cref="IFileSystemWatcher.BeginInit()" />
public void BeginInit()
=> _instance.BeginInit();
Expand All @@ -119,6 +115,10 @@ public event FileSystemEventHandler? Deleted
remove => _instance.Deleted -= value;
}

/// <inheritdoc cref="IDisposable.Dispose()" />
public void Dispose()
=> _instance.Dispose();

/// <inheritdoc cref="IFileSystemWatcher.EndInit()" />
public void EndInit()
=> _instance.EndInit();
Expand Down
8 changes: 4 additions & 4 deletions Source/Testably.Abstractions/TimeSystem/TimerWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public bool Change(long dueTime, long period)
public bool Change(TimeSpan dueTime, TimeSpan period)
=> _timer.Change(dueTime, period);

/// <inheritdoc cref="ITimer.Dispose(WaitHandle)" />
public bool Dispose(WaitHandle notifyObject)
=> _timer.Dispose(notifyObject);

/// <inheritdoc cref="IDisposable.Dispose()" />
public void Dispose()
=> _timer.Dispose();

/// <inheritdoc cref="ITimer.Dispose(WaitHandle)" />
public bool Dispose(WaitHandle notifyObject)
=> _timer.Dispose(notifyObject);

#if FEATURE_ASYNC_DISPOSABLE
/// <inheritdoc cref="IAsyncDisposable.DisposeAsync()" />
public ValueTask DisposeAsync()
Expand Down
Loading

0 comments on commit b95d7e2

Please sign in to comment.