Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise serialization of entitymessages #972

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/DurableTask.Core/Entities/EntityMessageEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#nullable enable
using System;
using DurableTask.Core.Entities.EventFormat;
using DurableTask.Core.Serializing.Internal;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace DurableTask.Core.Entities
{
Expand Down Expand Up @@ -50,21 +50,11 @@ public override string ToString()
/// </summary>
public OrchestrationInstance TargetInstance => this.target;

/// <summary>
/// Returns the content of this event, as an object that can be serialized later.
/// </summary>
/// <returns></returns>
public object ContentAsObject()
{
// we pre-serialize this now to avoid interference from the application-defined serialization settings
return JObject.FromObject(message, Serializer.InternalSerializer);
}

/// <summary>
/// Returns the content of this event, as a serialized string.
/// </summary>
/// <returns></returns>
public string ContentAsString()
public string AsSerializedString()
{
return JsonConvert.SerializeObject(message, Serializer.InternalSerializerSettings);
}
Expand All @@ -78,13 +68,24 @@ public TaskMessage AsTaskMessage()
return new TaskMessage
{
OrchestrationInstance = this.target,
Event = new History.EventRaisedEvent(-1, this.ContentAsString())
Event = new History.EventRaisedEvent(-1, this.AsSerializedString())
{
Name = this.eventName
}
};
}

#pragma warning disable CS0618 // Type or member is obsolete. Intentional internal usage.
/// <summary>
/// Returns the content as an already-serialized string. Can be used to bypass the application-defined serializer.
/// </summary>
/// <returns></returns>
public RawInput AsRawInput()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is AsRawInput() expected to be called? By the dotnet isolated SDK shim layer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is the corresponding PR: microsoft/durabletask-dotnet#207

{
return new RawInput(this.AsSerializedString());
}
#pragma warning restore CS0618 // Type or member is obsolete

/// <summary>
/// Utility function to compute a capped scheduled time, given a scheduled time, a timestamp representing the current time, and the maximum delay.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/DurableTask.Core/TaskOrchestrationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ public override void SendEvent(OrchestrationInstance orchestrationInstance, stri
}

int id = this.idCounter++;
string serializedEventData = this.MessageDataConverter.SerializeInternal(eventData);

string serializedEventData = this.MessageDataConverter.SerializeInternal(eventData);

var action = new SendEventOrchestratorAction
{
Expand Down