Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ public void Settings_DefaultBinderIsAllowedTypes()
}

[TestMethod]
public void Settings_BinderCanBeSetToNull()
public void Settings_NullBinderRestoresAllowedTypesBinder()
{
var providerSettings = new FabricOrchestrationProviderSettings();
providerSettings.JsonSerializationBinder = null;
Assert.IsNull(providerSettings.JsonSerializationBinder);
Assert.IsInstanceOfType(providerSettings.JsonSerializationBinder, typeof(AllowedTypesSerializationBinder));
Comment on lines 225 to +230
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace DurableTask.AzureServiceFabric
/// </summary>
public sealed class FabricOrchestrationProviderSettings
{
ISerializationBinder jsonSerializationBinder = new AllowedTypesSerializationBinder();

/// <summary>
/// Constructor. Initializes all settings to their default values.
/// </summary>
Expand Down Expand Up @@ -66,9 +68,13 @@ public FabricOrchestrationProviderSettings()
/// <para>
/// Defaults to <see cref="AllowedTypesSerializationBinder"/>, which permits only known
/// DurableTask and core system types. Set a custom <see cref="ISerializationBinder"/> to
/// override, or set to <c>null</c> to disable type restrictions (not recommended).
/// override. Setting this property to <c>null</c> restores the default binder.
/// </para>
/// </summary>
public ISerializationBinder JsonSerializationBinder { get; set; } = new AllowedTypesSerializationBinder();
public ISerializationBinder JsonSerializationBinder
{
get => this.jsonSerializationBinder;
set => this.jsonSerializationBinder = value ?? new AllowedTypesSerializationBinder();
}
}
}
7 changes: 2 additions & 5 deletions src/DurableTask.AzureServiceFabric/Service/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Startup(string listeningAddress, FabricOrchestrationProvider fabricOrches
{
this.listeningAddress = listeningAddress ?? throw new ArgumentNullException(nameof(listeningAddress));
this.fabricOrchestrationProvider = fabricOrchestrationProvider ?? throw new ArgumentNullException(nameof(fabricOrchestrationProvider));
this.serializationBinder = serializationBinder;
this.serializationBinder = serializationBinder ?? new AllowedTypesSerializationBinder();
}

public string GetListeningAddress()
Expand Down Expand Up @@ -64,10 +64,7 @@ void IOwinAppBuilder.Startup(IAppBuilder appBuilder)
config.Formatters.Remove(config.Formatters.XmlFormatter);
config.Formatters.Remove(config.Formatters.FormUrlEncodedFormatter);
config.Formatters.JsonFormatter.SerializerSettings.TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All;
if (this.serializationBinder != null)
{
config.Formatters.JsonFormatter.SerializerSettings.SerializationBinder = this.serializationBinder;
}
config.Formatters.JsonFormatter.SerializerSettings.SerializationBinder = this.serializationBinder;

appBuilder.UseWebApi(config);
}
Expand Down
Loading