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 netstandard1.6 platform target #312

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
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
6 changes: 3 additions & 3 deletions src/Hyperion.Benchmarks/Prolog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class HyperionConfig : ManualConfig
{
public HyperionConfig()
{
Add(StatisticColumn.Mean, StatisticColumn.Min, StatisticColumn.Max, StatisticColumn.OperationsPerSecond);
Add(MarkdownExporter.GitHub);
Add(MemoryDiagnoser.Default);
AddColumn(StatisticColumn.Mean, StatisticColumn.Min, StatisticColumn.Max, StatisticColumn.OperationsPerSecond);
AddExporter(MarkdownExporter.GitHub);
AddDiagnoser(MemoryDiagnoser.Default);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Hyperion.Benchmarks/SerializeClassesBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public class SerializeClassesBenchmark : HyperionBenchmark

protected override void Init()
{
var baseOptions = new SerializerOptions(preserveObjectReferences: true);
var baseOptions = SerializerOptions.Default
.WithPreserveObjectReferences(true);
Serializer = new Serializer(baseOptions);

var filteredOptions = baseOptions
Expand Down
25 changes: 19 additions & 6 deletions src/Hyperion.Tests/Bugs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public void CanSerializeMessageWithByte()
{
var stream = new MemoryStream();
var msg = new ByteMessage(DateTime.UtcNow, 1, 2);
var serializer = new Serializer(new SerializerOptions(versionTolerance: true, preserveObjectReferences: true));
var serializer = new Serializer(SerializerOptions.Default
.WithVersionTolerance(true)
.WithPreserveObjectReferences(true));
serializer.Serialize(msg, stream);
stream.Position = 0;
var res = serializer.Deserialize(stream);
Expand All @@ -107,7 +109,9 @@ public void CanSerializeMessageWithByte()
[Fact]
public void CanFindTypeByManifest_WhenManifestContainsUnknownAssemblyVersion()
{
var serializer = new Serializer(new SerializerOptions(versionTolerance: true, preserveObjectReferences: true));
var serializer = new Serializer(SerializerOptions.Default
.WithVersionTolerance(true)
.WithPreserveObjectReferences(true));
var type = typeof(ByteMessage);

MemoryStream GetStreamForManifest(string manifest)
Expand Down Expand Up @@ -168,7 +172,9 @@ public void TypeEx_ToQualifiedAssemblyName_should_strip_version_correctly_for_mu
public void CanSerialieCustomType_bug()
{
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions(versionTolerance: true, preserveObjectReferences: true));
var serializer = new Serializer(SerializerOptions.Default
.WithVersionTolerance(true)
.WithPreserveObjectReferences(true));
var root = new Recover(SnapshotSelectionCriteria.Latest);

serializer.Serialize(root, stream);
Expand All @@ -179,7 +185,9 @@ public void CanSerialieCustomType_bug()
[Fact]
public void CanSerializeImmutableGenericInterfaces()
{
var serializer = new Serializer(new SerializerOptions(versionTolerance: true, preserveObjectReferences: true));
var serializer = new Serializer(SerializerOptions.Default
.WithVersionTolerance(true)
.WithPreserveObjectReferences(true));
var names = new List<Container<string>>
{
new Container<string>("Mr", TrustLevel.Partial),
Expand Down Expand Up @@ -210,7 +218,9 @@ public void CanSerializeUri()
{
var stream = new MemoryStream();
var msg = new Uri("http://localhost:9202/", UriKind.RelativeOrAbsolute);
var serializer = new Serializer(new SerializerOptions(preserveObjectReferences: true, versionTolerance: true));
var serializer = new Serializer(SerializerOptions.Default
.WithVersionTolerance(true)
.WithPreserveObjectReferences(true));
serializer.Serialize(msg, stream);
stream.Position = 0;
var res = serializer.Deserialize(stream);
Expand Down Expand Up @@ -458,7 +468,7 @@ public void WritesManifestEvenIfKnown()
{ 42, "iMaGiNe" }
}.ToImmutableDictionary(),
};
var serializer = new Serializer(new SerializerOptions(knownTypes: new[]
var serializer = new Serializer(SerializerOptions.Default.WithKnownTypes(new[]
{
typeof(object[]),
typeof(int[]),
Expand Down Expand Up @@ -494,8 +504,11 @@ public void WritesManifestEvenIfKnown()

class FieldsToOrder
{
#pragma warning disable CS0649
public string A2;
// ReSharper disable once InconsistentNaming
public string a1;
#pragma warning restore CS0649
}

[Fact]
Expand Down
18 changes: 11 additions & 7 deletions src/Hyperion.Tests/CollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ public void CanSerializeArray3DOfInt()
public void Issue18()
{
var msg = new byte[] {1, 2, 3, 4};
var serializer = new Serializer(new SerializerOptions(true, true));
var serializer = new Serializer(SerializerOptions.Default
.WithVersionTolerance(true)
.WithPreserveObjectReferences(true));

byte[] serialized;
using (var ms = new MemoryStream())
Expand All @@ -420,9 +422,9 @@ public void Issue18()
public void Issue263_CanSerializeArrayOfSurrogate_WhenPreservingObjectReference()
{
var invoked = new List<SurrogatedClass.ClassSurrogate>();
var serializer = new Serializer(new SerializerOptions(
preserveObjectReferences: true,
surrogates: new []
var serializer = new Serializer(SerializerOptions.Default
.WithPreserveObjectReferences(true)
.WithSurrogates(new []
{
Surrogate.Create<SurrogatedClass, SurrogatedClass.ClassSurrogate>(
to => to.ToSurrogate(),
Expand Down Expand Up @@ -562,7 +564,9 @@ public class NotKnown { }

public abstract class BaseContainer : IList<NotKnown>, ICollection<NotKnown>, IEnumerable<NotKnown>, IEnumerable, IList, ICollection
{
#pragma warning disable CS0649
private List<NotKnown> _inner;
#pragma warning restore CS0649

#region interfaces methods

Expand Down Expand Up @@ -663,9 +667,9 @@ public void Add(NotKnown item)
[Fact]
public void CanInstantiateSerializerForCollectionWithAmbiguousAddMethod()
{
var serializer = new Serializer(
new SerializerOptions(knownTypes: new List<Type> {typeof(DerivedContainer)},
serializerFactories: new List<ValueSerializerFactory> {new DerivedContainerSerializerFactory()}));
var serializer = new Serializer(SerializerOptions.Default
.WithKnownTypes(new List<Type> {typeof(DerivedContainer)})
.WithSerializerFactory(new List<ValueSerializerFactory> {new DerivedContainerSerializerFactory()}));
var init = new DerivedContainer();
serializer.Serialize(init, new MemoryStream());
// we're done if AmbiguousMatchException wasn't fired
Expand Down
2 changes: 1 addition & 1 deletion src/Hyperion.Tests/CustomObjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void CanEmptyObject()
[Fact]
public void CanSerializeObjectsKnownTypes()
{
CustomInit(new Serializer(new SerializerOptions(knownTypes: new[] { typeof(Something) })));
CustomInit(new Serializer(SerializerOptions.Default.WithKnownTypes(new[] { typeof(Something) })));
var expected1 = new Something
{
StringProp = "First"
Expand Down
18 changes: 13 additions & 5 deletions src/Hyperion.Tests/CyclicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public class CyclicTests
public void CanSerializeDeepCyclicReferences()
{
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions(versionTolerance: true, preserveObjectReferences: true));
var serializer = new Serializer(SerializerOptions.Default
.WithVersionTolerance(true)
.WithPreserveObjectReferences(true));
var root = new Root();
var bar = new Bar();
bar.Self = bar;
Expand All @@ -40,7 +42,9 @@ public void CanSerializeDeepCyclicReferences()
public void CanSerializeDictionaryPreserveObjectReferences()
{
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions(versionTolerance: true, preserveObjectReferences: true));
var serializer = new Serializer(SerializerOptions.Default
.WithVersionTolerance(true)
.WithPreserveObjectReferences(true));

var arr1 = new[] {1, 2, 3};
var arr2 = new[] { 1, 2, 3 };
Expand All @@ -64,7 +68,9 @@ public void CanSerializeDictionaryPreserveObjectReferences()
public void CanSerializeDictionaryPreserveObjectReferences2()
{
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions(versionTolerance: true, preserveObjectReferences: true));
var serializer = new Serializer(SerializerOptions.Default
.WithVersionTolerance(true)
.WithPreserveObjectReferences(true));

var val = new List<string> { "first", "second" };

Expand All @@ -91,7 +97,9 @@ public void CanSerializeDictionaryPreserveObjectReferences2()
public void CanSerializeCyclicReferences()
{
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions(versionTolerance: true, preserveObjectReferences: true));
var serializer = new Serializer(SerializerOptions.Default
.WithVersionTolerance(true)
.WithPreserveObjectReferences(true));
var bar = new Bar();
bar.Self = bar;
bar.XYZ = 234;
Expand All @@ -107,7 +115,7 @@ public void CanSerializeCyclicReferences()
public void CanSerializeMultiLevelCyclicReferences()
{
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions(preserveObjectReferences: true));
var serializer = new Serializer(SerializerOptions.Default.WithPreserveObjectReferences(true));
var a = new A();
var b = new B();
a.B = b;
Expand Down
8 changes: 4 additions & 4 deletions src/Hyperion.Tests/DelegateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Create()
public void CanSerializeMemberMethod()
{
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions());
var serializer = new Serializer(SerializerOptions.Default);

Func<string> a = 123.ToString;
serializer.Serialize(a, stream);
Expand All @@ -49,7 +49,7 @@ public void CanSerializeMemberMethod()
public void CanSerializeDelegate()
{
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions());
var serializer = new Serializer(SerializerOptions.Default);

Action<Dummy> a = dummy => dummy.Prop = 1;
serializer.Serialize(a,stream);
Expand All @@ -71,7 +71,7 @@ private static int StaticFunc(int a)
public void CanSerializeStaticDelegate()
{
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions());
var serializer = new Serializer(SerializerOptions.Default);

Func<int, int> fun = StaticFunc;

Expand All @@ -88,7 +88,7 @@ public void CanSerializeStaticDelegate()
public void CanSerializeObjectWithClosure()
{
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions());
var serializer = new Serializer(SerializerOptions.Default);

var hasClosure = new HasClosure();
hasClosure.Create();
Expand Down
2 changes: 1 addition & 1 deletion src/Hyperion.Tests/ExpressionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ public void CanSerializeLambdaExpression()
[Fact]
public void CanSerializeLambdaExpressionContainingGenericMethod() {
Expression<Func<Dummy, bool>> expr = dummy => dummy.TestField.Contains('s');
var serializer = new Serializer(new SerializerOptions(preserveObjectReferences: true));
var serializer = new Serializer(SerializerOptions.Default.WithPreserveObjectReferences(true));
using (var ms = new MemoryStream())
{
serializer.Serialize(expr, ms);
Expand Down
18 changes: 8 additions & 10 deletions src/Hyperion.Tests/IlCompilerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// -----------------------------------------------------------------------
#endregion

#if NET45
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -67,7 +66,7 @@ public void CanCallStaticMethodUsingParameter()
var a = c.Compile();
var dummy = new Dummy();
a(dummy);
Assert.Equal(true, dummy.BoolField);
Assert.True(dummy.BoolField);
}

[Fact]
Expand All @@ -79,7 +78,7 @@ public void CanCallInstanceMethodOnParameter()
var a = c.Compile();
var dummy = new Dummy();
a(dummy);
Assert.Equal(true, dummy.BoolField);
Assert.True(dummy.BoolField);
}


Expand All @@ -93,7 +92,7 @@ public void CanModifyParameter()
var a = c.Compile();
var dummy = new Dummy();
a(dummy);
Assert.Equal(true,dummy.BoolField);
Assert.True(dummy.BoolField);
}

[Fact]
Expand All @@ -112,7 +111,7 @@ public void CanCreateEmptyMethodWithReturnType()
c.Emit(b);
var a = c.Compile();
var res = a();
Assert.Equal(true,res);
Assert.True(res);
}

[Fact]
Expand Down Expand Up @@ -190,7 +189,7 @@ public void ReadSimulationFakeTupleString()
{
var value = new FakeTupleString("Hello");
var type = value.GetType();
var serializer = new Serializer(new SerializerOptions(knownTypes: new List<Type>() { type }));
var serializer = new Serializer(SerializerOptions.Default.WithKnownTypes(new List<Type>() { type }));
var session = new DeserializerSession(serializer);
var stream = new MemoryStream();

Expand All @@ -211,7 +210,7 @@ public void ReadSimulationOptionString()
{
var value = FSharpOption<string>.Some("abc");
var type = value.GetType();
var serializer = new Serializer(new SerializerOptions(knownTypes: new List<Type>() { type }));
var serializer = new Serializer(SerializerOptions.Default.WithKnownTypes(new List<Type>() { type }));
var session = new DeserializerSession(serializer);
var stream = new MemoryStream();

Expand All @@ -230,7 +229,7 @@ public void ReadSimulationTupleString()
{
var value = Tuple.Create("Hello");
var type = value.GetType();
var serializer = new Serializer(new SerializerOptions(knownTypes: new List<Type>() { type }));
var serializer = new Serializer(SerializerOptions.Default.WithKnownTypes(new List<Type>() { type }));
var session = new DeserializerSession(serializer);
var stream = new MemoryStream();

Expand All @@ -248,7 +247,7 @@ public void ReadSimulationTupleString()
[Fact]
public void ReadSimulation()
{
var serializer = new Serializer(new SerializerOptions(knownTypes:new List<Type>() {typeof(Poco)}));
var serializer = new Serializer(SerializerOptions.Default.WithKnownTypes(new List<Type>() {typeof(Poco)}));
var session = new DeserializerSession(serializer);
var stream = new MemoryStream();
var poco = new Poco()
Expand Down Expand Up @@ -306,4 +305,3 @@ private static ObjectReader GetDelegate(Type type, FieldInfo[] fields, Serialize
}
}
}
#endif
2 changes: 1 addition & 1 deletion src/Hyperion.Tests/InterfaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void CanSerializeInterfaceField()
}
};
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions());
var serializer = new Serializer(SerializerOptions.Default);
serializer.Serialize(b, stream);
stream.Position = 0;
var res = serializer.Deserialize(stream);
Expand Down
6 changes: 3 additions & 3 deletions src/Hyperion.Tests/SurrogateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void CanSerializeWithSurrogate()
})
};
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions(surrogates: surrogates));
var serializer = new Serializer(SerializerOptions.Default.WithSurrogates(surrogates));
var foo = new Foo
{
Bar = "I will be replaced!"
Expand All @@ -131,7 +131,7 @@ public void CanSerializeWithInterfaceSurrogate()
})
};
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions(surrogates: surrogates));
var serializer = new Serializer(SerializerOptions.Default.WithSurrogates(surrogates));
var foo = new Foo
{
Bar = "I will be replaced!"
Expand All @@ -157,7 +157,7 @@ public void CanSerializeWithSurrogateInCollection()
})
};
var stream = new MemoryStream();
var serializer = new Serializer(new SerializerOptions(surrogates: surrogates));
var serializer = new Serializer(SerializerOptions.Default.WithSurrogates(surrogates));
var key = new SurrogatedKey("test key");
var foo = new Foo
{
Expand Down
3 changes: 0 additions & 3 deletions src/Hyperion.Tests/UnsupportedTypeSerializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ public void DoUnsupportedTypesThrowErrors()


/* Copied from MongoDB.Bson.BsonElement - causes failures in the serializer - not sure why */
#if NET45
[Serializable]
#endif

internal struct TestElement : IComparable<TestElement>, IEquatable<TestElement>
{
public TestElement(string name, string value)
Expand Down
Loading