Skip to content

Commit 7978dd2

Browse files
authored
fix: Non-breaking bug fixes, code quality improvements, and dead dependency removal (#41)
* fix: Non-breaking bug fixes, code quality improvements, and dead dependency removal Bug fixes: - Fix path manipulation bug in FileManagementUtilities using String.Replace (fragile when sourceDirectory appears as substring in nested paths) - Fix thread-safety in ConcurrentPersistentDictionary: all CRUD operations now use proper locking to match the class name's contract - Fix resource leak in StreamUtils.CopyRessourceToFile (FileStream not disposed on exception) - Fix bare catch blocks in OdbcConnectionManager (catch ArgumentException instead of all exceptions) and BGErrorTracking (catch Exception) - Add missing GC.SuppressFinalize to IDisposable implementations across 8 classes (FixerIOClient, GenericAPIClient, CSVFileReader, CSVFileWriter, ZIPFileUtils, CloudinaryImageManager, ApplicationController, ConcurrentPersistentDictionary) Code quality: - Fix spelling: 'Initalize' → 'Initialize' in 6 files (all private methods) - Make Scheduler.ShutdownTimeout configurable (was hardcoded 30s) - Make CloudinaryImageManager.MaxListResults configurable (was hardcoded 500) - Make ApplicationController.Dispose virtual for subclass overrides Dependency cleanup: - Remove unused System.Data.SqlClient package (deprecated, has known CVEs, not referenced in any source file) * fix: Address remaining consistency issues from code review - Add GC.SuppressFinalize to 4 missed IDisposable classes: BGLoggerNetworkListener, LockingList, FileChangesMonitor, ChromeWebbrowserControl - Fix bare catch block in BGErrorTrackingConfiguration (catch Exception) - Harden FileManagementUtilities path normalization with Path.GetFullPath to prevent issues with mixed separators on netstandard2.0
1 parent 8c147a4 commit 7978dd2

23 files changed

Lines changed: 129 additions & 64 deletions

File tree

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<PackageVersion Include="Microsoft.Win32.SystemEvents" Version="10.0.2" />
4444
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="10.0.2" />
4545
<PackageVersion Include="System.Data.Odbc" Version="10.0.2" />
46-
<PackageVersion Include="System.Data.SqlClient" Version="4.9.0" />
46+
4747
<PackageVersion Include="System.ServiceProcess.ServiceController" Version="10.0.2" />
4848
<PackageVersion Include="System.Text.Encoding.CodePages" Version="10.0.2" />
4949
<PackageVersion Include="System.Collections.Immutable" Version="10.0.2" />

src/BAUERGROUP.Shared.API/API/GenericAPIClient.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ public GenericAPIClient(String url, Int32 timeout = 10 * 1000, IWebProxy? proxy
6161
})
6262
);
6363

64-
Initalize();
64+
Initialize();
6565
Authenticate();
6666
}
6767

68-
private void Initalize()
68+
private void Initialize()
6969
{
7070
Client.AddDefaultHeader(KnownHeaders.Accept, "application/json");
7171
}
@@ -102,6 +102,7 @@ private void Validate(RestClientOptions clientOptions)
102102
public void Dispose()
103103
{
104104
Client?.Dispose();
105+
GC.SuppressFinalize(this);
105106
}
106107

107108
protected async Task<T> ExceptionHandlerAsync<T>(Func<Task<T>> action)

src/BAUERGROUP.Shared.Cloud/CloudinaryClient/CloudinaryImageManager.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ public class CloudinaryImageManager : IDisposable
2424
/// </summary>
2525
protected Cloudinary Client { get; private set; } = null!;
2626

27+
/// <summary>
28+
/// Gets or sets the maximum number of results returned by list operations. Default is 500.
29+
/// </summary>
30+
public int MaxListResults { get; set; } = 500;
31+
2732
/// <summary>
2833
/// Initializes a new instance of the <see cref="CloudinaryImageManager"/> class.
2934
/// </summary>
@@ -32,10 +37,10 @@ public CloudinaryImageManager(CloudinaryImageManagerConfiguration configuration)
3237
{
3338
Configuration = configuration;
3439

35-
Initalize();
40+
Initialize();
3641
}
3742

38-
private void Initalize()
43+
private void Initialize()
3944
{
4045
var account = new Account(Configuration.Name, Configuration.APIKey, Configuration.APISecret);
4146
Client = new Cloudinary(account);
@@ -46,7 +51,7 @@ private void Initalize()
4651
/// </summary>
4752
public void Dispose()
4853
{
49-
54+
GC.SuppressFinalize(this);
5055
}
5156

5257
/// <summary>
@@ -183,7 +188,7 @@ public Resource[] List(String? uniqueIdentifier = null, CloudinaryContentType co
183188
{
184189
var listParameters = new ListResourcesParams()
185190
{
186-
MaxResults = 500,
191+
MaxResults = MaxListResults,
187192
ResourceType = contentType == CloudinaryContentType.Image ? ResourceType.Image : ResourceType.Video
188193
};
189194

src/BAUERGROUP.Shared.Cloud/FixerIO/FixerIOClient.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public FixerIOClient(FixerIOConfiguration configuration)
6969
})
7070
);
7171

72-
Initalize();
72+
Initialize();
7373
}
7474

7575
private void Validate()
@@ -78,7 +78,7 @@ private void Validate()
7878
throw new FixerIOClientException($"Invalid API URL '{Configuration.URL}'.", new ArgumentException("Invalid URL"));
7979
}
8080

81-
private void Initalize()
81+
private void Initialize()
8282
{
8383
Client.AddDefaultHeader(KnownHeaders.Accept, "application/json");
8484
}
@@ -97,6 +97,7 @@ private static string GetUserAgent()
9797
public void Dispose()
9898
{
9999
Client.Dispose();
100+
GC.SuppressFinalize(this);
100101
}
101102

102103
protected async Task<T> ExceptionHandlerAsync<T>(Func<Task<T>> action)

src/BAUERGROUP.Shared.Core/Application/ApplicationController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ namespace BAUERGROUP.Shared.Core.Application
99
/// <summary>
1010
/// Base class for application lifecycle management.
1111
/// </summary>
12-
public class ApplicationController: IDisposable
12+
public class ApplicationController : IDisposable
1313
{
1414
/// <summary>
1515
/// Initializes a new instance of the <see cref="ApplicationController"/> class.
1616
/// </summary>
1717
public ApplicationController()
1818
{
19-
2019
}
2120

2221
/// <summary>
2322
/// Releases all resources used by the <see cref="ApplicationController"/>.
23+
/// Subclasses should override this method to release managed resources.
2424
/// </summary>
25-
public void Dispose()
25+
public virtual void Dispose()
2626
{
27-
27+
GC.SuppressFinalize(this);
2828
}
2929
}
3030
}

src/BAUERGROUP.Shared.Core/ErrorTracking/BGErrorTracking.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private static string GetDefaultRelease()
101101
var version = assembly.GetName().Version;
102102
return $"{name}@{version}";
103103
}
104-
catch
104+
catch (Exception)
105105
{
106106
return "unknown";
107107
}

src/BAUERGROUP.Shared.Core/ErrorTracking/BGErrorTrackingConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public BGErrorTrackingConfiguration()
1717
var assembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();
1818
ApplicationName = Path.GetFileNameWithoutExtension(assembly.Location);
1919
}
20-
catch
20+
catch (Exception)
2121
{
2222
ApplicationName = "Unknown";
2323
}

src/BAUERGROUP.Shared.Core/Files/CSVFileReader.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public void Dispose()
4444

4545
_cr = null;
4646
_sr = null;
47+
48+
GC.SuppressFinalize(this);
4749
}
4850

4951
public void Close()

src/BAUERGROUP.Shared.Core/Files/CSVFileWriter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public void Dispose()
4545

4646
_cw = null;
4747
_sw = null;
48+
49+
GC.SuppressFinalize(this);
4850
}
4951

5052
public void Close()

src/BAUERGROUP.Shared.Core/Files/FileChangesMonitor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ private void OnFileChanged(Object sender, FileSystemEventArgs e)
3636
public void Dispose()
3737
{
3838
_fsw.Dispose();
39+
GC.SuppressFinalize(this);
3940
}
4041
}
4142
}

0 commit comments

Comments
 (0)