diff --git a/.gitignore b/.gitignore index c089d3b5..d427d813 100644 --- a/.gitignore +++ b/.gitignore @@ -163,3 +163,6 @@ pip-log.txt # Mac crap .DS_Store Posh-SSH.zip + +Source/**/bin/** +Source/**/obj/** diff --git a/Source/PoshSSH/PoshSSH.Core/PoshSSH.Core.csproj b/Source/PoshSSH/PoshSSH.Core/PoshSSH.Core.csproj index 7cb8d471..6e4570ad 100644 --- a/Source/PoshSSH/PoshSSH.Core/PoshSSH.Core.csproj +++ b/Source/PoshSSH/PoshSSH.Core/PoshSSH.Core.csproj @@ -33,7 +33,6 @@ - 1.3.0 diff --git a/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/Newtonsoft.Json.dll b/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/Newtonsoft.Json.dll deleted file mode 100644 index b501fb6a..00000000 Binary files a/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/Newtonsoft.Json.dll and /dev/null differ diff --git a/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/PoshSSH.deps.json b/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/PoshSSH.deps.json new file mode 100644 index 00000000..8bbaa60c --- /dev/null +++ b/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/PoshSSH.deps.json @@ -0,0 +1,98 @@ +{ + "runtimeTarget": { + "name": ".NETStandard,Version=v2.0/", + "signature": "1c29894f4e98a18a46b4ef3d88fe6ab552e3c6d5" + }, + "compilationOptions": {}, + "targets": { + ".NETStandard,Version=v2.0": {}, + ".NETStandard,Version=v2.0/": { + "PoshSSH/1.0.0": { + "dependencies": { + "NETStandard.Library": "2.0.3", + "PowerShellStandard.Library": "5.1.1", + "SSH.NET": "2020.0.2", + "SshNet.Security.Cryptography": "1.3.0" + }, + "runtime": { + "PoshSSH.dll": {} + } + }, + "Microsoft.NETCore.Platforms/1.1.0": {}, + "NETStandard.Library/2.0.3": { + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + }, + "PowerShellStandard.Library/5.1.1": { + "runtime": { + "lib/netstandard2.0/System.Management.Automation.dll": { + "assemblyVersion": "3.0.0.0", + "fileVersion": "5.1.1.0" + } + } + }, + "SSH.NET/2020.0.2": { + "dependencies": { + "SshNet.Security.Cryptography": "1.3.0" + }, + "runtime": { + "lib/netstandard2.0/Renci.SshNet.dll": { + "assemblyVersion": "2020.0.2.0", + "fileVersion": "2020.0.2.0" + } + } + }, + "SshNet.Security.Cryptography/1.3.0": { + "runtime": { + "lib/netstandard2.0/SshNet.Security.Cryptography.dll": { + "assemblyVersion": "1.3.0.0", + "fileVersion": "1.3.0.0" + } + } + } + } + }, + "libraries": { + "PoshSSH/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "Microsoft.NETCore.Platforms/1.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==", + "path": "microsoft.netcore.platforms/1.1.0", + "hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512" + }, + "NETStandard.Library/2.0.3": { + "type": "package", + "serviceable": true, + "sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "path": "netstandard.library/2.0.3", + "hashPath": "netstandard.library.2.0.3.nupkg.sha512" + }, + "PowerShellStandard.Library/5.1.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-e31xJjG+Kjbv6YF3Yq6D4Dl3or8v7LrNF41k3CXrWozW6hR1zcOe5KYuZJaGSiAgLnwP8wcW+I3+IWEzMPZKXQ==", + "path": "powershellstandard.library/5.1.1", + "hashPath": "powershellstandard.library.5.1.1.nupkg.sha512" + }, + "SSH.NET/2020.0.2": { + "type": "package", + "serviceable": true, + "sha512": "sha512-G0dNlTBAM00KZXv1wWVwgg26d9/METcM6qWBpNQwllzQmmbu+Zu+FS1L1X4fFgGdPu3e8k9mmTBu6SwtQ0614g==", + "path": "ssh.net/2020.0.2", + "hashPath": "ssh.net.2020.0.2.nupkg.sha512" + }, + "SshNet.Security.Cryptography/1.3.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-5pBIXRjcSO/amY8WztpmNOhaaCNHY/B6CcYDI7FSTgqSyo/ZUojlLiKcsl+YGbxQuLX439qIkMfP0PHqxqJi/Q==", + "path": "sshnet.security.cryptography/1.3.0", + "hashPath": "sshnet.security.cryptography.1.3.0.nupkg.sha512" + } + } +} \ No newline at end of file diff --git a/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/PoshSSH.dll b/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/PoshSSH.dll new file mode 100644 index 00000000..7679fdb2 Binary files /dev/null and b/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/PoshSSH.dll differ diff --git a/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/PoshSSH.pdb b/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/PoshSSH.pdb new file mode 100644 index 00000000..3b661f57 Binary files /dev/null and b/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/PoshSSH.pdb differ diff --git a/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/Renci.SshNet.dll b/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/Renci.SshNet.dll deleted file mode 100644 index 285a99f8..00000000 Binary files a/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/Renci.SshNet.dll and /dev/null differ diff --git a/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/SshNet.Security.Cryptography.dll b/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/SshNet.Security.Cryptography.dll deleted file mode 100644 index 2761fd1d..00000000 Binary files a/Source/PoshSSH/PoshSSH.Core/bin/Debug/netstandard2.0/SshNet.Security.Cryptography.dll and /dev/null differ diff --git a/Source/PoshSSH/PoshSSH/Stores/JsonStore.cs b/Source/PoshSSH/PoshSSH/Stores/JsonStore.cs index 00a2ffb2..5046418c 100644 --- a/Source/PoshSSH/PoshSSH/Stores/JsonStore.cs +++ b/Source/PoshSSH/PoshSSH/Stores/JsonStore.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Newtonsoft.Json; +using System.Runtime.Serialization.Json; namespace SSH.Stores { @@ -14,34 +14,48 @@ public class ConfigFileStruct public class JsonStore : MemoryStore { private readonly string FileName; + private readonly DataContractJsonSerializerSettings serializationSettings; public JsonStore(string fileName) { FileName = fileName; + serializationSettings = new DataContractJsonSerializerSettings { UseSimpleDictionaryFormat = true }; } public void LoadFromDisk() { if (File.Exists(FileName)) { - var jsonString = File.ReadAllText(FileName); - var keys = JsonConvert.DeserializeObject(jsonString).Keys; - HostKeys = new ConcurrentDictionary(keys); + using (var stream = File.OpenRead(FileName)) + { + var serializer = new DataContractJsonSerializer(typeof(ConfigFileStruct), serializationSettings); + var keys = (ConfigFileStruct)serializer.ReadObject(stream); + if (Equals(keys, null)) throw new Exception(); + HostKeys = new ConcurrentDictionary(keys.Keys); + } } } private void WriteToDisk() { - var jsonString = JsonConvert.SerializeObject(new ConfigFileStruct() - { - Keys = HostKeys.ToDictionary(x => x.Key, x => x.Value) - }, - Formatting.Indented - ); var d = Directory.CreateDirectory(Path.GetDirectoryName(FileName)); if (d.Exists) { - File.WriteAllText(FileName, jsonString); + using (var stream = File.Open(FileName, FileMode.Create, FileAccess.Write, FileShare.Read)) + { + using (var writer = JsonReaderWriterFactory.CreateJsonWriter( + stream, System.Text.Encoding.UTF8, true, true, " ")) + { + var serializer = new DataContractJsonSerializer(typeof(ConfigFileStruct), serializationSettings); + serializer.WriteObject(writer, + new ConfigFileStruct() + { + Keys = HostKeys.ToDictionary(x => x.Key, x => x.Value) + } + ); + writer.Flush(); + } + } } }