Resolve CA1063

This commit is contained in:
JustArchi
2021-05-06 23:45:10 +02:00
parent 559fdb34c6
commit 0e9b956ae9
4 changed files with 28 additions and 17 deletions

View File

@@ -111,7 +111,6 @@ dotnet_diagnostic.ca1028.severity = silent
dotnet_diagnostic.ca1031.severity = silent
# TODO - one at a time
dotnet_diagnostic.ca1063.severity = silent
dotnet_diagnostic.ca1303.severity = silent
dotnet_diagnostic.ca1307.severity = silent
dotnet_diagnostic.ca1308.severity = silent

View File

@@ -106,15 +106,20 @@ namespace ArchiSteamFarm {
MatchActivelyBlacklistedAppIDs.OnModified += OnObjectModified;
}
public override void Dispose() {
BlacklistedFromTradesSteamIDs.OnModified -= OnObjectModified;
IdlingBlacklistedAppIDs.OnModified -= OnObjectModified;
IdlingPriorityAppIDs.OnModified -= OnObjectModified;
MatchActivelyBlacklistedAppIDs.OnModified -= OnObjectModified;
protected override void Dispose(bool disposing) {
if (disposing) {
// Events we registered
BlacklistedFromTradesSteamIDs.OnModified -= OnObjectModified;
IdlingBlacklistedAppIDs.OnModified -= OnObjectModified;
IdlingPriorityAppIDs.OnModified -= OnObjectModified;
MatchActivelyBlacklistedAppIDs.OnModified -= OnObjectModified;
BackingMobileAuthenticator?.Dispose();
// Those are objects that might be null and the check should be in-place
BackingMobileAuthenticator?.Dispose();
}
base.Dispose();
// Base dispose
base.Dispose(disposing);
}
internal void AddGamesToRedeemInBackground(IOrderedDictionary games) {

View File

@@ -107,15 +107,17 @@ namespace ArchiSteamFarm {
[JsonConstructor]
private GlobalDatabase() => ServerListProvider.ServerListUpdated += OnObjectModified;
public override void Dispose() {
// Events we registered
ServerListProvider.ServerListUpdated -= OnObjectModified;
protected override void Dispose(bool disposing) {
if (disposing) {
// Events we registered
ServerListProvider.ServerListUpdated -= OnObjectModified;
// Those are objects that are always being created if constructor doesn't throw exception
PackagesRefreshSemaphore.Dispose();
// Those are objects that are always being created if constructor doesn't throw exception
PackagesRefreshSemaphore.Dispose();
}
// Base dispose
base.Dispose();
base.Dispose(disposing);
}
internal static async Task<GlobalDatabase?> CreateOrLoad(string filePath) {

View File

@@ -34,12 +34,17 @@ namespace ArchiSteamFarm.Helpers {
private bool ReadOnly;
private bool SavingScheduled;
public virtual void Dispose() {
FileSemaphore.Dispose();
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing) {
if (disposing) {
FileSemaphore.Dispose();
}
}
protected async Task Save() {
if (string.IsNullOrEmpty(FilePath)) {
throw new InvalidOperationException(nameof(FilePath));