diff options
author | Kenneth Hsu <kennethhsu@gmail.com> | 2020-01-26 20:49:10 +0300 |
---|---|---|
committer | Kenneth Hsu <kennethhsu@gmail.com> | 2020-01-26 20:49:10 +0300 |
commit | 69d153a12187fa41d8141407919508cb8cf417b2 (patch) | |
tree | 9fe9b2de457ee589eddc1f55695bec12dfa3e697 /Duplicati/GUI | |
parent | 22d34f60c0b45bf282d784d669e1e1b312d4b7b7 (diff) |
Mark fields as readonly but allow for deserializer to set them.
This will prevent accidental reassignment of these fields. Without the
JsonProperty attribute, we would encounter an issue starting the server
when a password was set on the web UI.
Diffstat (limited to 'Duplicati/GUI')
-rw-r--r-- | Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs index 574b9bfc5..19fd89ec2 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs @@ -6,6 +6,7 @@ using System.Text; using Duplicati.Library.Common.IO;
using Duplicati.Server.Serialization;
using Duplicati.Server.Serialization.Interface;
+using Newtonsoft.Json;
namespace Duplicati.GUI.TrayIcon
{
@@ -226,13 +227,13 @@ namespace Duplicati.GUI.TrayIcon private class SaltAndNonce
{
- // ReSharper disable once FieldCanBeMadeReadOnly.Local
- // This cannot be made readonly as its value is set by a deserializer.
- public string Salt = null;
-
- // ReSharper disable once FieldCanBeMadeReadOnly.Local
- // This cannot be made readonly as its value is set by a deserializer.
- public string Nonce = null;
+ // The JsonProperty attribute allows the Serializer.Deserialize method to
+ // set these readonly fields.
+ [JsonProperty]
+ public readonly string Salt = null;
+
+ [JsonProperty]
+ public readonly string Nonce = null;
}
private SaltAndNonce GetSaltAndNonce()
|