Skip to content

Commit e9bbe28

Browse files
committed
fix(Solution): Udpated to latest Neuroglia Framework packages
fix(Sdk): Fixed property attributes to solve improper ordering of serialized properties fix(Sdk): Fixed all enumerations by assigning a value to their fields, thus allowing for default values (0)
1 parent 7b20d45 commit e9bbe28

File tree

18 files changed

+358
-340
lines changed

18 files changed

+358
-340
lines changed

src/ServerlessWorkflow.Sdk.UnitTests/Cases/Services/WorkflowReaderTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717
using FluentAssertions;
1818
using Newtonsoft.Json;
1919
using Newtonsoft.Json.Linq;
20+
using Newtonsoft.Json.Serialization;
2021
using ServerlessWorkflow.Sdk.Models;
2122
using ServerlessWorkflow.Sdk.Services.IO;
23+
using ServerlessWorkflow.Sdk.UnitTests.Data.Factories;
2224
using System;
2325
using System.Collections.Generic;
2426
using System.IO;
27+
using System.Linq;
2528
using System.Net.Http;
2629
using System.Net.Http.Headers;
30+
using System.Reflection;
2731
using System.Threading.Tasks;
2832
using Xunit;
2933

src/ServerlessWorkflow.Sdk.UnitTests/Data/Factories/WorkflowDefinitionFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public static WorkflowDefinition Create()
1919
.WithId("fake-workflow")
2020
.WithVersion("0.1.0-fake")
2121
.WithName("Fake Workflow")
22+
.WithAnnotation("group=/synapse")
23+
.WithMetadata("group", "synapse")
2224
.WithDataInputSchema(new JSchemaGenerator().Generate(typeof(TestInputData)))
2325
.AddFunction(function =>
2426
function.WithName("fake-function")

src/ServerlessWorkflow.Sdk/ActionType.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ public enum ActionType
3030
/// Indicates an action that invokes a function
3131
/// </summary>
3232
[EnumMember(Value = "function")]
33-
Function,
33+
Function = 1,
3434
/// <summary>
3535
/// Indicates an action that executes a cloud event trigger
3636
/// </summary>
3737
[EnumMember(Value = "trigger")]
38-
Trigger,
38+
Trigger = 2,
3939
/// <summary>
4040
/// Indicates an action that executes a subflow
4141
/// </summary>
4242
[EnumMember(Value = "subflow")]
43-
Subflow
43+
Subflow = 4
4444
}
4545

4646
}

src/ServerlessWorkflow.Sdk/AuthenticationScheme.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ public enum AuthenticationScheme
2929
/// Indicates the basic (username/password) authentication scheme
3030
/// </summary>
3131
[EnumMember(Value = "basic")]
32-
Basic,
32+
Basic = 1,
3333
/// <summary>
3434
/// Indicates the bearer (JwT) authentication scheme
3535
/// </summary>
3636
[EnumMember(Value = "bearer")]
37-
Bearer,
37+
Bearer = 2,
3838
/// <summary>
3939
/// Indicates the OAuth 2 authentication scheme
4040
/// </summary>
4141
[EnumMember(Value = "oauth2")]
42-
OAuth2
42+
OAuth2 = 4
4343
}
4444

4545
}

src/ServerlessWorkflow.Sdk/ConditionType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ public enum ConditionType
3030
/// Indicates a transition condition
3131
/// </summary>
3232
[EnumMember(Value = "transition")]
33-
Transition,
33+
Transition = 1,
3434
/// <summary>
3535
/// Indicates an end condition
3636
/// </summary>
3737
[EnumMember(Value = "end")]
38-
End
38+
End = 2
3939
}
4040

4141
}

src/ServerlessWorkflow.Sdk/EventKind.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ public enum EventKind
3030
/// Indicates an event to consume
3131
/// </summary>
3232
[EnumMember(Value = "consumed")]
33-
Consumed,
33+
Consumed = 1,
3434
/// <summary>
3535
/// Indicates an event to produce
3636
/// </summary>
3737
[EnumMember(Value = "produced")]
38-
Produced
38+
Produced = 2
3939
}
4040

4141
}

src/ServerlessWorkflow.Sdk/FunctionType.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,32 @@ public enum FunctionType
2828
/// Indicates a REST function
2929
/// </summary>
3030
[EnumMember(Value = "rest")]
31-
Rest,
31+
Rest = 1,
3232
/// <summary>
3333
/// Indicates an Remote Procedure Call (RPC)
3434
/// </summary>
3535
[EnumMember(Value = "rpc")]
36-
Rpc,
36+
Rpc = 2,
3737
/// <summary>
3838
/// Indicates a GraphQL function
3939
/// </summary>
4040
[EnumMember(Value = "graphql")]
41-
GraphQL,
41+
GraphQL = 4,
4242
/// <summary>
4343
/// Indicates an OData function
4444
/// </summary>
4545
[EnumMember(Value = "odata")]
46-
OData,
46+
OData = 8,
4747
/// <summary>
4848
/// Indicates an expression function
4949
/// </summary>
5050
[EnumMember(Value = "expression")]
51-
Expression,
51+
Expression = 16,
5252
/// <summary>
5353
/// Indicates an Async API function
5454
/// </summary>
5555
[EnumMember(Value = "asyncapi")]
56-
AsyncApi
56+
AsyncApi = 32
5757
}
5858

5959
}

src/ServerlessWorkflow.Sdk/Models/ActionDefinition.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ namespace ServerlessWorkflow.Sdk.Models
3030
public class ActionDefinition
3131
{
3232

33+
/// <summary>
34+
/// Gets/sets the unique action definition name
35+
/// </summary>
36+
[ProtoMember(1)]
37+
[DataMember(Order = 1)]
38+
public virtual string? Name { get; set; }
39+
3340
/// <summary>
3441
/// Gets the <see cref="ActionDefinition"/>'s type
3542
/// </summary>
@@ -51,13 +58,6 @@ public virtual ActionType Type
5158
}
5259
}
5360

54-
/// <summary>
55-
/// Gets/sets the unique action definition name
56-
/// </summary>
57-
[ProtoMember(1)]
58-
[DataMember(Order = 1)]
59-
public virtual string? Name { get; set; }
60-
6161
/// <summary>
6262
/// Gets/sets a <see cref="OneOf{T1, T2}"/> that represents the function to invoke
6363
/// </summary>

src/ServerlessWorkflow.Sdk/Models/StateDefinition.cs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,28 @@ protected StateDefinition(StateType type)
5252
}
5353

5454
/// <summary>
55-
/// Gets the <see cref="StateDefinition"/>'s type
55+
/// Gets/sets the <see cref="StateDefinition"/>'s id
5656
/// </summary>
57-
[YamlMember]
5857
[ProtoMember(1)]
5958
[DataMember(Order = 1)]
60-
public virtual StateType Type { get; protected set; }
59+
public virtual string? Id { get; set; }
6160

6261
/// <summary>
6362
/// Gets/sets the <see cref="StateDefinition"/>'s id
6463
/// </summary>
64+
[Required]
65+
[Newtonsoft.Json.JsonRequired]
6566
[ProtoMember(2)]
6667
[DataMember(Order = 2)]
67-
public virtual string? Id { get; set; }
68+
public virtual string Name { get; set; } = null!;
6869

6970
/// <summary>
70-
/// Gets/sets the <see cref="StateDefinition"/>'s id
71+
/// Gets the <see cref="StateDefinition"/>'s type
7172
/// </summary>
72-
[Required]
73-
[Newtonsoft.Json.JsonRequired]
73+
[YamlMember]
7474
[ProtoMember(3)]
7575
[DataMember(Order = 3)]
76-
public virtual string Name { get; set; } = null!;
76+
public virtual StateType Type { get; protected set; }
7777

7878
/// <summary>
7979
/// Gets/sets the filter to apply to the <see cref="StateDefinition"/>'s input and output data
@@ -155,13 +155,34 @@ public virtual Uri? DataInputSchemaUri
155155
[DataMember(Order = 6, Name = "onErrors")]
156156
public virtual List<ErrorHandlerDefinition>? Errors { get; set; }
157157

158+
/// <summary>
159+
/// Gets/sets the id of the <see cref="StateDefinition"/> used to compensate the <see cref="StateDefinition"/>
160+
/// </summary>
161+
[ProtoMember(9)]
162+
[DataMember(Order = 9)]
163+
public virtual string? CompensatedBy { get; set; }
164+
165+
/// <summary>
166+
/// Gets/sets a boolean indicating whether or not the <see cref="StateDefinition"/> is used for compensating another <see cref="StateDefinition"/>
167+
/// </summary>
168+
[ProtoMember(10)]
169+
[DataMember(Order = 10)]
170+
public virtual bool UsedForCompensation { get; set; }
171+
172+
/// <summary>
173+
/// Gets/sets the <see cref="StateDefinition"/>'s metadata
174+
/// </summary>
175+
[ProtoMember(11)]
176+
[DataMember(Order = 11)]
177+
public virtual DynamicObject? Metadata { get; set; }
178+
158179
/// <summary>
159180
/// Gets/sets the <see cref="OneOf{T1, T2}"/> that represents the <see cref="StateDefinition"/>'s <see cref="TransitionDefinition"/>
160181
/// </summary>
161-
[ProtoMember(7, Name = "transition")]
162-
[DataMember(Order = 7, Name = "transition")]
182+
[ProtoMember(999999999, Name = "transition")]
183+
[DataMember(Order = 999999999, Name = "transition")]
163184
[YamlMember(Alias = "transition")]
164-
[Newtonsoft.Json.JsonProperty(PropertyName = "transition"), Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.OneOfConverter<TransitionDefinition, string>))]
185+
[Newtonsoft.Json.JsonProperty(PropertyName = "transition", Order = 999999999), Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.OneOfConverter<TransitionDefinition, string>))]
165186
[System.Text.Json.Serialization.JsonPropertyName("transition"), System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Converters.OneOfConverter<TransitionDefinition, string>))]
166187
protected virtual OneOf<TransitionDefinition, string>? TransitionValue { get; set; }
167188

@@ -218,10 +239,10 @@ public virtual string? TransitionToStateName
218239
/// <summary>
219240
/// Gets/sets the <see cref="OneOf{T1, T2}"/> that represents the <see cref="StateDefinition"/>'s <see cref="EndDefinition"/>
220241
/// </summary>
221-
[ProtoMember(4, Name = "end")]
222-
[DataMember(Order = 4, Name = "end")]
242+
[ProtoMember(999999999, Name = "end")]
243+
[DataMember(Order = 999999999, Name = "end")]
223244
[YamlMember(Alias = "end")]
224-
[Newtonsoft.Json.JsonProperty(PropertyName = "end"), Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.OneOfConverter<EndDefinition, bool>))]
245+
[Newtonsoft.Json.JsonProperty(PropertyName = "end", Order = 999999999), Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.OneOfConverter<EndDefinition, bool>))]
225246
[System.Text.Json.Serialization.JsonPropertyName("end"), System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Converters.OneOfConverter<EndDefinition, bool>))]
226247
protected virtual OneOf<EndDefinition, bool>? EndValue { get; set; }
227248

@@ -239,7 +260,7 @@ public virtual EndDefinition? End
239260
{
240261
if (this.EndValue?.T1Value == null
241262
&& (this.EndValue != null && this.EndValue.T2Value))
242-
return new() { };
263+
return new() { };
243264
else
244265
return this.EndValue?.T1Value;
245266
}
@@ -275,27 +296,6 @@ public virtual bool IsEnd
275296
}
276297
}
277298

278-
/// <summary>
279-
/// Gets/sets the id of the <see cref="StateDefinition"/> used to compensate the <see cref="StateDefinition"/>
280-
/// </summary>
281-
[ProtoMember(9)]
282-
[DataMember(Order = 9)]
283-
public virtual string? CompensatedBy { get; set; }
284-
285-
/// <summary>
286-
/// Gets/sets a boolean indicating whether or not the <see cref="StateDefinition"/> is used for compensating another <see cref="StateDefinition"/>
287-
/// </summary>
288-
[ProtoMember(10)]
289-
[DataMember(Order = 10)]
290-
public virtual bool UsedForCompensation { get; set; }
291-
292-
/// <summary>
293-
/// Gets/sets the <see cref="StateDefinition"/>'s metadata
294-
/// </summary>
295-
[ProtoMember(11)]
296-
[DataMember(Order = 11)]
297-
public virtual DynamicObject? Metadata { get; set; }
298-
299299
/// <inheritdoc/>
300300
public override string ToString()
301301
{

0 commit comments

Comments
 (0)