Skip to content

Commit f53d071

Browse files
authored
Merge pull request #929 from softworkz/submit_platform_annotations
ElectronNET.API: Add platform support attributes
2 parents 8e8d88c + 2cf3095 commit f53d071

File tree

12 files changed

+185
-13
lines changed

12 files changed

+185
-13
lines changed

src/ElectronNET.API/API/App.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using ElectronNET.API.Extensions;
33
using System;
44
using System.Runtime.InteropServices;
5+
using System.Runtime.Versioning;
56
using System.Text.Json;
67
using System.Threading;
78
using System.Threading.Tasks;
@@ -259,6 +260,8 @@ public event Action WebContentsCreated
259260
/// screen readers, are enabled or disabled. See https://www.chromium.org/developers/design-documents/accessibility for more details.
260261
/// </summary>
261262
/// <returns><see langword="true"/> when Chrome's accessibility support is enabled, <see langword="false"/> otherwise.</returns>
263+
[SupportedOSPlatform("macOS")]
264+
[SupportedOSPlatform("Windows")]
262265
public event Action<bool> AccessibilitySupportChanged
263266
{
264267
add => AddEvent(value, GetHashCode());
@@ -316,6 +319,7 @@ internal set
316319
/// <para/>
317320
/// On Windows, you have to parse the arguments using App.CommandLine to get the filepath.
318321
/// </summary>
322+
[SupportedOSPlatform("macOS")]
319323
public event Action<string> OpenFile
320324
{
321325
add => AddEvent(value, GetHashCode());
@@ -327,6 +331,7 @@ public event Action<string> OpenFile
327331
/// Emitted when a MacOS user wants to open a URL with the application. Your application's Info.plist file must
328332
/// define the URL scheme within the CFBundleURLTypes key, and set NSPrincipalClass to AtomApplication.
329333
/// </summary>
334+
[SupportedOSPlatform("macOS")]
330335
public event Action<string> OpenUrl
331336
{
332337
add => AddEvent(value, GetHashCode());
@@ -481,6 +486,7 @@ public void Focus(FocusOptions focusOptions)
481486
/// <summary>
482487
/// Hides all application windows without minimizing them.
483488
/// </summary>
489+
[SupportedOSPlatform("macOS")]
484490
public void Hide()
485491
{
486492
this.CallMethod0();
@@ -489,6 +495,7 @@ public void Hide()
489495
/// <summary>
490496
/// Shows application windows after they were hidden. Does not automatically focus them.
491497
/// </summary>
498+
[SupportedOSPlatform("macOS")]
492499
public void Show()
493500
{
494501
this.CallMethod0();
@@ -586,6 +593,8 @@ public async Task<string> GetLocaleAsync(CancellationToken cancellationToken = d
586593
/// list from the task bar, and on macOS you can visit it from dock menu.
587594
/// </summary>
588595
/// <param name="path">Path to add.</param>
596+
[SupportedOSPlatform("macOS")]
597+
[SupportedOSPlatform("Windows")]
589598
public void AddRecentDocument(string path)
590599
{
591600
this.CallMethod1(path);
@@ -594,6 +603,8 @@ public void AddRecentDocument(string path)
594603
/// <summary>
595604
/// Clears the recent documents list.
596605
/// </summary>
606+
[SupportedOSPlatform("macOS")]
607+
[SupportedOSPlatform("Windows")]
597608
public void ClearRecentDocuments()
598609
{
599610
this.CallMethod0();
@@ -709,6 +720,8 @@ public async Task<bool> SetAsDefaultProtocolClientAsync(string protocol, string
709720
/// <param name="protocol">The name of your protocol, without ://.</param>
710721
/// <param name="cancellationToken">The cancellation token.</param>
711722
/// <returns>Whether the call succeeded.</returns>
723+
[SupportedOSPlatform("macOS")]
724+
[SupportedOSPlatform("Windows")]
712725
public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, CancellationToken cancellationToken = default)
713726
{
714727
return await this.RemoveAsDefaultProtocolClientAsync(protocol, null, null, cancellationToken).ConfigureAwait(false);
@@ -722,6 +735,8 @@ public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, Canc
722735
/// <param name="path">Defaults to process.execPath.</param>
723736
/// <param name="cancellationToken">The cancellation token.</param>
724737
/// <returns>Whether the call succeeded.</returns>
738+
[SupportedOSPlatform("macOS")]
739+
[SupportedOSPlatform("Windows")]
725740
public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path, CancellationToken cancellationToken = default)
726741
{
727742
return await this.RemoveAsDefaultProtocolClientAsync(protocol, path, null, cancellationToken).ConfigureAwait(false);
@@ -736,6 +751,8 @@ public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, stri
736751
/// <param name="args">Defaults to an empty array.</param>
737752
/// <param name="cancellationToken">The cancellation token.</param>
738753
/// <returns>Whether the call succeeded.</returns>
754+
[SupportedOSPlatform("macOS")]
755+
[SupportedOSPlatform("Windows")]
739756
public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default)
740757
{
741758
cancellationToken.ThrowIfCancellationRequested();
@@ -826,6 +843,7 @@ public async Task<bool> IsDefaultProtocolClientAsync(string protocol, string pat
826843
/// <param name="userTasks">Array of <see cref="UserTask"/> objects.</param>
827844
/// <param name="cancellationToken">The cancellation token.</param>
828845
/// <returns>Whether the call succeeded.</returns>
846+
[SupportedOSPlatform("Windows")]
829847
public async Task<bool> SetUserTasksAsync(UserTask[] userTasks, CancellationToken cancellationToken = default)
830848
{
831849
cancellationToken.ThrowIfCancellationRequested();
@@ -846,6 +864,7 @@ public async Task<bool> SetUserTasksAsync(UserTask[] userTasks, CancellationToke
846864
/// </summary>
847865
/// <param name="cancellationToken">The cancellation token.</param>
848866
/// <returns>Jump List settings.</returns>
867+
[SupportedOSPlatform("Windows")]
849868
public async Task<JumpListSettings> GetJumpListSettingsAsync(CancellationToken cancellationToken = default)
850869
{
851870
cancellationToken.ThrowIfCancellationRequested();
@@ -868,6 +887,7 @@ public async Task<JumpListSettings> GetJumpListSettingsAsync(CancellationToken c
868887
/// omitted from the Jump List. The list of removed items can be obtained using <see cref="GetJumpListSettingsAsync"/>.
869888
/// </summary>
870889
/// <param name="categories">Array of <see cref="JumpListCategory"/> objects.</param>
890+
[SupportedOSPlatform("Windows")]
871891
public void SetJumpList(JumpListCategory[] categories)
872892
{
873893
this.CallMethod1(categories);
@@ -950,6 +970,7 @@ public async Task<bool> HasSingleInstanceLockAsync(CancellationToken cancellatio
950970
/// </summary>
951971
/// <param name="type">Uniquely identifies the activity. Maps to <see href="https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSUserActivity_Class/index.html#//apple_ref/occ/instp/NSUserActivity/activityType">NSUserActivity.activityType</see>.</param>
952972
/// <param name="userInfo">App-specific state to store for use by another device.</param>
973+
[SupportedOSPlatform("macOS")]
953974
public void SetUserActivity(string type, object userInfo)
954975
{
955976
SetUserActivity(type, userInfo, null);
@@ -967,6 +988,7 @@ public void SetUserActivity(string type, object userInfo)
967988
/// <param name="webpageUrl">
968989
/// The webpage to load in a browser if no suitable app is installed on the resuming device. The scheme must be http or https.
969990
/// </param>
991+
[SupportedOSPlatform("macOS")]
970992
public void SetUserActivity(string type, object userInfo, string webpageUrl)
971993
{
972994
this.CallMethod3(type, userInfo, webpageUrl);
@@ -976,6 +998,7 @@ public void SetUserActivity(string type, object userInfo, string webpageUrl)
976998
/// The type of the currently running activity.
977999
/// </summary>
9781000
/// <param name="cancellationToken">The cancellation token.</param>
1001+
[SupportedOSPlatform("macOS")]
9791002
public async Task<string> GetCurrentActivityTypeAsync(CancellationToken cancellationToken = default)
9801003
{
9811004
cancellationToken.ThrowIfCancellationRequested();
@@ -985,6 +1008,7 @@ public async Task<string> GetCurrentActivityTypeAsync(CancellationToken cancella
9851008
/// <summary>
9861009
/// Invalidates the current <see href="https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html">Handoff</see> user activity.
9871010
/// </summary>
1011+
[SupportedOSPlatform("macOS")]
9881012
public void InvalidateCurrentActivity()
9891013
{
9901014
this.CallMethod0();
@@ -993,6 +1017,7 @@ public void InvalidateCurrentActivity()
9931017
/// <summary>
9941018
/// Marks the current <see href="https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html">Handoff</see> user activity as inactive without invalidating it.
9951019
/// </summary>
1020+
[SupportedOSPlatform("macOS")]
9961021
public void ResignCurrentActivity()
9971022
{
9981023
this.CallMethod0();
@@ -1002,6 +1027,7 @@ public void ResignCurrentActivity()
10021027
/// Changes the <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx">Application User Model ID</see> to id.
10031028
/// </summary>
10041029
/// <param name="id">Model Id.</param>
1030+
[SupportedOSPlatform("Windows")]
10051031
public void SetAppUserModelId(string id)
10061032
{
10071033
this.CallMethod1(id);
@@ -1016,6 +1042,7 @@ public void SetAppUserModelId(string id)
10161042
/// <param name="options"></param>
10171043
/// <param name="cancellationToken">The cancellation token.</param>
10181044
/// <returns>Result of import. Value of 0 indicates success.</returns>
1045+
[SupportedOSPlatform("Linux")]
10191046
public async Task<int> ImportCertificateAsync(ImportCertificateOptions options, CancellationToken cancellationToken = default)
10201047
{
10211048
cancellationToken.ThrowIfCancellationRequested();
@@ -1067,6 +1094,8 @@ public async Task<GPUFeatureStatus> GetGpuFeatureStatusAsync(CancellationToken c
10671094
/// <param name="count">Counter badge.</param>
10681095
/// <param name="cancellationToken">The cancellation token.</param>
10691096
/// <returns>Whether the call succeeded.</returns>
1097+
[SupportedOSPlatform("Linux")]
1098+
[SupportedOSPlatform("macOS")]
10701099
public async Task<bool> SetBadgeCountAsync(int count, CancellationToken cancellationToken = default)
10711100
{
10721101
cancellationToken.ThrowIfCancellationRequested();
@@ -1086,6 +1115,8 @@ public async Task<bool> SetBadgeCountAsync(int count, CancellationToken cancella
10861115
/// The current value displayed in the counter badge.
10871116
/// </summary>
10881117
/// <param name="cancellationToken">The cancellation token.</param>
1118+
[SupportedOSPlatform("Linux")]
1119+
[SupportedOSPlatform("macOS")]
10891120
public async Task<int> GetBadgeCountAsync(CancellationToken cancellationToken = default)
10901121
{
10911122
cancellationToken.ThrowIfCancellationRequested();
@@ -1101,6 +1132,7 @@ public async Task<int> GetBadgeCountAsync(CancellationToken cancellationToken =
11011132
/// Whether the current desktop environment is Unity launcher.
11021133
/// </summary>
11031134
/// <param name="cancellationToken">The cancellation token.</param>
1135+
[SupportedOSPlatform("Linux")]
11041136
public async Task<bool> IsUnityRunningAsync(CancellationToken cancellationToken = default)
11051137
{
11061138
cancellationToken.ThrowIfCancellationRequested();
@@ -1111,6 +1143,8 @@ public async Task<bool> IsUnityRunningAsync(CancellationToken cancellationToken
11111143
/// If you provided path and args options to <see cref="SetLoginItemSettings"/> then you need to pass the same
11121144
/// arguments here for <see cref="LoginItemSettings.OpenAtLogin"/> to be set correctly.
11131145
/// </summary>
1146+
[SupportedOSPlatform("macOS")]
1147+
[SupportedOSPlatform("Windows")]
11141148
public async Task<LoginItemSettings> GetLoginItemSettingsAsync(CancellationToken cancellationToken = default)
11151149
{
11161150
return await this.GetLoginItemSettingsAsync(null, cancellationToken).ConfigureAwait(false);
@@ -1122,6 +1156,8 @@ public async Task<LoginItemSettings> GetLoginItemSettingsAsync(CancellationToken
11221156
/// </summary>
11231157
/// <param name="options"></param>
11241158
/// <param name="cancellationToken">The cancellation token.</param>
1159+
[SupportedOSPlatform("macOS")]
1160+
[SupportedOSPlatform("Windows")]
11251161
public async Task<LoginItemSettings> GetLoginItemSettingsAsync(LoginItemSettingsOptions options, CancellationToken cancellationToken = default)
11261162
{
11271163
cancellationToken.ThrowIfCancellationRequested();
@@ -1151,6 +1187,8 @@ public async Task<LoginItemSettings> GetLoginItemSettingsAsync(LoginItemSettings
11511187
/// you'll want to set the launch path to Update.exe, and pass arguments that specify your application name.
11521188
/// </summary>
11531189
/// <param name="loginSettings"></param>
1190+
[SupportedOSPlatform("macOS")]
1191+
[SupportedOSPlatform("Windows")]
11541192
public void SetLoginItemSettings(LoginSettings loginSettings)
11551193
{
11561194
this.CallMethod1(loginSettings);
@@ -1162,6 +1200,8 @@ public void SetLoginItemSettings(LoginSettings loginSettings)
11621200
/// See <see href="chromium.org/developers/design-documents/accessibility">Chromium's accessibility docs</see> for more details.
11631201
/// </summary>
11641202
/// <returns><see langword="true"/> if Chrome’s accessibility support is enabled, <see langword="false"/> otherwise.</returns>
1203+
[SupportedOSPlatform("macOS")]
1204+
[SupportedOSPlatform("Windows")]
11651205
public async Task<bool> IsAccessibilitySupportEnabledAsync(CancellationToken cancellationToken = default)
11661206
{
11671207
cancellationToken.ThrowIfCancellationRequested();
@@ -1178,6 +1218,8 @@ public async Task<bool> IsAccessibilitySupportEnabledAsync(CancellationToken can
11781218
/// Note: Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
11791219
/// </summary>
11801220
/// <param name="enabled">Enable or disable <see href="https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/the-accessibility-tree">accessibility tree</see> rendering.</param>
1221+
[SupportedOSPlatform("macOS")]
1222+
[SupportedOSPlatform("Windows")]
11811223
public void SetAccessibilitySupportEnabled(bool enabled)
11821224
{
11831225
this.CallMethod1(enabled);

0 commit comments

Comments
 (0)