Drop workaround via DescriptinoAttribute: No longer needed

This commit is contained in:
softworkz
2025-11-22 00:03:18 +01:00
parent 6761119241
commit 77834d0f2e
6 changed files with 8 additions and 43 deletions

View File

@@ -539,7 +539,7 @@ namespace ElectronNET.API
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.Once<string>("appGetPathCompleted", taskCompletionSource.SetResult);
BridgeConnector.Socket.Emit("appGetPath", pathName.GetDescription());
BridgeConnector.Socket.Emit("appGetPath", pathName);
return await taskCompletionSource.Task
.ConfigureAwait(false);
@@ -560,7 +560,7 @@ namespace ElectronNET.API
/// </summary>
public void SetPath(PathName name, string path)
{
this.CallMethod2(name.GetDescription(), path);
this.CallMethod2(name, path);
}
/// <summary>

View File

@@ -681,7 +681,7 @@ public class BrowserWindow : ApiBase
/// <param name="level">Values include normal, floating, torn-off-menu, modal-panel, main-menu,
/// status, pop-up-menu and screen-saver. The default is floating.
/// See the macOS docs</param>
public void SetAlwaysOnTop(bool flag, OnTopLevel level) => this.CallMethod2(flag, level.GetDescription());
public void SetAlwaysOnTop(bool flag, OnTopLevel level) => this.CallMethod2(flag, level);
/// <summary>
/// Sets whether the window should show always on top of other windows.
@@ -694,7 +694,7 @@ public class BrowserWindow : ApiBase
/// See the macOS docs</param>
/// <param name="relativeLevel">The number of layers higher to set this window relative to the given level.
/// The default is 0. Note that Apple discourages setting levels higher than 1 above screen-saver.</param>
public void SetAlwaysOnTop(bool flag, OnTopLevel level, int relativeLevel) => this.CallMethod3(flag, level.GetDescription(), relativeLevel);
public void SetAlwaysOnTop(bool flag, OnTopLevel level, int relativeLevel) => this.CallMethod3(flag, level, relativeLevel);
/// <summary>
/// Whether the window is always on top of other windows.
@@ -1190,7 +1190,7 @@ public class BrowserWindow : ApiBase
/// menu, popover, sidebar, medium-light or ultra-dark.
/// See the macOS documentation for more details.</param>
[SupportedOSPlatform("macOS")]
public void SetVibrancy(Vibrancy type) => this.CallMethod1(type.GetDescription());
public void SetVibrancy(Vibrancy type) => this.CallMethod1(type);
/// <summary>
/// Render and control web pages.

View File

@@ -57,7 +57,7 @@ namespace ElectronNET.API
using (cancellationToken.Register(() => tcs.TrySetCanceled()))
{
BridgeConnector.Socket.Once<int>("dock-bounce-completed", tcs.SetResult);
BridgeConnector.Socket.Emit("dock-bounce", type.GetDescription());
BridgeConnector.Socket.Emit("dock-bounce", type);
return await tcs.Task
.ConfigureAwait(false);

View File

@@ -1,35 +0,0 @@
using System;
using System.ComponentModel;
using System.Reflection;
namespace ElectronNET.API.Extensions
{
internal static class EnumExtensions
{
public static string GetDescription<T>(this T enumerationValue) where T : struct
{
Type type = enumerationValue.GetType();
if (!type.IsEnum)
{
throw new ArgumentException("EnumerationValue must be of Enum type", "enumerationValue");
}
//Tries to find a DescriptionAttribute for a potential friendly name
//for the enum
MemberInfo[] memberInfo = type.GetMember(enumerationValue.ToString());
if (memberInfo != null && memberInfo.Length > 0)
{
object[] attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attrs != null && attrs.Length > 0)
{
//Pull out the description value
return ((DescriptionAttribute)attrs[0]).Description;
}
}
//If we have no description attribute, just return the ToString of the enum
return enumerationValue.ToString();
}
}
}

View File

@@ -99,7 +99,7 @@ namespace ElectronNET.API
/// <param name="themeSourceMode">The new ThemeSource.</param>
public void SetThemeSource(ThemeSourceMode themeSourceMode)
{
var themeSource = themeSourceMode.GetDescription();
var themeSource = themeSourceMode;
BridgeConnector.Socket.Emit("nativeTheme-themeSource", themeSource);
}

View File

@@ -134,7 +134,7 @@ namespace ElectronNET.API
var tcs = new TaskCompletionSource<bool>();
BridgeConnector.Socket.Once<bool>("shell-writeShortcutLinkCompleted", tcs.SetResult);
BridgeConnector.Socket.Emit("shell-writeShortcutLink", shortcutPath, operation.GetDescription(), options);
BridgeConnector.Socket.Emit("shell-writeShortcutLink", shortcutPath, operation, options);
return tcs.Task;
}