From e0210822c215169fed85d5e59d1c6e85d88c0964 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Sat, 28 Sep 2019 00:30:36 -0700 Subject: [PATCH] Remove Newtonsoft.Json. --- Agent/Agent.csproj | 1 - Desktop.Unix/Services/Config.cs | 8 ++++---- Desktop.Win/App.config | 6 +++++- Desktop.Win/Desktop.Win.csproj | 3 --- Desktop.Win/Services/Config.cs | 8 ++++---- Desktop.Win/packages.config | 1 - ScreenCast.Core/Services/Logger.cs | 8 ++++---- ScreenCast.Linux/ScreenCast.Linux.csproj | 1 - ScreenCast.Win/App.config | 6 +++++- ScreenCast.Win/ScreenCast.Win.csproj | 3 --- ScreenCast.Win/packages.config | 1 - Server/Data/ApplicationDbContext.cs | 2 +- Server/Server.csproj | 1 - Server/Startup.cs | 14 ++------------ Shared/Models/CommandContext.cs | 6 +++--- Shared/Models/CommandContext.cs.d.ts | 15 ++++++++++++--- Shared/Models/EventLog.cs | 4 ++-- Shared/Models/PermissionGroup.cs | 3 +-- Shared/Shared.csproj | 2 +- 19 files changed, 44 insertions(+), 49 deletions(-) diff --git a/Agent/Agent.csproj b/Agent/Agent.csproj index 26ef3a56..75f92afe 100644 --- a/Agent/Agent.csproj +++ b/Agent/Agent.csproj @@ -30,7 +30,6 @@ - diff --git a/Desktop.Unix/Services/Config.cs b/Desktop.Unix/Services/Config.cs index 096a1ea1..7fe80083 100644 --- a/Desktop.Unix/Services/Config.cs +++ b/Desktop.Unix/Services/Config.cs @@ -1,10 +1,10 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using System.Text; +using System.Text.Json; using System.Threading.Tasks; namespace Remotely.Desktop.Unix.Services @@ -25,7 +25,7 @@ namespace Remotely.Desktop.Unix.Services { try { - return JsonConvert.DeserializeObject(File.ReadAllText(ConfigFile)); + return JsonSerializer.Deserialize(File.ReadAllText(ConfigFile)); } catch { @@ -40,7 +40,7 @@ namespace Remotely.Desktop.Unix.Services try { Directory.CreateDirectory(ConfigFolder); - File.WriteAllText(ConfigFile, JsonConvert.SerializeObject(this)); + File.WriteAllText(ConfigFile, JsonSerializer.Serialize(this)); } catch { diff --git a/Desktop.Win/App.config b/Desktop.Win/App.config index 097303f7..534b28cf 100644 --- a/Desktop.Win/App.config +++ b/Desktop.Win/App.config @@ -19,7 +19,7 @@ - + @@ -29,6 +29,10 @@ + + + + diff --git a/Desktop.Win/Desktop.Win.csproj b/Desktop.Win/Desktop.Win.csproj index 37b0de3a..d3b356ac 100644 --- a/Desktop.Win/Desktop.Win.csproj +++ b/Desktop.Win/Desktop.Win.csproj @@ -179,9 +179,6 @@ ..\packages\Microsoft.Extensions.Primitives.3.0.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll True - - ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll - ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll diff --git a/Desktop.Win/Services/Config.cs b/Desktop.Win/Services/Config.cs index c11cfc2c..e9185ac1 100644 --- a/Desktop.Win/Services/Config.cs +++ b/Desktop.Win/Services/Config.cs @@ -1,10 +1,10 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using System.Text; +using System.Text.Json; using System.Threading.Tasks; namespace Remotely.Desktop.Win.Services @@ -25,7 +25,7 @@ namespace Remotely.Desktop.Win.Services { try { - return JsonConvert.DeserializeObject(File.ReadAllText(ConfigFile)); + return JsonSerializer.Deserialize(File.ReadAllText(ConfigFile)); } catch { @@ -40,7 +40,7 @@ namespace Remotely.Desktop.Win.Services try { Directory.CreateDirectory(ConfigFolder); - File.WriteAllText(ConfigFile, JsonConvert.SerializeObject(this)); + File.WriteAllText(ConfigFile, JsonSerializer.Serialize(this)); } catch { diff --git a/Desktop.Win/packages.config b/Desktop.Win/packages.config index ada75ebf..21c2291e 100644 --- a/Desktop.Win/packages.config +++ b/Desktop.Win/packages.config @@ -20,7 +20,6 @@ - diff --git a/ScreenCast.Core/Services/Logger.cs b/ScreenCast.Core/Services/Logger.cs index 0c17f4ee..f288e108 100644 --- a/ScreenCast.Core/Services/Logger.cs +++ b/ScreenCast.Core/Services/Logger.cs @@ -1,11 +1,11 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; +using System.Text.Json; using System.Threading.Tasks; namespace Remotely.ScreenCast.Core.Services @@ -44,7 +44,7 @@ namespace Remotely.ScreenCast.Core.Services fi = new FileInfo(path); } } - File.AppendAllText(path, JsonConvert.SerializeObject(jsoninfo) + Environment.NewLine); + File.AppendAllText(path, JsonSerializer.Serialize(jsoninfo) + Environment.NewLine); } } catch { } @@ -88,7 +88,7 @@ namespace Remotely.ScreenCast.Core.Services fi = new FileInfo(path); } } - File.AppendAllText(path, JsonConvert.SerializeObject(jsonError) + Environment.NewLine); + File.AppendAllText(path, JsonSerializer.Serialize(jsonError) + Environment.NewLine); exception = exception.InnerException; } } diff --git a/ScreenCast.Linux/ScreenCast.Linux.csproj b/ScreenCast.Linux/ScreenCast.Linux.csproj index 760fb84e..0ecd178c 100644 --- a/ScreenCast.Linux/ScreenCast.Linux.csproj +++ b/ScreenCast.Linux/ScreenCast.Linux.csproj @@ -34,7 +34,6 @@ - diff --git a/ScreenCast.Win/App.config b/ScreenCast.Win/App.config index b1b679cc..5f2bd3a7 100644 --- a/ScreenCast.Win/App.config +++ b/ScreenCast.Win/App.config @@ -15,7 +15,7 @@ - + @@ -29,6 +29,10 @@ + + + + diff --git a/ScreenCast.Win/ScreenCast.Win.csproj b/ScreenCast.Win/ScreenCast.Win.csproj index 438b4f7b..179e973b 100644 --- a/ScreenCast.Win/ScreenCast.Win.csproj +++ b/ScreenCast.Win/ScreenCast.Win.csproj @@ -179,9 +179,6 @@ ..\packages\NAudio.1.9.0\lib\net35\NAudio.dll - - ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll - ..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll diff --git a/ScreenCast.Win/packages.config b/ScreenCast.Win/packages.config index fb213a1a..b12ed59b 100644 --- a/ScreenCast.Win/packages.config +++ b/ScreenCast.Win/packages.config @@ -21,7 +21,6 @@ - diff --git a/Server/Data/ApplicationDbContext.cs b/Server/Data/ApplicationDbContext.cs index 3faed7e2..daeb0aa3 100644 --- a/Server/Data/ApplicationDbContext.cs +++ b/Server/Data/ApplicationDbContext.cs @@ -40,7 +40,7 @@ namespace Remotely.Server.Data base.OnModelCreating(builder); builder.Entity().ToTable("RemotelyUsers"); - builder.Entity().ToTable("RemotelyUsers"); + //builder.Entity().ToTable("RemotelyUsers"); builder.Entity() .HasMany(x => x.Devices) diff --git a/Server/Server.csproj b/Server/Server.csproj index 2f962f60..58a3e33e 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -70,7 +70,6 @@ - diff --git a/Server/Startup.cs b/Server/Startup.cs index 7cafe8a9..7b1816a2 100644 --- a/Server/Startup.cs +++ b/Server/Startup.cs @@ -24,7 +24,6 @@ using Remotely.Shared.Services; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.Identity.UI; using Microsoft.AspNetCore.Cors.Infrastructure; -using Swashbuckle.AspNetCore.Swagger; using Newtonsoft.Json; using System.Net; using Microsoft.Extensions.Hosting; @@ -144,11 +143,6 @@ namespace Remotely.Server }) .AddMessagePackProtocol(); - services.AddSwaggerGen(c => - { - c.SwaggerDoc("v1", new Info { Title = "Remotely API", Version = "v1" }); - }); - services.AddLogging(); services.AddScoped(); services.AddScoped(); @@ -191,6 +185,8 @@ namespace Remotely.Server app.UseAuthentication(); + app.UseAuthorization(); + app.UseEndpoints(routeBuilder => { @@ -220,12 +216,6 @@ namespace Remotely.Server }); - app.UseSwagger(); - - app.UseSwaggerUI(c => - { - c.SwaggerEndpoint("/swagger/v1/swagger.json", "Remotely API V1"); - }); app.UseCors("TrustedOriginPolicy"); try diff --git a/Shared/Models/CommandContext.cs b/Shared/Models/CommandContext.cs index 33095d74..3cbe1fba 100644 --- a/Shared/Models/CommandContext.cs +++ b/Shared/Models/CommandContext.cs @@ -1,8 +1,8 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; +using System.Text.Json.Serialization; namespace Remotely.Shared.Models { @@ -18,7 +18,7 @@ namespace Remotely.Shared.Models public ICollection PSCoreResults { get; set; } = new List(); public ICollection CommandResults { get; set; } = new List(); public DateTime TimeStamp { get; set; } = DateTime.Now; - [IgnoreDataMember] + [JsonIgnore] public virtual Organization Organization { get; set; } public string OrganizationID { get; set; } } diff --git a/Shared/Models/CommandContext.cs.d.ts b/Shared/Models/CommandContext.cs.d.ts index b0b340fb..ff950a4f 100644 --- a/Shared/Models/CommandContext.cs.d.ts +++ b/Shared/Models/CommandContext.cs.d.ts @@ -1,4 +1,3 @@ -declare module server { interface commandContext { iD: string; commandMode: string; @@ -9,6 +8,16 @@ declare module server { pSCoreResults: any[]; commandResults: any[]; timeStamp: Date; + organization: { + iD: string; + organizationName: string; + remotelyUsers: any[]; + devices: any[]; + commandContexts: .commandContext[]; + eventLogs: any[]; + permissionGroups: any[]; + inviteLinks: any[]; + sharedFiles: any[]; + }; organizationID: string; - } -} + } \ No newline at end of file diff --git a/Shared/Models/EventLog.cs b/Shared/Models/EventLog.cs index ac7b6c28..87566060 100644 --- a/Shared/Models/EventLog.cs +++ b/Shared/Models/EventLog.cs @@ -1,8 +1,8 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Text; +using System.Text.Json.Serialization; namespace Remotely.Shared.Models { diff --git a/Shared/Models/PermissionGroup.cs b/Shared/Models/PermissionGroup.cs index 82a71491..a3bd503b 100644 --- a/Shared/Models/PermissionGroup.cs +++ b/Shared/Models/PermissionGroup.cs @@ -1,5 +1,4 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Text; diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj index 094f52bd..7830180b 100644 --- a/Shared/Shared.csproj +++ b/Shared/Shared.csproj @@ -9,8 +9,8 @@ - +