From 2c799fe9e9415482921715346a6fc986661e7a8b Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 18:40:58 +0000 Subject: [PATCH 1/2] refactor: use typeof for assembly retrieval This PR refactors how we obtain the executing assembly's file location by replacing reflection-based GetExecutingAssembly() calls with a direct typeof(Program).Assembly reference. This change improves type safety, clarity, and reduces potential runtime ambiguities. - Consider using `typeof(T).Assembly` to get currently executing assembly: The original code used System.Reflection.Assembly.GetExecutingAssembly().Location to locate the assembly at runtime, which relies on reflection and may not clearly indicate which assembly is in use, especially in multi-assembly scenarios. The updated code replaces this with typeof(Program).Assembly.Location, providing an explicit, compile-time validated reference that is easier to understand and maintain. > This Autofix was generated by AI. Please review the change before merging. --- CallbackHandler/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CallbackHandler/Program.cs b/CallbackHandler/Program.cs index 763aae1..7ab1a56 100644 --- a/CallbackHandler/Program.cs +++ b/CallbackHandler/Program.cs @@ -31,7 +31,7 @@ public static void Main(string[] args) public static IHostBuilder CreateHostBuilder(string[] args) { //At this stage, we only need our hosting file for ip and ports - FileInfo fi = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location); + FileInfo fi = new FileInfo(typeof(Program).Assembly.Location); IConfigurationRoot config = new ConfigurationBuilder().SetBasePath(fi.Directory.FullName) .AddJsonFile("hosting.json", optional: true) From fead622ee75de60557e956af1b2f6533bc60eb15 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 18:46:34 +0000 Subject: [PATCH 2/2] refactor: drop redundant type from new expression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR removes redundant type declarations in object instantiation by leveraging C# 9's target-typed new expressions to enhance code readability and reduce verbosity. - Type can be dropped from the declaration's RHS when explicitly mentioned in the LHS: The original code declared a FileInfo instance with an explicit type on both sides of the assignment, leading to repetition. We refactored the instantiation to use the target-typed new (i.e., ‘new(...)’), removing the duplicated type information and adhering to modern C# conventions, which streamlines the code. > This Autofix was generated by AI. Please review the change before merging. --- CallbackHandler/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CallbackHandler/Program.cs b/CallbackHandler/Program.cs index 7ab1a56..4a0c7c6 100644 --- a/CallbackHandler/Program.cs +++ b/CallbackHandler/Program.cs @@ -31,7 +31,7 @@ public static void Main(string[] args) public static IHostBuilder CreateHostBuilder(string[] args) { //At this stage, we only need our hosting file for ip and ports - FileInfo fi = new FileInfo(typeof(Program).Assembly.Location); + FileInfo fi = new(typeof(Program).Assembly.Location); IConfigurationRoot config = new ConfigurationBuilder().SetBasePath(fi.Directory.FullName) .AddJsonFile("hosting.json", optional: true)