Skip to content

Commit 12c5391

Browse files
authored
Merge pull request #932 from softworkz/submit_platform_specific
Webb app: add platform guards and promote analyzer severity
2 parents 8ba24c0 + a6d67a4 commit 12c5391

File tree

3 files changed

+39
-48
lines changed

3 files changed

+39
-48
lines changed

src/.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[*.cs]
2+
3+
# CA1416: Validate platform compatibility
4+
dotnet_diagnostic.CA1416.severity = error

src/ElectronNET.WebApp/Controllers/HomeController.cs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,20 @@ public IActionResult Index()
1010
{
1111
if (HybridSupport.IsElectronActive)
1212
{
13-
Electron.PowerMonitor.OnLockScreen += () =>
13+
if (OperatingSystem.IsMacOS() || OperatingSystem.IsWindows())
1414
{
15-
Console.WriteLine("Screen Locked detected from C#");
16-
};
15+
Electron.PowerMonitor.OnLockScreen += () => { Console.WriteLine("Screen Locked detected from C#"); };
1716

18-
Electron.PowerMonitor.OnUnLockScreen += () =>
19-
{
20-
Console.WriteLine("Screen unlocked detected from C# ");
21-
};
22-
23-
Electron.PowerMonitor.OnSuspend += () =>
24-
{
25-
Console.WriteLine("The system is going to sleep");
26-
};
17+
Electron.PowerMonitor.OnUnLockScreen += () => { Console.WriteLine("Screen unlocked detected from C# "); };
2718

28-
Electron.PowerMonitor.OnResume += () =>
29-
{
30-
Console.WriteLine("The system is resuming");
31-
};
19+
Electron.PowerMonitor.OnSuspend += () => { Console.WriteLine("The system is going to sleep"); };
3220

33-
Electron.PowerMonitor.OnAC += () =>
34-
{
35-
Console.WriteLine("The system changes to AC power");
36-
};
21+
Electron.PowerMonitor.OnResume += () => { Console.WriteLine("The system is resuming"); };
3722

38-
Electron.PowerMonitor.OnBattery += () =>
39-
{
40-
Console.WriteLine("The system is about to change to battery power");
41-
};
23+
Electron.PowerMonitor.OnAC += () => { Console.WriteLine("The system changes to AC power"); };
4224

25+
Electron.PowerMonitor.OnBattery += () => { Console.WriteLine("The system is about to change to battery power"); };
26+
}
4327
}
4428

4529
return View();

src/ElectronNET.WebApp/Program.cs

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,39 +55,42 @@ private static void AddDevelopmentTests()
5555
});
5656
});
5757

58-
Electron.Dock.SetMenu(new[]
58+
if (System.OperatingSystem.IsMacOS())
5959
{
60-
new MenuItem
60+
Electron.Dock.SetMenu(new[]
6161
{
62-
Type = MenuType.normal,
63-
Label = "MenuItem",
64-
Click = () =>
62+
new MenuItem
6563
{
66-
Electron.Notification.Show(new NotificationOptions(
67-
"Dock MenuItem Click",
68-
"A menu item added to the Dock was selected;"));
64+
Type = MenuType.normal,
65+
Label = "MenuItem",
66+
Click = () =>
67+
{
68+
Electron.Notification.Show(new NotificationOptions(
69+
"Dock MenuItem Click",
70+
"A menu item added to the Dock was selected;"));
71+
},
6972
},
70-
},
71-
new MenuItem
72-
{
73-
Type = MenuType.submenu,
74-
Label = "SubMenu",
75-
Submenu = new[]
73+
new MenuItem
7674
{
77-
new MenuItem
75+
Type = MenuType.submenu,
76+
Label = "SubMenu",
77+
Submenu = new[]
7878
{
79-
Type = MenuType.normal,
80-
Label = "Sub MenuItem",
81-
Click = () =>
79+
new MenuItem
8280
{
83-
Electron.Notification.Show(new NotificationOptions(
84-
"Dock Sub MenuItem Click",
85-
"A menu item added to the Dock was selected;"));
81+
Type = MenuType.normal,
82+
Label = "Sub MenuItem",
83+
Click = () =>
84+
{
85+
Electron.Notification.Show(new NotificationOptions(
86+
"Dock Sub MenuItem Click",
87+
"A menu item added to the Dock was selected;"));
88+
},
8689
},
87-
},
90+
}
8891
}
89-
}
90-
});
92+
});
93+
}
9194
}
9295
}
9396
}

0 commit comments

Comments
 (0)