Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ElectronNET.API/API/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ public Task ShowCertificateTrustDialogAsync(CertificateTrustDialogOptions option
[SupportedOSPlatform("Windows")]
public Task ShowCertificateTrustDialogAsync(BrowserWindow browserWindow, CertificateTrustDialogOptions options)
{
var tcs = new TaskCompletionSource<object>();
var tcs = new TaskCompletionSource();
string guid = Guid.NewGuid().ToString();

BridgeConnector.Socket.Once("showCertificateTrustDialogComplete" + guid, () => tcs.SetResult(null));
BridgeConnector.Socket.Once("showCertificateTrustDialogComplete" + guid, () => tcs.SetResult());
BridgeConnector.Socket.Emit("showCertificateTrustDialog",
browserWindow,
options,
Expand Down
28 changes: 14 additions & 14 deletions src/ElectronNET.API/API/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public void AllowNTLMCredentialsForDomains(string domains)
/// <returns></returns>
public Task ClearAuthCacheAsync(RemovePassword options)
{
var tcs = new TaskCompletionSource<object>();
var tcs = new TaskCompletionSource();
string guid = Guid.NewGuid().ToString();

BridgeConnector.Socket.Once("webContents-session-clearAuthCache-completed" + guid, () => tcs.SetResult(null));
BridgeConnector.Socket.Once("webContents-session-clearAuthCache-completed" + guid, () => tcs.SetResult());
BridgeConnector.Socket.Emit("webContents-session-clearAuthCache", Id, options, guid);

return tcs.Task;
Expand All @@ -61,10 +61,10 @@ public Task ClearAuthCacheAsync(RemovePassword options)
/// </summary>
public Task ClearAuthCacheAsync()
{
var tcs = new TaskCompletionSource<object>();
var tcs = new TaskCompletionSource();
string guid = Guid.NewGuid().ToString();

BridgeConnector.Socket.Once("webContents-session-clearAuthCache-completed" + guid, () => tcs.SetResult(null));
BridgeConnector.Socket.Once("webContents-session-clearAuthCache-completed" + guid, () => tcs.SetResult());
BridgeConnector.Socket.Emit("webContents-session-clearAuthCache", Id, guid);

return tcs.Task;
Expand All @@ -76,10 +76,10 @@ public Task ClearAuthCacheAsync()
/// <returns></returns>
public Task ClearCacheAsync()
{
var tcs = new TaskCompletionSource<object>();
var tcs = new TaskCompletionSource();
string guid = Guid.NewGuid().ToString();

BridgeConnector.Socket.Once("webContents-session-clearCache-completed" + guid, () => tcs.SetResult(null));
BridgeConnector.Socket.Once("webContents-session-clearCache-completed" + guid, () => tcs.SetResult());
BridgeConnector.Socket.Emit("webContents-session-clearCache", Id, guid);

return tcs.Task;
Expand All @@ -91,10 +91,10 @@ public Task ClearCacheAsync()
/// <returns></returns>
public Task ClearHostResolverCacheAsync()
{
var tcs = new TaskCompletionSource<object>();
var tcs = new TaskCompletionSource();
string guid = Guid.NewGuid().ToString();

BridgeConnector.Socket.Once("webContents-session-clearHostResolverCache-completed" + guid, () => tcs.SetResult(null));
BridgeConnector.Socket.Once("webContents-session-clearHostResolverCache-completed" + guid, () => tcs.SetResult());
BridgeConnector.Socket.Emit("webContents-session-clearHostResolverCache", Id, guid);

return tcs.Task;
Expand All @@ -106,10 +106,10 @@ public Task ClearHostResolverCacheAsync()
/// <returns></returns>
public Task ClearStorageDataAsync()
{
var tcs = new TaskCompletionSource<object>();
var tcs = new TaskCompletionSource();
string guid = Guid.NewGuid().ToString();

BridgeConnector.Socket.Once("webContents-session-clearStorageData-completed" + guid, () => tcs.SetResult(null));
BridgeConnector.Socket.Once("webContents-session-clearStorageData-completed" + guid, () => tcs.SetResult());
BridgeConnector.Socket.Emit("webContents-session-clearStorageData", Id, guid);

return tcs.Task;
Expand All @@ -122,10 +122,10 @@ public Task ClearStorageDataAsync()
/// <returns></returns>
public Task ClearStorageDataAsync(ClearStorageDataOptions options)
{
var tcs = new TaskCompletionSource<object>();
var tcs = new TaskCompletionSource();
string guid = Guid.NewGuid().ToString();

BridgeConnector.Socket.Once("webContents-session-clearStorageData-options-completed" + guid, () => tcs.SetResult(null));
BridgeConnector.Socket.Once("webContents-session-clearStorageData-options-completed" + guid, () => tcs.SetResult());
BridgeConnector.Socket.Emit("webContents-session-clearStorageData-options", Id, options, guid);

return tcs.Task;
Expand Down Expand Up @@ -276,10 +276,10 @@ public void SetPreloads(string[] preloads)
/// <returns></returns>
public Task SetProxyAsync(ProxyConfig config)
{
var tcs = new TaskCompletionSource<object>();
var tcs = new TaskCompletionSource();
string guid = Guid.NewGuid().ToString();

BridgeConnector.Socket.Once("webContents-session-setProxy-completed" + guid, () => tcs.SetResult(null));
BridgeConnector.Socket.Once("webContents-session-setProxy-completed" + guid, () => tcs.SetResult());
BridgeConnector.Socket.Emit("webContents-session-setProxy", Id, config, guid);

return tcs.Task;
Expand Down
6 changes: 1 addition & 5 deletions src/ElectronNET.API/API/Shell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,9 @@ internal static Shell Instance
/// <param name="fullPath">The full path to the directory / file.</param>
public Task ShowItemInFolderAsync(string fullPath)
{
var tcs = new TaskCompletionSource<object>();

// Is this really useful?
BridgeConnector.Socket.Once("shell-showItemInFolderCompleted", () => { });
BridgeConnector.Socket.Emit("shell-showItemInFolder", fullPath);

return tcs.Task;
return Task.CompletedTask;
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/ElectronNET.API/API/WebContents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,12 @@ public Task LoadURLAsync(string url)
/// <param name="options"></param>
public Task LoadURLAsync(string url, LoadURLOptions options)
{
var tcs = new TaskCompletionSource<object>();
var tcs = new TaskCompletionSource();

BridgeConnector.Socket.Once("webContents-loadURL-complete" + Id, () =>
{
BridgeConnector.Socket.Off("webContents-loadURL-error" + Id);
tcs.SetResult(null);
tcs.SetResult();
});

BridgeConnector.Socket.Once<string>("webContents-loadURL-error" + Id, (error) => { tcs.SetException(new InvalidOperationException(error)); });
Expand Down
20 changes: 2 additions & 18 deletions src/ElectronNET.API/Bridge/SocketIOFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
// ReSharper disable once CheckNamespace
namespace ElectronNET.API;

using ElectronNET.API.Serialization;
using SocketIO.Serializer.SystemTextJson;
using System;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using ElectronNET.API.Serialization;
using SocketIO.Serializer.SystemTextJson;
using SocketIO = SocketIOClient.SocketIO;

internal class SocketIoFacade
Expand Down Expand Up @@ -66,20 +64,6 @@ public void On<T>(string eventName, Action<T> action)
}
}

// Keep object overload for compatibility; value will be a JsonElement boxed as object.
public void On(string eventName, Action<object> action)
{
lock (_lockObj)
{
_socket.On(eventName, response =>
{
var value = (object)response.GetValue<JsonElement>();
////Console.WriteLine($"Called Event {eventName} - data {value}");
Task.Run(() => action(value));
});
}
}

public void Once(string eventName, Action action)
{
lock (_lockObj)
Expand Down
1 change: 1 addition & 0 deletions src/ElectronNET.ConsoleApp/ElectronNET.ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<ImportNuGetBuildTasksPackTargetsFromSdk>false</ImportNuGetBuildTasksPackTargetsFromSdk>
<PublishTrimmed>False</PublishTrimmed>
<NuGetAudit>false</NuGetAudit>
<Nullable>disable</Nullable>
</PropertyGroup>
<PropertyGroup Label="ElectronNetCommon">
<PackageIcon>128.png</PackageIcon>
Expand Down
1 change: 1 addition & 0 deletions src/ElectronNET.WebApp/ElectronNET.WebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<PropertyGroup>
<TypeScriptCompileOnSaveEnabled>true</TypeScriptCompileOnSaveEnabled>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="publish\**" />
Expand Down
1 change: 1 addition & 0 deletions src/ElectronNET/ElectronNET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<Description>$(DescriptionFirstPart) This package contains the ElectronNET project system.</Description>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<IncludeSymbols>false</IncludeSymbols>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Include="PackageIcon.png" Pack="true" PackagePath="\" />
Expand Down