diff --git a/Statecharts.NET.Core/Parser.cs b/Statecharts.NET.Core/Parser.cs index 8f654dc..261f84f 100644 --- a/Statecharts.NET.Core/Parser.cs +++ b/Statecharts.NET.Core/Parser.cs @@ -127,14 +127,15 @@ Service CreateServiceFromActivity(ActivityServiceDefinition service, string id) return new TaskCompletionSource().Task; // TODO: check if token and TaskCompletionSource have to be linked }); - return serviceDefinitions.Select((serviceDefinition, index) => serviceDefinition.Match( + return serviceDefinitions?.Select((serviceDefinition, index) => serviceDefinition.Match( activity => CreateServiceFromActivity(activity, serviceDefinition.GetId(statenode.Id, index)), task => new Service(serviceDefinition.GetId(statenode.Id, index), async cancellationToken => { await task.Task(cancellationToken); return default; }), - dataTask => new Service(serviceDefinition.GetId(statenode.Id, index), dataTask.Task))); + dataTask => new Service(serviceDefinition.GetId(statenode.Id, index), dataTask.Task))) + ?? Enumerable.Empty(); } }