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 dotnet_diagnostic.ca1031.severity = silent
# TODO - one at a time # TODO - one at a time
dotnet_diagnostic.ca1063.severity = silent
dotnet_diagnostic.ca1303.severity = silent dotnet_diagnostic.ca1303.severity = silent
dotnet_diagnostic.ca1307.severity = silent dotnet_diagnostic.ca1307.severity = silent
dotnet_diagnostic.ca1308.severity = silent dotnet_diagnostic.ca1308.severity = silent

View File

@@ -106,15 +106,20 @@ namespace ArchiSteamFarm {
MatchActivelyBlacklistedAppIDs.OnModified += OnObjectModified; MatchActivelyBlacklistedAppIDs.OnModified += OnObjectModified;
} }
public override void Dispose() { protected override void Dispose(bool disposing) {
BlacklistedFromTradesSteamIDs.OnModified -= OnObjectModified; if (disposing) {
IdlingBlacklistedAppIDs.OnModified -= OnObjectModified; // Events we registered
IdlingPriorityAppIDs.OnModified -= OnObjectModified; BlacklistedFromTradesSteamIDs.OnModified -= OnObjectModified;
MatchActivelyBlacklistedAppIDs.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) { internal void AddGamesToRedeemInBackground(IOrderedDictionary games) {

View File

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

View File

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