Skip to content

Commit 265383e

Browse files
committed
ElectronNET API: Add platform support attributes
1 parent 7889057 commit 265383e

File tree

11 files changed

+167
-13
lines changed

11 files changed

+167
-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());
@@ -482,6 +487,7 @@ public void Focus(FocusOptions focusOptions)
482487
/// <summary>
483488
/// Hides all application windows without minimizing them.
484489
/// </summary>
490+
[SupportedOSPlatform("macOS")]
485491
public void Hide()
486492
{
487493
this.CallMethod0();
@@ -490,6 +496,7 @@ public void Hide()
490496
/// <summary>
491497
/// Shows application windows after they were hidden. Does not automatically focus them.
492498
/// </summary>
499+
[SupportedOSPlatform("macOS")]
493500
public void Show()
494501
{
495502
this.CallMethod0();
@@ -587,6 +594,8 @@ public async Task<string> GetLocaleAsync(CancellationToken cancellationToken = d
587594
/// list from the task bar, and on macOS you can visit it from dock menu.
588595
/// </summary>
589596
/// <param name="path">Path to add.</param>
597+
[SupportedOSPlatform("macOS")]
598+
[SupportedOSPlatform("Windows")]
590599
public void AddRecentDocument(string path)
591600
{
592601
this.CallMethod1(path);
@@ -595,6 +604,8 @@ public void AddRecentDocument(string path)
595604
/// <summary>
596605
/// Clears the recent documents list.
597606
/// </summary>
607+
[SupportedOSPlatform("macOS")]
608+
[SupportedOSPlatform("Windows")]
598609
public void ClearRecentDocuments()
599610
{
600611
this.CallMethod0();
@@ -710,6 +721,8 @@ public async Task<bool> SetAsDefaultProtocolClientAsync(string protocol, string
710721
/// <param name="protocol">The name of your protocol, without ://.</param>
711722
/// <param name="cancellationToken">The cancellation token.</param>
712723
/// <returns>Whether the call succeeded.</returns>
724+
[SupportedOSPlatform("macOS")]
725+
[SupportedOSPlatform("Windows")]
713726
public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, CancellationToken cancellationToken = default)
714727
{
715728
return await this.RemoveAsDefaultProtocolClientAsync(protocol, null, null, cancellationToken).ConfigureAwait(false);
@@ -723,6 +736,8 @@ public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, Canc
723736
/// <param name="path">Defaults to process.execPath.</param>
724737
/// <param name="cancellationToken">The cancellation token.</param>
725738
/// <returns>Whether the call succeeded.</returns>
739+
[SupportedOSPlatform("macOS")]
740+
[SupportedOSPlatform("Windows")]
726741
public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path, CancellationToken cancellationToken = default)
727742
{
728743
return await this.RemoveAsDefaultProtocolClientAsync(protocol, path, null, cancellationToken).ConfigureAwait(false);
@@ -737,6 +752,8 @@ public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, stri
737752
/// <param name="args">Defaults to an empty array.</param>
738753
/// <param name="cancellationToken">The cancellation token.</param>
739754
/// <returns>Whether the call succeeded.</returns>
755+
[SupportedOSPlatform("macOS")]
756+
[SupportedOSPlatform("Windows")]
740757
public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default)
741758
{
742759
cancellationToken.ThrowIfCancellationRequested();
@@ -827,6 +844,7 @@ public async Task<bool> IsDefaultProtocolClientAsync(string protocol, string pat
827844
/// <param name="userTasks">Array of <see cref="UserTask"/> objects.</param>
828845
/// <param name="cancellationToken">The cancellation token.</param>
829846
/// <returns>Whether the call succeeded.</returns>
847+
[SupportedOSPlatform("Windows")]
830848
public async Task<bool> SetUserTasksAsync(UserTask[] userTasks, CancellationToken cancellationToken = default)
831849
{
832850
cancellationToken.ThrowIfCancellationRequested();
@@ -847,6 +865,7 @@ public async Task<bool> SetUserTasksAsync(UserTask[] userTasks, CancellationToke
847865
/// </summary>
848866
/// <param name="cancellationToken">The cancellation token.</param>
849867
/// <returns>Jump List settings.</returns>
868+
[SupportedOSPlatform("Windows")]
850869
public async Task<JumpListSettings> GetJumpListSettingsAsync(CancellationToken cancellationToken = default)
851870
{
852871
cancellationToken.ThrowIfCancellationRequested();
@@ -869,6 +888,7 @@ public async Task<JumpListSettings> GetJumpListSettingsAsync(CancellationToken c
869888
/// omitted from the Jump List. The list of removed items can be obtained using <see cref="GetJumpListSettingsAsync"/>.
870889
/// </summary>
871890
/// <param name="categories">Array of <see cref="JumpListCategory"/> objects.</param>
891+
[SupportedOSPlatform("Windows")]
872892
public void SetJumpList(JumpListCategory[] categories)
873893
{
874894
this.CallMethod1(categories);
@@ -951,6 +971,7 @@ public async Task<bool> HasSingleInstanceLockAsync(CancellationToken cancellatio
951971
/// </summary>
952972
/// <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>
953973
/// <param name="userInfo">App-specific state to store for use by another device.</param>
974+
[SupportedOSPlatform("macOS")]
954975
public void SetUserActivity(string type, object userInfo)
955976
{
956977
SetUserActivity(type, userInfo, null);
@@ -968,6 +989,7 @@ public void SetUserActivity(string type, object userInfo)
968989
/// <param name="webpageUrl">
969990
/// The webpage to load in a browser if no suitable app is installed on the resuming device. The scheme must be http or https.
970991
/// </param>
992+
[SupportedOSPlatform("macOS")]
971993
public void SetUserActivity(string type, object userInfo, string webpageUrl)
972994
{
973995
this.CallMethod3(type, userInfo, webpageUrl);
@@ -977,6 +999,7 @@ public void SetUserActivity(string type, object userInfo, string webpageUrl)
977999
/// The type of the currently running activity.
9781000
/// </summary>
9791001
/// <param name="cancellationToken">The cancellation token.</param>
1002+
[SupportedOSPlatform("macOS")]
9801003
public async Task<string> GetCurrentActivityTypeAsync(CancellationToken cancellationToken = default)
9811004
{
9821005
cancellationToken.ThrowIfCancellationRequested();
@@ -986,6 +1009,7 @@ public async Task<string> GetCurrentActivityTypeAsync(CancellationToken cancella
9861009
/// <summary>
9871010
/// Invalidates the current <see href="https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html">Handoff</see> user activity.
9881011
/// </summary>
1012+
[SupportedOSPlatform("macOS")]
9891013
public void InvalidateCurrentActivity()
9901014
{
9911015
this.CallMethod0();
@@ -994,6 +1018,7 @@ public void InvalidateCurrentActivity()
9941018
/// <summary>
9951019
/// 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.
9961020
/// </summary>
1021+
[SupportedOSPlatform("macOS")]
9971022
public void ResignCurrentActivity()
9981023
{
9991024
this.CallMethod0();
@@ -1003,6 +1028,7 @@ public void ResignCurrentActivity()
10031028
/// 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.
10041029
/// </summary>
10051030
/// <param name="id">Model Id.</param>
1031+
[SupportedOSPlatform("Windows")]
10061032
public void SetAppUserModelId(string id)
10071033
{
10081034
this.CallMethod1(id);
@@ -1017,6 +1043,7 @@ public void SetAppUserModelId(string id)
10171043
/// <param name="options"></param>
10181044
/// <param name="cancellationToken">The cancellation token.</param>
10191045
/// <returns>Result of import. Value of 0 indicates success.</returns>
1046+
[SupportedOSPlatform("Linux")]
10201047
public async Task<int> ImportCertificateAsync(ImportCertificateOptions options, CancellationToken cancellationToken = default)
10211048
{
10221049
cancellationToken.ThrowIfCancellationRequested();
@@ -1068,6 +1095,8 @@ public async Task<GPUFeatureStatus> GetGpuFeatureStatusAsync(CancellationToken c
10681095
/// <param name="count">Counter badge.</param>
10691096
/// <param name="cancellationToken">The cancellation token.</param>
10701097
/// <returns>Whether the call succeeded.</returns>
1098+
[SupportedOSPlatform("Linux")]
1099+
[SupportedOSPlatform("macOS")]
10711100
public async Task<bool> SetBadgeCountAsync(int count, CancellationToken cancellationToken = default)
10721101
{
10731102
cancellationToken.ThrowIfCancellationRequested();
@@ -1087,6 +1116,8 @@ public async Task<bool> SetBadgeCountAsync(int count, CancellationToken cancella
10871116
/// The current value displayed in the counter badge.
10881117
/// </summary>
10891118
/// <param name="cancellationToken">The cancellation token.</param>
1119+
[SupportedOSPlatform("Linux")]
1120+
[SupportedOSPlatform("macOS")]
10901121
public async Task<int> GetBadgeCountAsync(CancellationToken cancellationToken = default)
10911122
{
10921123
cancellationToken.ThrowIfCancellationRequested();
@@ -1102,6 +1133,7 @@ public async Task<int> GetBadgeCountAsync(CancellationToken cancellationToken =
11021133
/// Whether the current desktop environment is Unity launcher.
11031134
/// </summary>
11041135
/// <param name="cancellationToken">The cancellation token.</param>
1136+
[SupportedOSPlatform("Linux")]
11051137
public async Task<bool> IsUnityRunningAsync(CancellationToken cancellationToken = default)
11061138
{
11071139
cancellationToken.ThrowIfCancellationRequested();
@@ -1112,6 +1144,8 @@ public async Task<bool> IsUnityRunningAsync(CancellationToken cancellationToken
11121144
/// If you provided path and args options to <see cref="SetLoginItemSettings"/> then you need to pass the same
11131145
/// arguments here for <see cref="LoginItemSettings.OpenAtLogin"/> to be set correctly.
11141146
/// </summary>
1147+
[SupportedOSPlatform("macOS")]
1148+
[SupportedOSPlatform("Windows")]
11151149
public async Task<LoginItemSettings> GetLoginItemSettingsAsync(CancellationToken cancellationToken = default)
11161150
{
11171151
return await this.GetLoginItemSettingsAsync(null, cancellationToken).ConfigureAwait(false);
@@ -1123,6 +1157,8 @@ public async Task<LoginItemSettings> GetLoginItemSettingsAsync(CancellationToken
11231157
/// </summary>
11241158
/// <param name="options"></param>
11251159
/// <param name="cancellationToken">The cancellation token.</param>
1160+
[SupportedOSPlatform("macOS")]
1161+
[SupportedOSPlatform("Windows")]
11261162
public async Task<LoginItemSettings> GetLoginItemSettingsAsync(LoginItemSettingsOptions options, CancellationToken cancellationToken = default)
11271163
{
11281164
cancellationToken.ThrowIfCancellationRequested();
@@ -1152,6 +1188,8 @@ public async Task<LoginItemSettings> GetLoginItemSettingsAsync(LoginItemSettings
11521188
/// you'll want to set the launch path to Update.exe, and pass arguments that specify your application name.
11531189
/// </summary>
11541190
/// <param name="loginSettings"></param>
1191+
[SupportedOSPlatform("macOS")]
1192+
[SupportedOSPlatform("Windows")]
11551193
public void SetLoginItemSettings(LoginSettings loginSettings)
11561194
{
11571195
this.CallMethod1(loginSettings);
@@ -1163,6 +1201,8 @@ public void SetLoginItemSettings(LoginSettings loginSettings)
11631201
/// See <see href="chromium.org/developers/design-documents/accessibility">Chromium's accessibility docs</see> for more details.
11641202
/// </summary>
11651203
/// <returns><see langword="true"/> if Chrome’s accessibility support is enabled, <see langword="false"/> otherwise.</returns>
1204+
[SupportedOSPlatform("macOS")]
1205+
[SupportedOSPlatform("Windows")]
11661206
public async Task<bool> IsAccessibilitySupportEnabledAsync(CancellationToken cancellationToken = default)
11671207
{
11681208
cancellationToken.ThrowIfCancellationRequested();
@@ -1179,6 +1219,8 @@ public async Task<bool> IsAccessibilitySupportEnabledAsync(CancellationToken can
11791219
/// Note: Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
11801220
/// </summary>
11811221
/// <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>
1222+
[SupportedOSPlatform("macOS")]
1223+
[SupportedOSPlatform("Windows")]
11821224
public void SetAccessibilitySupportEnabled(bool enabled)
11831225
{
11841226
this.CallMethod1(enabled);

0 commit comments

Comments
 (0)