From 006228647d82af4cf72e032f935e15d9fee39b8a Mon Sep 17 00:00:00 2001 From: efrick Date: Thu, 8 Aug 2024 11:35:31 -0400 Subject: [PATCH 1/5] Fix null literal warning in ConfForm. --- ConfForm.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ConfForm.cs b/ConfForm.cs index 6e93b70..8e112ee 100644 --- a/ConfForm.cs +++ b/ConfForm.cs @@ -17,11 +17,11 @@ namespace PDF_Merge { InitializeComponent(); - string sourcePath = ConfigurationManager.AppSettings["PDF-Path"]; - string outputPath = ConfigurationManager.AppSettings["PDF-Output"]; - string outputName = ConfigurationManager.AppSettings["PDF-Name"]; - string outputExt = ConfigurationManager.AppSettings["PDF-Extension"]; - string dateIndex = ConfigurationManager.AppSettings["dateIndex"]; + string sourcePath = ConfigurationManager.AppSettings["PDF-Path"] ?? ""; + string outputPath = ConfigurationManager.AppSettings["PDF-Output"] ?? ""; + string outputName = ConfigurationManager.AppSettings["PDF-Name"] ?? "merged"; + string outputExt = ConfigurationManager.AppSettings["PDF-Extension"] ?? ".pdf"; + string dateIndex = ConfigurationManager.AppSettings["dateIndex"] ?? "0"; int dateIndexValue; From d0a9bc9055167beb9951694934c0ddc7bc46d62f Mon Sep 17 00:00:00 2001 From: efrick Date: Thu, 8 Aug 2024 11:37:22 -0400 Subject: [PATCH 2/5] Fix null warning in MainForm --- MainForm.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MainForm.cs b/MainForm.cs index 6da352e..890bc0d 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -25,7 +25,7 @@ namespace PDF_Merge } public void SetPathLable() { - string sourcePath = ConfigurationManager.AppSettings["PDF-Path"]; + string sourcePath = ConfigurationManager.AppSettings["PDF-Path"] ?? ""; if (sourcePath != null) { From a1c79ab1f37981344039b42cf5f8d897cf50a79b Mon Sep 17 00:00:00 2001 From: efrick Date: Thu, 8 Aug 2024 11:41:02 -0400 Subject: [PATCH 3/5] Fixed null warning in MergePDFs --- MergePDFs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MergePDFs.cs b/MergePDFs.cs index 03ff9e2..d665a07 100644 --- a/MergePDFs.cs +++ b/MergePDFs.cs @@ -60,7 +60,7 @@ } public static string[] CollectPdfFiles() { - string dirPath = ConfigurationManager.AppSettings["PDF-Path"]; + string dirPath = ConfigurationManager.AppSettings["PDF-Path"] ?? ""; Console.WriteLine(dirPath); string[] pdfFiles = Directory.EnumerateFiles(dirPath, "*.pdf").ToArray(); Array.Sort(pdfFiles); @@ -81,7 +81,7 @@ public static string GetDate() { DateTime date = DateTime.Now; - string dateFormat = ConfigurationManager.AppSettings["dateFormat"]; + string dateFormat = ConfigurationManager.AppSettings["dateFormat"] ?? "yyyy-MM-dd"; return date.ToString(dateFormat); } } From 70cc9583af4e34bcb4a1797bdf1f1ed945bfbef9 Mon Sep 17 00:00:00 2001 From: efrick Date: Thu, 8 Aug 2024 12:36:16 -0400 Subject: [PATCH 4/5] Fix null warnings in AboutBox1 One warning was left because it should not ever return null unless the package has been damaged. --- AboutBox1.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AboutBox1.cs b/AboutBox1.cs index ae5d3a3..fb0f568 100644 --- a/AboutBox1.cs +++ b/AboutBox1.cs @@ -37,7 +37,7 @@ namespace PDF_Merge return titleAttribute.Title; } } - return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); + return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location); } } @@ -45,7 +45,7 @@ namespace PDF_Merge { get { - return Assembly.GetExecutingAssembly().GetName().Version.ToString(); + return Assembly.GetExecutingAssembly()?.GetName()?.Version?.ToString(); } } From cd64c19fa35208a6023e67a89f228624afd0fc12 Mon Sep 17 00:00:00 2001 From: efrick Date: Thu, 8 Aug 2024 12:36:16 -0400 Subject: [PATCH 5/5] Fix null warnings in AboutBox1 One warning was left because it should not ever return null unless the package has been damaged. All other warnings have been resolved. This should close issue #4. --- AboutBox1.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AboutBox1.cs b/AboutBox1.cs index ae5d3a3..fb0f568 100644 --- a/AboutBox1.cs +++ b/AboutBox1.cs @@ -37,7 +37,7 @@ namespace PDF_Merge return titleAttribute.Title; } } - return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); + return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location); } } @@ -45,7 +45,7 @@ namespace PDF_Merge { get { - return Assembly.GetExecutingAssembly().GetName().Version.ToString(); + return Assembly.GetExecutingAssembly()?.GetName()?.Version?.ToString(); } }