Merge pull request #932 from softworkz/submit_platform_specific

Webb app: add platform guards and promote analyzer severity
This commit is contained in:
Florian Rappl
2025-11-15 12:34:57 +01:00
committed by GitHub
3 changed files with 42 additions and 51 deletions

4
src/.editorconfig Normal file
View File

@@ -0,0 +1,4 @@
[*.cs]
# CA1416: Validate platform compatibility
dotnet_diagnostic.CA1416.severity = error

View File

@@ -10,36 +10,20 @@ namespace ElectronNET.WebApp.Controllers
{
if (HybridSupport.IsElectronActive)
{
Electron.PowerMonitor.OnLockScreen += () =>
if (OperatingSystem.IsMacOS() || OperatingSystem.IsWindows())
{
Console.WriteLine("Screen Locked detected from C#");
};
Electron.PowerMonitor.OnLockScreen += () => { Console.WriteLine("Screen Locked detected from C#"); };
Electron.PowerMonitor.OnUnLockScreen += () =>
{
Console.WriteLine("Screen unlocked detected from C# ");
};
Electron.PowerMonitor.OnUnLockScreen += () => { Console.WriteLine("Screen unlocked detected from C# "); };
Electron.PowerMonitor.OnSuspend += () =>
{
Console.WriteLine("The system is going to sleep");
};
Electron.PowerMonitor.OnSuspend += () => { Console.WriteLine("The system is going to sleep"); };
Electron.PowerMonitor.OnResume += () =>
{
Console.WriteLine("The system is resuming");
};
Electron.PowerMonitor.OnResume += () => { Console.WriteLine("The system is resuming"); };
Electron.PowerMonitor.OnAC += () =>
{
Console.WriteLine("The system changes to AC power");
};
Electron.PowerMonitor.OnBattery += () =>
{
Console.WriteLine("The system is about to change to battery power");
};
Electron.PowerMonitor.OnAC += () => { Console.WriteLine("The system changes to AC power"); };
Electron.PowerMonitor.OnBattery += () => { Console.WriteLine("The system is about to change to battery power"); };
}
}
return View();

View File

@@ -55,39 +55,42 @@ namespace ElectronNET.WebApp
});
});
Electron.Dock.SetMenu(new[]
if (System.OperatingSystem.IsMacOS())
{
new MenuItem
Electron.Dock.SetMenu(new[]
{
Type = MenuType.normal,
Label = "MenuItem",
Click = () =>
new MenuItem
{
Electron.Notification.Show(new NotificationOptions(
"Dock MenuItem Click",
"A menu item added to the Dock was selected;"));
},
},
new MenuItem
{
Type = MenuType.submenu,
Label = "SubMenu",
Submenu = new[]
{
new MenuItem
Type = MenuType.normal,
Label = "MenuItem",
Click = () =>
{
Type = MenuType.normal,
Label = "Sub MenuItem",
Click = () =>
{
Electron.Notification.Show(new NotificationOptions(
"Dock Sub MenuItem Click",
"A menu item added to the Dock was selected;"));
},
Electron.Notification.Show(new NotificationOptions(
"Dock MenuItem Click",
"A menu item added to the Dock was selected;"));
},
},
new MenuItem
{
Type = MenuType.submenu,
Label = "SubMenu",
Submenu = new[]
{
new MenuItem
{
Type = MenuType.normal,
Label = "Sub MenuItem",
Click = () =>
{
Electron.Notification.Show(new NotificationOptions(
"Dock Sub MenuItem Click",
"A menu item added to the Dock was selected;"));
},
},
}
}
}
});
});
}
}
}
}