Fix nullable warning

This commit is contained in:
Luis von der Eltz
2021-09-08 14:06:49 +02:00
parent e783cffc51
commit 9506e433cc
@@ -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