From 9506e433cc94cf4e5bd20c48709ffbd8c2a9c10b Mon Sep 17 00:00:00 2001 From: Luis von der Eltz Date: Wed, 8 Sep 2021 14:06:49 +0200 Subject: [PATCH] Fix nullable warning --- .../FreeDesktopApplicationContext.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/DesktopNotifications.FreeDesktop/FreeDesktopApplicationContext.cs b/DesktopNotifications.FreeDesktop/FreeDesktopApplicationContext.cs index baa868c..4e651fe 100644 --- a/DesktopNotifications.FreeDesktop/FreeDesktopApplicationContext.cs +++ b/DesktopNotifications.FreeDesktop/FreeDesktopApplicationContext.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.IO; namespace DesktopNotifications.FreeDesktop @@ -19,6 +20,12 @@ namespace DesktopNotifications.FreeDesktop public static FreeDesktopApplicationContext FromCurrentProcess(string? appIcon = null) { var mainModule = Process.GetCurrentProcess().MainModule; + + if (mainModule?.FileName == null) + { + throw new InvalidOperationException("No valid process module found."); + } + return new FreeDesktopApplicationContext( Path.GetFileNameWithoutExtension(mainModule.FileName), appIcon