Skip to content

Commit 46dff7a

Browse files
committed
Fix alerting deserialization
Closes #3237 (cherry picked from commit e285f77)
1 parent 93e1597 commit 46dff7a

File tree

16 files changed

+256
-44
lines changed

16 files changed

+256
-44
lines changed

.paket/Paket.Restore.targets

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<!-- Step 1 Check if lockfile is properly restored -->
4444
<PropertyGroup>
4545
<PaketRestoreRequired>true</PaketRestoreRequired>
46-
<NoWarn>$(NoWarn);NU1603</NoWarn>
46+
<NoWarn>$(NoWarn);NU1603;NU1604;NU1605;NU1608</NoWarn>
4747
</PropertyGroup>
4848

4949
<!-- Because ReadAllText is slow on osx/linux, try to find shasum and awk -->
@@ -69,9 +69,11 @@
6969
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
7070
</PropertyGroup>
7171

72+
7273
<!-- Do a global restore if required -->
7374
<Exec Command='$(PaketBootStrapperCommand)' Condition="Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" ContinueOnError="false" />
74-
<Exec Command='$(PaketCommand) restore' Condition=" '$(PaketRestoreRequired)' == 'true' " ContinueOnError="false" />
75+
<Exec Command='$(PaketCommand) restore --target-framework "$(TargetFrameworks)"' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(TargetFramework)' == '' " ContinueOnError="false" />
76+
<Exec Command='$(PaketCommand) restore --target-framework "$(TargetFramework)"' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(TargetFramework)' != '' " ContinueOnError="false" />
7577

7678
<!-- Step 2 Detect project specific changes -->
7779
<PropertyGroup>

src/Nest/XPack/Watcher/Action/ActionBase.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ public interface IAction
2525

2626
public abstract class ActionBase : IAction
2727
{
28-
protected ActionBase(string name)
29-
{
30-
this.Name = name;
31-
}
28+
internal ActionBase() {}
29+
30+
protected ActionBase(string name) => this.Name = name;
3231

3332
public string Name { get; set; }
3433

@@ -42,10 +41,8 @@ protected ActionBase(string name)
4241

4342
public static bool operator true(ActionBase a) => false;
4443

45-
public static ActionBase operator &(ActionBase left, ActionBase right)
46-
{
47-
return new ActionCombinator(left, right);
48-
}
44+
public static ActionBase operator &(ActionBase left, ActionBase right) =>
45+
new ActionCombinator(left, right);
4946
}
5047

5148
internal class ActionCombinator : ActionBase, IAction

src/Nest/XPack/Watcher/Action/Email/EmailAttachments.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace Nest
66
{
7+
[JsonConverter(typeof(EmailAttachmentsJsonConverter))]
78
public interface IEmailAttachments : IIsADictionary<string, IEmailAttachment> {}
89

9-
[JsonConverter(typeof(EmailAttachmentsJsonConverter))]
1010
public class EmailAttachments : IsADictionaryBase<string, IEmailAttachment>, IEmailAttachments
1111
{
1212
public EmailAttachments() {}
@@ -34,7 +34,7 @@ internal class EmailAttachmentsJsonConverter : JsonConverter
3434
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
3535
{
3636
writer.WriteStartObject();
37-
var attachments = value as IDictionary<string, IEmailAttachment>;
37+
var attachments = (IDictionary<string, IEmailAttachment>)value;
3838
if (attachments != null)
3939
{
4040
foreach (var attachment in attachments)
@@ -67,9 +67,12 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
6767
{
6868
var name = (string)reader.Value;
6969
IEmailAttachment attachment;
70+
71+
reader.Read();
72+
reader.Read();
73+
var type = (string)reader.Value;
7074
reader.Read();
7175

72-
var type = reader.ReadAsString();
7376
switch (type)
7477
{
7578
case "http":

src/Nest/XPack/Watcher/Action/Email/HttpAttachment.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public interface IHttpAttachment : IEmailAttachment
1414
bool? Inline { get; set; }
1515

1616
[JsonProperty("request")]
17+
[JsonConverter(typeof(ReadAsTypeJsonConverter<HttpInputRequest>))]
1718
IHttpInputRequest Request { get; set; }
1819
}
1920

src/Nest/XPack/Watcher/Action/PagerDuty/PagerDutyAction.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Nest
88
{
99
[JsonObject]
10+
[ExactContractJsonConverter(typeof(ReadAsTypeJsonConverter<PagerDutyAction>))]
1011
public interface IPagerDutyAction : IAction, IPagerDutyEvent { }
1112

1213
public class PagerDutyAction : ActionBase, IPagerDutyAction

src/Nest/XPack/Watcher/Action/PagerDuty/PagerDutyEvent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Nest
55
{
66
[JsonObject]
7-
[JsonConverter(typeof(ReadAsTypeJsonConverter<PagerDutyEvent>))]
7+
[ContractJsonConverter(typeof(ReadAsTypeJsonConverter<PagerDutyEvent>))]
88
public interface IPagerDutyEvent
99
{
1010
[JsonProperty("account")]

src/Nest/XPack/Watcher/Action/Webhook/WebhookAction.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Nest
66
{
77
[JsonObject]
8+
[ExactContractJsonConverter(typeof(ReadAsTypeJsonConverter<WebhookAction>))]
89
public interface IWebhookAction : IAction, IHttpInputRequest
910
{
1011
}

src/Nest/XPack/Watcher/Execution/HttpInputRequestResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
namespace Nest
44
{
55
[JsonObject]
6-
[JsonConverter(typeof(ReadAsTypeJsonConverter<HttpInputRequestResult>))]
6+
[ExactContractJsonConverter(typeof(ReadAsTypeJsonConverter<HttpInputRequestResult>))]
77
public class HttpInputRequestResult : HttpInputRequest {}
88
}

src/Nest/XPack/Watcher/Input/ChainInput.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
9494
{
9595
if (reader.TokenType == JsonToken.StartObject)
9696
{
97-
var name = reader.ReadAsString();
97+
reader.Read();
98+
var name = (string)reader.Value;
99+
reader.Read();
98100
var input = (InputContainer)serializer.Deserialize<IInputContainer>(reader);
99101

100102
inputs.Add(name, input);

src/Nest/XPack/Watcher/Input/HttpInputAuthentication.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Nest
77
/// The Authentication mechanism for a request to a HTTP endpoint
88
/// </summary>
99
[JsonObject]
10+
[JsonConverter(typeof(ReadAsTypeJsonConverter<HttpInputAuthentication>))]
1011
public interface IHttpInputAuthentication
1112
{
1213
/// <summary>

0 commit comments

Comments
 (0)