mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-13 21:24:00 +00:00
refactor: Migrated from Newtonsoft.Json to System.Text.Json, missing one test passing
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using ElectronNET.Converter;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using ElectronNET.Converter;
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -213,7 +213,7 @@ namespace ElectronNET.API.Entities
|
||||
/// The style of window title bar. Default is default. Possible values are:
|
||||
/// 'default' | 'hidden' | 'hiddenInset' | 'customButtonsOnHover'
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public TitleBarStyle TitleBarStyle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -256,7 +256,7 @@ namespace ElectronNET.API.Entities
|
||||
/// appearance-based, light, dark, titlebar, selection, menu, popover, sidebar,
|
||||
/// medium-light or ultra-dark.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public Vibrancy Vibrancy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -294,3 +294,7 @@ namespace ElectronNET.API.Entities
|
||||
public string ProxyCredentials { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/// <summary>
|
||||
/// Percentage of CPU used since the last call to getCPUUsage. First call returns 0.
|
||||
/// </summary>
|
||||
public int PercentCPUUsage { get; set; }
|
||||
public double PercentCPUUsage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of average idle cpu wakeups per second since the last call to
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Provide metadata about the current loaded Chrome extension
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// The cause of the change
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public enum CookieChangedCause
|
||||
{
|
||||
/// <summary>
|
||||
///The cookie was changed directly by a consumer's action.
|
||||
/// </summary>
|
||||
[JsonProperty("explicit")]
|
||||
[JsonPropertyName("explicit")]
|
||||
@explicit,
|
||||
|
||||
/// <summary>
|
||||
@@ -33,7 +33,7 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// The cookie was overwritten with an already-expired expiration date.
|
||||
/// </summary>
|
||||
[JsonProperty("expired_overwrite")]
|
||||
[JsonPropertyName("expired_overwrite")]
|
||||
expiredOverwrite
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
/// <summary>
|
||||
/// Unique identifier associated with the display.
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// true for an internal display and false for an external display.
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Docs: https://electronjs.org/docs/api/structures/extension
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -10,43 +11,43 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// Canvas.
|
||||
/// </summary>
|
||||
[JsonProperty("2d_canvas")]
|
||||
[JsonPropertyName("2d_canvas")]
|
||||
public string Canvas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flash.
|
||||
/// </summary>
|
||||
[JsonProperty("flash_3d")]
|
||||
[JsonPropertyName("flash_3d")]
|
||||
public string Flash3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flash Stage3D.
|
||||
/// </summary>
|
||||
[JsonProperty("flash_stage3d")]
|
||||
[JsonPropertyName("flash_stage3d")]
|
||||
public string FlashStage3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flash Stage3D Baseline profile.
|
||||
/// </summary>
|
||||
[JsonProperty("flash_stage3d_baseline")]
|
||||
[JsonPropertyName("flash_stage3d_baseline")]
|
||||
public string FlashStage3dBaseline { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Compositing.
|
||||
/// </summary>
|
||||
[JsonProperty("gpu_compositing")]
|
||||
[JsonPropertyName("gpu_compositing")]
|
||||
public string GpuCompositing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Multiple Raster Threads.
|
||||
/// </summary>
|
||||
[JsonProperty("multiple_raster_threads")]
|
||||
[JsonPropertyName("multiple_raster_threads")]
|
||||
public string MultipleRasterThreads { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Native GpuMemoryBuffers.
|
||||
/// </summary>
|
||||
[JsonProperty("native_gpu_memory_buffers")]
|
||||
[JsonPropertyName("native_gpu_memory_buffers")]
|
||||
public string NativeGpuMemoryBuffers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -57,19 +58,19 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// Video Decode.
|
||||
/// </summary>
|
||||
[JsonProperty("video_decode")]
|
||||
[JsonPropertyName("video_decode")]
|
||||
public string VideoDecode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Video Encode.
|
||||
/// </summary>
|
||||
[JsonProperty("video_encode")]
|
||||
[JsonPropertyName("video_encode")]
|
||||
public string VideoEncode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// VPx Video Decode.
|
||||
/// </summary>
|
||||
[JsonProperty("vpx_decode")]
|
||||
[JsonPropertyName("vpx_decode")]
|
||||
public string VpxDecode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
using ElectronNET.Converter;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -76,7 +75,9 @@ namespace ElectronNET.API.Entities
|
||||
/// `touchScrollStarted`, `pointerDown`, `pointerUp`, `pointerMove`,
|
||||
/// `pointerRawUpdate`, `pointerCancel` or `pointerCausedUaAction`.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public InputEventType Type { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
internal class JsonPropertyAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -21,7 +21,8 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// One of the following: "tasks" | "frequent" | "recent" | "custom"
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public JumpListCategoryType Type { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -52,7 +52,9 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// One of the following: "task" | "separator" | "file"
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public JumpListItemType Type { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -21,13 +19,13 @@ namespace ElectronNET.API.Entities
|
||||
/// Define the action of the menu item, when specified the click property will be
|
||||
/// ignored.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public MenuRole Role { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Can be normal, separator, submenu, checkbox or radio.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public MenuType Type { get; set; }
|
||||
|
||||
|
||||
@@ -101,3 +99,5 @@ namespace ElectronNET.API.Entities
|
||||
public string Position { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -13,7 +13,7 @@ namespace ElectronNET.API.Entities
|
||||
/// displays the same icon as "info", unless you set an icon using the "icon"
|
||||
/// option. On macOS, both "warning" and "error" display the same warning icon.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public MessageBoxType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -99,3 +99,5 @@ namespace ElectronNET.API.Entities
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
internal class NativeImageJsonConverter : JsonConverter
|
||||
internal class NativeImageJsonConverter : JsonConverter<NativeImage>
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
public override void Write(Utf8JsonWriter writer, NativeImage value, JsonSerializerOptions options)
|
||||
{
|
||||
if (value is NativeImage nativeImage)
|
||||
if (value is null)
|
||||
{
|
||||
var scaledImages = nativeImage.GetAllScaledImages();
|
||||
serializer.Serialize(writer, scaledImages);
|
||||
writer.WriteNullValue();
|
||||
return;
|
||||
}
|
||||
|
||||
var scaledImages = value.GetAllScaledImages();
|
||||
JsonSerializer.Serialize(writer, scaledImages, Serialization.ElectronJson.Options);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
public override NativeImage Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
var dict = serializer.Deserialize<Dictionary<float, string>>(reader);
|
||||
var dict = JsonSerializer.Deserialize<Dictionary<float, string>>(ref reader, Serialization.ElectronJson.Options);
|
||||
var newDictionary = new Dictionary<float, Image>();
|
||||
foreach (var item in dict)
|
||||
{
|
||||
@@ -29,7 +33,6 @@ namespace ElectronNET.API.Entities
|
||||
|
||||
return new NativeImage(newDictionary);
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType) => objectType == typeof(NativeImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -13,7 +13,8 @@ namespace ElectronNET.API.Entities
|
||||
/// detach.Defaults to last used dock state.In undocked mode it's possible to dock
|
||||
/// back.In detach mode it's not.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public DevToolsMode Mode { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -33,7 +33,7 @@ namespace ElectronNET.API.Entities
|
||||
/// Contains which features the dialog should use. The following values are supported:
|
||||
/// 'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory'
|
||||
/// </summary>
|
||||
[JsonProperty("properties", ItemConverterType = typeof(StringEnumConverter))]
|
||||
[JsonPropertyName("properties")]
|
||||
public OpenDialogProperty[] Properties { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -58,4 +58,5 @@ namespace ElectronNET.API.Entities
|
||||
/// </example>
|
||||
public FileFilter[] Filters { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using ElectronNET.Converter;
|
||||
using Newtonsoft.Json;
|
||||
using ElectronNET.Converter;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -11,7 +11,8 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// Mode for the progress bar. Can be 'none' | 'normal' | 'indeterminate' | 'error' | 'paused'.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public ProgressBarMode Mode { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -28,7 +28,7 @@ namespace ElectronNET.API.Entities
|
||||
/// Scheme of the authentication. Can be basic, digest, ntlm, negotiate.
|
||||
/// Must be provided if removing by origin.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public Scheme Scheme { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -51,3 +51,5 @@ namespace ElectronNET.API.Entities
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -36,7 +35,7 @@ namespace ElectronNET.API.Entities
|
||||
/// hidden - The button is not shown to the user.
|
||||
/// noninteractive - The button is enabled but not interactive; no pressed button state is drawn.This value is intended for instances where the button is used in a notification.
|
||||
/// </summary>
|
||||
[JsonProperty("flags", ItemConverterType = typeof(StringEnumConverter))]
|
||||
[JsonPropertyName("flags")]
|
||||
public ThumbarButtonFlag[] Flags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -58,4 +57,5 @@ namespace ElectronNET.API.Entities
|
||||
Icon = icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -10,7 +11,7 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// The default style
|
||||
/// </summary>
|
||||
[JsonProperty("default")]
|
||||
[JsonPropertyName("default")]
|
||||
defaultStyle,
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user