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

Remove BinaryFormatter altogether #6922

Merged
merged 1 commit into from
Jan 29, 2021
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
6 changes: 0 additions & 6 deletions src/Orleans.Core/Core/DefaultClientServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public static void AddDefaultServices(IClientBuilder builder, IServiceCollection
services.TryAddSingleton<ImrRpcProvider>();
services.TryAddSingleton<ImrGrainMethodInvokerProvider>();
services.TryAddSingleton<GrainReferenceSerializer>();
services.TryAddSingleton<BinaryFormatterGrainReferenceSurrogateSelector>();
services.TryAddSingleton<GrainReferenceKeyStringConverter>();
services.TryAddSingleton<IGrainReferenceRuntime, GrainReferenceRuntime>();
services.TryAddSingleton<GrainInterfaceTypeResolver>();
Expand Down Expand Up @@ -87,13 +86,8 @@ public static void AddDefaultServices(IClientBuilder builder, IServiceCollection
services.AddSingleton<DotNetSerializableSerializer>();
services.AddFromExisting<IKeyedSerializer, DotNetSerializableSerializer>();

services.AddSingleton<BinaryFormatterSerializer>();
services.AddSingleton<BinaryFormatterISerializableSerializer>();
services.AddFromExisting<IKeyedSerializer, BinaryFormatterISerializableSerializer>();
#pragma warning disable CS0618 // Type or member is obsolete
services.TryAddSingleton<ILBasedSerializer>();
services.AddFromExisting<IKeyedSerializer, ILBasedSerializer>();
#pragma warning restore CS0618 // Type or member is obsolete

// Application parts
var parts = builder.GetApplicationPartManager();
Expand Down

This file was deleted.

This file was deleted.

143 changes: 0 additions & 143 deletions src/Orleans.Core/Serialization/BinaryFormatterSerializer.cs

This file was deleted.

11 changes: 5 additions & 6 deletions src/Orleans.Core/Serialization/ILBasedSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using System;
using System.Collections.Concurrent;
using System.Reflection;
using Orleans.Runtime;

namespace Orleans.Serialization
{
using System;
using System.Collections.Concurrent;
using System.Reflection;
using Orleans.Runtime;

/// <summary>
/// Fallback serializer to be used when other serializers are unavailable.
/// </summary>
[Obsolete("Obsolete in favor of other serializers.")]
public class ILBasedSerializer : IKeyedSerializer
{
private static readonly Type ExceptionType = typeof(Exception);
Expand Down
4 changes: 1 addition & 3 deletions src/Orleans.Core/Serialization/KeyedSerializerId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ internal enum KeyedSerializerId : byte
/// </summary>
ILBasedSerializer = 1,

/// <summary>
/// <see cref="Orleans.Serialization.BinaryFormatterISerializableSerializer"/>
/// </summary>
[Obsolete("Removed")]
BinaryFormatterISerializable = 2,

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Orleans.Core/Serialization/SerializationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ private IExternalSerializer GetFallbackSerializer(IServiceProvider serviceProvid
}
else
{
serializer = new BinaryFormatterSerializer(this.ServiceProvider);
serializer = this.ServiceProvider.GetRequiredService<ILBasedSerializer>();
}
return serializer;
}
Expand Down
6 changes: 0 additions & 6 deletions src/Orleans.Runtime/Hosting/DefaultSiloServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ internal static void AddDefaultServices(IApplicationPartManager applicationPartM
services.TryAddSingleton<ImrRpcProvider>();
services.TryAddSingleton<ImrGrainMethodInvokerProvider>();
services.TryAddSingleton<GrainReferenceSerializer>();
services.TryAddSingleton<BinaryFormatterGrainReferenceSurrogateSelector>();
services.TryAddSingleton<GrainReferenceKeyStringConverter>();
services.AddSingleton<GrainVersionManifest>();
services.TryAddSingleton<TypeMetadataCache>();
Expand Down Expand Up @@ -305,14 +304,9 @@ internal static void AddDefaultServices(IApplicationPartManager applicationPartM
services.AddSingleton<DotNetSerializableSerializer>();
services.AddFromExisting<IKeyedSerializer, DotNetSerializableSerializer>();

services.AddSingleton<BinaryFormatterSerializer>();
services.AddSingleton<BinaryFormatterISerializableSerializer>();
services.AddFromExisting<IKeyedSerializer, BinaryFormatterISerializableSerializer>();

#pragma warning disable CS0618 // Type or member is obsolete
services.AddSingleton<ILBasedSerializer>();
services.AddFromExisting<IKeyedSerializer, ILBasedSerializer>();
#pragma warning restore CS0618 // Type or member is obsolete

// Transactions
services.TryAddSingleton<ITransactionAgent, DisabledTransactionAgent>();
Expand Down
20 changes: 0 additions & 20 deletions src/Orleans.TestingHost/Utils/TestingUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.IO;
using System.Net;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -128,24 +127,5 @@ public static void ConfigureThreadPoolSettingsForStorageTests(int numDotNetPoolT
ServicePointManager.DefaultConnectionLimit = numDotNetPoolThreads; // 1000;
ServicePointManager.UseNagleAlgorithm = false;
}

/// <summary> Serialize and deserialize the input </summary>
/// <typeparam name="T">The type of the input</typeparam>
/// <param name="input">The input to serialize and deserialize</param>
/// <param name="grainFactory">The grain factory.</param>
/// <param name="serializationManager">The serialization manager.</param>
/// <returns>Input that have been serialized and then deserialized</returns>
public static T RoundTripDotNetSerializer<T>(T input, IGrainFactory grainFactory, SerializationManager serializationManager)
{
IFormatter formatter = new BinaryFormatter();
MemoryStream stream = new MemoryStream(new byte[100000], true);
formatter.Context = new StreamingContext(StreamingContextStates.All, new SerializationContext(serializationManager));
formatter.SurrogateSelector = serializationManager.ServiceProvider.GetRequiredService<BinaryFormatterGrainReferenceSurrogateSelector>();
formatter.Serialize(stream, input);
stream.Position = 0;
T output = (T)formatter.Deserialize(stream);

return output;
}
}
}
Loading