From 6bafc4c747068adf0e5e1f68e21e6b05d1363b3a Mon Sep 17 00:00:00 2001 From: jkuehner Date: Wed, 23 Sep 2020 18:05:07 +0200 Subject: [PATCH 01/18] bugfix not using know serializers when defined --- .../SerializerFactories/ArraySerializerFactory.cs | 9 ++++++++- .../ConstructorInfoSerializerFactory.cs | 8 +++++++- .../DefaultDictionarySerializerFactory.cs | 8 +++++++- .../SerializerFactories/DelegateSerializerFactory.cs | 8 +++++++- .../SerializerFactories/DictionarySerializerFactory.cs | 8 +++++++- .../SerializerFactories/EnumerableSerializerFactory.cs | 8 +++++++- .../SerializerFactories/ExceptionSerializerFactory.cs | 8 +++++++- .../ExpandoObjectSerializerFactory.cs | 8 +++++++- .../SerializerFactories/FSharpListSerializerFactory.cs | 8 +++++++- .../SerializerFactories/FSharpMapSerializerFactory.cs | 8 +++++++- .../SerializerFactories/FieldInfoSerializerFactory.cs | 8 +++++++- .../ImmutableCollectionsSerializerFactory.cs | 8 +++++++- .../SerializerFactories/MethodInfoSerializerFactory.cs | 8 +++++++- .../MultipleDimensionalArraySerialzierFactory.cs | 8 +++++++- .../SerializerFactories/PropertyInfoSerializerFactory.cs | 8 +++++++- 15 files changed, 106 insertions(+), 15 deletions(-) diff --git a/src/Hyperion/SerializerFactories/ArraySerializerFactory.cs b/src/Hyperion/SerializerFactories/ArraySerializerFactory.cs index a4ac76a3..797d635b 100644 --- a/src/Hyperion/SerializerFactories/ArraySerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/ArraySerializerFactory.cs @@ -71,7 +71,14 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type WriteValues((dynamic)arr, stream, elementType, elementSerializer, session); }; arraySerializer.Initialize(reader, writer); - typeMapping.TryAdd(type, arraySerializer); + + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(arraySerializer, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, arraySerializer); return arraySerializer; } } diff --git a/src/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs b/src/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs index 877bc950..6cf7f5e3 100644 --- a/src/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs @@ -32,7 +32,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var os = new ObjectSerializer(type); - typeMapping.TryAdd(type, os); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(os, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, os); ObjectReader reader = (stream, session) => { var owner = stream.ReadObject(session) as Type; diff --git a/src/Hyperion/SerializerFactories/DefaultDictionarySerializerFactory.cs b/src/Hyperion/SerializerFactories/DefaultDictionarySerializerFactory.cs index b7d26ece..29902e95 100644 --- a/src/Hyperion/SerializerFactories/DefaultDictionarySerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/DefaultDictionarySerializerFactory.cs @@ -31,7 +31,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var ser = new ObjectSerializer(type); - typeMapping.TryAdd(type, ser); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(ser, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, ser); var elementSerializer = serializer.GetSerializerByType(typeof (DictionaryEntry)); var preserveObjectReferences = serializer.Options.PreserveObjectReferences; ObjectReader reader = (stream, session) => diff --git a/src/Hyperion/SerializerFactories/DelegateSerializerFactory.cs b/src/Hyperion/SerializerFactories/DelegateSerializerFactory.cs index 850233df..6181c81e 100644 --- a/src/Hyperion/SerializerFactories/DelegateSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/DelegateSerializerFactory.cs @@ -31,7 +31,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var os = new ObjectSerializer(type); - typeMapping.TryAdd(type, os); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(os, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, os); var methodInfoSerializer = serializer.GetSerializerByType(typeof(MethodInfo)); var preserveObjectReferences = serializer.Options.PreserveObjectReferences; ObjectReader reader = (stream, session) => diff --git a/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs b/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs index 113317b5..4c6fdbec 100644 --- a/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs @@ -39,7 +39,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type { var preserveObjectReferences = serializer.Options.PreserveObjectReferences; var ser = new ObjectSerializer(type); - typeMapping.TryAdd(type, ser); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(ser, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, ser); var dictionaryTypes = GetKeyValuePairType(type); var elementSerializer = serializer.GetSerializerByType(dictionaryTypes.KeyValuePairType); diff --git a/src/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs b/src/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs index ebadbf2b..854d40e2 100644 --- a/src/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs @@ -136,7 +136,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var x = new ObjectSerializer(type); - typeMapping.TryAdd(type, x); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(x, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, x); var preserveObjectReferences = serializer.Options.PreserveObjectReferences; diff --git a/src/Hyperion/SerializerFactories/ExceptionSerializerFactory.cs b/src/Hyperion/SerializerFactories/ExceptionSerializerFactory.cs index f7ac7b63..aca00d58 100644 --- a/src/Hyperion/SerializerFactories/ExceptionSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/ExceptionSerializerFactory.cs @@ -91,7 +91,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type StringSerializer.WriteValueImpl(stream, stackTraceString, session); stream.WriteObjectWithManifest(innerException, session); }); - typeMapping.TryAdd(type, exceptionSerializer); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(exceptionSerializer, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, exceptionSerializer); return exceptionSerializer; } } diff --git a/src/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs b/src/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs index b04775a0..48ba56af 100644 --- a/src/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs @@ -29,7 +29,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type { var preserveObjectReferences = serializer.Options.PreserveObjectReferences; var ser = new ObjectSerializer(type); - typeMapping.TryAdd(type, ser); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(ser, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, ser); var elementSerializer = serializer.GetSerializerByType(typeof(DictionaryEntry)); ObjectReader reader = (stream, session) => diff --git a/src/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs b/src/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs index abcfd41f..4716d355 100644 --- a/src/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs @@ -48,7 +48,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var x = new ObjectSerializer(type); - typeMapping.TryAdd(type, x); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(x, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, x); var elementType = GetEnumerableType(type); var arrType = elementType.MakeArrayType(); diff --git a/src/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs b/src/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs index 55db6c2d..5d2738e0 100644 --- a/src/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs @@ -64,7 +64,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var x = new ObjectSerializer(type); - typeMapping.TryAdd(type, x); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(x, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, x); var keyType = GetKeyType(type); var valueType = GetValyeType(type); diff --git a/src/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs b/src/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs index 84685233..adf5e1d3 100644 --- a/src/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs @@ -31,7 +31,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var os = new ObjectSerializer(type); - typeMapping.TryAdd(type, os); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(os, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, os); ObjectReader reader = (stream, session) => { var name = stream.ReadString(session); diff --git a/src/Hyperion/SerializerFactories/ImmutableCollectionsSerializerFactory.cs b/src/Hyperion/SerializerFactories/ImmutableCollectionsSerializerFactory.cs index e6eab05e..29004b9e 100644 --- a/src/Hyperion/SerializerFactories/ImmutableCollectionsSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/ImmutableCollectionsSerializerFactory.cs @@ -49,7 +49,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var x = new ObjectSerializer(type); - typeMapping.TryAdd(type, x); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(x, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, x); var preserveObjectReferences = serializer.Options.PreserveObjectReferences; var elementType = GetEnumerableType(type) ?? typeof (object); diff --git a/src/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs b/src/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs index 44b63e41..7444cf8d 100644 --- a/src/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs @@ -32,7 +32,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var os = new ObjectSerializer(type); - typeMapping.TryAdd(type, os); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(os, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, os); ObjectReader reader = (stream, session) => { var name = stream.ReadString(session); diff --git a/src/Hyperion/SerializerFactories/MultipleDimensionalArraySerialzierFactory.cs b/src/Hyperion/SerializerFactories/MultipleDimensionalArraySerialzierFactory.cs index cdfab7a2..86d83bce 100644 --- a/src/Hyperion/SerializerFactories/MultipleDimensionalArraySerialzierFactory.cs +++ b/src/Hyperion/SerializerFactories/MultipleDimensionalArraySerialzierFactory.cs @@ -142,7 +142,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type WriteValues((Array)arr, stream, elementType, elementSerializer, session); }; arraySerializer.Initialize(reader, writer); - typeMapping.TryAdd(type, arraySerializer); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(arraySerializer, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, arraySerializer); return arraySerializer; } diff --git a/src/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs b/src/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs index c9359518..45d47ad8 100644 --- a/src/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs @@ -31,7 +31,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var os = new ObjectSerializer(type); - typeMapping.TryAdd(type, os); + if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) + { + var wrapper = new KnownTypeObjectSerializer(os, index); + typeMapping.TryAdd(type, wrapper); + } + else + typeMapping.TryAdd(type, os); ObjectReader reader = (stream, session) => { var name = stream.ReadString(session); From e214023eb0a18db8ed2e8238d48de76ab89be89e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 24 Sep 2020 23:29:52 +0000 Subject: [PATCH 02/18] Bump Microsoft.NET.Test.Sdk from 16.6.1 to 16.7.1 (#182) --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index 324f0a7d..82e2f636 100644 --- a/src/common.props +++ b/src/common.props @@ -15,7 +15,7 @@ 2.4.1 - 16.6.1 + 16.7.1 1.2.2 \ No newline at end of file From dcc036f8eea952476a15350960ec5011ac9296af Mon Sep 17 00:00:00 2001 From: Ralf Date: Wed, 7 Oct 2020 10:10:04 +0200 Subject: [PATCH 03/18] fixed issue #40 regarding partial streams --- src/Hyperion.Tests/PartialStreamTest.cs | 58 +++++++++++++++++++ src/Hyperion.Tests/PrimitivesTests.cs | 10 ++++ src/Hyperion.Tests/TestBase.cs | 10 +++- src/Hyperion/Extensions/StreamEx.cs | 37 ++++++++++-- .../ValueSerializers/CharSerializer.cs | 3 +- .../ConsistentArraySerializer.cs | 2 +- .../DateTimeOffsetSerializer.cs | 3 +- .../ValueSerializers/DateTimeSerializer.cs | 3 +- .../ValueSerializers/DoubleSerializer.cs | 3 +- .../ValueSerializers/FloatSerializer.cs | 3 +- .../ValueSerializers/GuidSerializer.cs | 2 +- .../ValueSerializers/Int16Serializer.cs | 3 +- .../ValueSerializers/Int32Serializer.cs | 3 +- .../ValueSerializers/Int64Serializer.cs | 3 +- .../ValueSerializers/UInt16Serializer.cs | 3 +- .../ValueSerializers/UInt32Serializer.cs | 3 +- .../ValueSerializers/UInt64Serializer.cs | 3 +- 17 files changed, 132 insertions(+), 20 deletions(-) create mode 100644 src/Hyperion.Tests/PartialStreamTest.cs diff --git a/src/Hyperion.Tests/PartialStreamTest.cs b/src/Hyperion.Tests/PartialStreamTest.cs new file mode 100644 index 00000000..a4ed6b09 --- /dev/null +++ b/src/Hyperion.Tests/PartialStreamTest.cs @@ -0,0 +1,58 @@ +using System.IO; + +namespace Hyperion.Tests +{ + public class PartialStreamTest : PrimitivesTest + { + public PartialStreamTest() + : base(x => new OneBytePerReadStream(x)) + { + } + + private class OneBytePerReadStream : Stream + { + private readonly Stream _baseStream; + + public OneBytePerReadStream(Stream baseStream) + { + _baseStream = baseStream; + } + + public override void Flush() + { + _baseStream.Flush(); + } + + public override long Seek(long offset, SeekOrigin origin) + { + return _baseStream.Seek(offset, origin); + } + + public override void SetLength(long value) + { + _baseStream.SetLength(value); + } + + public override int Read(byte[] buffer, int offset, int count) + { + return _baseStream.Read(buffer, offset, count > 0 ? 1 : 0); + } + + public override void Write(byte[] buffer, int offset, int count) + { + _baseStream.Write(buffer, offset, count); + } + + public override bool CanRead => _baseStream.CanRead; + public override bool CanSeek => _baseStream.CanSeek; + public override bool CanWrite => _baseStream.CanWrite; + public override long Length => _baseStream.Length; + + public override long Position + { + get => _baseStream.Position; + set => _baseStream.Position = value; + } + } + } +} \ No newline at end of file diff --git a/src/Hyperion.Tests/PrimitivesTests.cs b/src/Hyperion.Tests/PrimitivesTests.cs index 8a050905..0595502f 100644 --- a/src/Hyperion.Tests/PrimitivesTests.cs +++ b/src/Hyperion.Tests/PrimitivesTests.cs @@ -8,6 +8,7 @@ #endregion using System; +using System.IO; using Xunit; namespace Hyperion.Tests @@ -15,6 +16,15 @@ namespace Hyperion.Tests public class PrimitivesTest : TestBase { + public PrimitivesTest() + { + } + + protected PrimitivesTest(Func streamFacade) + : base(streamFacade) + { + } + [Fact] public void CanSerializeTuple1() { diff --git a/src/Hyperion.Tests/TestBase.cs b/src/Hyperion.Tests/TestBase.cs index 91480501..c295750c 100644 --- a/src/Hyperion.Tests/TestBase.cs +++ b/src/Hyperion.Tests/TestBase.cs @@ -7,6 +7,7 @@ // ----------------------------------------------------------------------- #endregion +using System; using System.IO; using Xunit; @@ -15,12 +16,17 @@ namespace Hyperion.Tests public abstract class TestBase { private Serializer _serializer; - private readonly MemoryStream _stream; + private readonly Stream _stream; protected TestBase() + : this(x => x) + { + } + + protected TestBase(Func streamFacade) { _serializer = new Serializer(); - _stream = new MemoryStream(); + _stream = streamFacade(new MemoryStream()); } protected void CustomInit(Serializer serializer) diff --git a/src/Hyperion/Extensions/StreamEx.cs b/src/Hyperion/Extensions/StreamEx.cs index 01c7cd09..a2800542 100644 --- a/src/Hyperion/Extensions/StreamEx.cs +++ b/src/Hyperion/Extensions/StreamEx.cs @@ -15,7 +15,6 @@ namespace Hyperion.Extensions { internal static class StreamEx { - public static uint ReadVarint32(this Stream stream) { int result = 0; @@ -75,7 +74,7 @@ public static void WriteVarint64(this Stream stream, ulong value) public static uint ReadUInt16(this Stream self, DeserializerSession session) { var buffer = session.GetBuffer(2); - self.Read(buffer, 0, 2); + self.ReadFull(buffer, 0, 2); var res = BitConverter.ToUInt16(buffer, 0); return res; } @@ -83,7 +82,7 @@ public static uint ReadUInt16(this Stream self, DeserializerSession session) public static int ReadInt32(this Stream self, DeserializerSession session) { var buffer = session.GetBuffer(4); - self.Read(buffer, 0, 4); + self.ReadFull(buffer, 0, 4); var res = BitConverter.ToInt32(buffer, 0); return res; } @@ -92,7 +91,7 @@ public static byte[] ReadLengthEncodedByteArray(this Stream self, DeserializerSe { var length = self.ReadInt32(session); var buffer = new byte[length]; - self.Read(buffer, 0, length); + self.ReadFull(buffer, 0, length); return buffer; } @@ -190,9 +189,37 @@ public static string ReadString(this Stream stream, DeserializerSession session) var buffer = session.GetBuffer(length); - stream.Read(buffer, 0, length); + stream.ReadFull(buffer, 0, length); var res = StringEx.FromUtf8Bytes(buffer, 0, length); return res; } + + /// + /// Repeats reading from stream until requested bytes were read. + /// Returns with partial result if stream can't provide enough bytes + /// Fixes issue: https://github.com/akkadotnet/Hyperion/issues/40 + /// Reference for allowed partial streams: https://docs.microsoft.com/en-us/dotnet/api/system.io.stream.read?redirectedfrom=MSDN&view=netcore-3.1#System_IO_Stream_Read_System_Byte___System_Int32_System_Int32_ + /// -> "An implementation is free to return fewer bytes than requested even if the end of the stream has not been reached." + /// + public static int ReadFull(this Stream stream, byte[] buffer, int offset, int count) + { + // fast path for streams which doesn't deliver partial results + var totalReadBytes = stream.Read(buffer, offset, count); + if (totalReadBytes == count) + return totalReadBytes; + + // support streams with partial results + do + { + var readBytes = stream.Read(buffer, offset + totalReadBytes, count - totalReadBytes); + if (readBytes == 0) + break; + + totalReadBytes += readBytes; + } + while (totalReadBytes < count); + + return totalReadBytes; + } } } \ No newline at end of file diff --git a/src/Hyperion/ValueSerializers/CharSerializer.cs b/src/Hyperion/ValueSerializers/CharSerializer.cs index 84cf3c0f..046d49f0 100644 --- a/src/Hyperion/ValueSerializers/CharSerializer.cs +++ b/src/Hyperion/ValueSerializers/CharSerializer.cs @@ -9,6 +9,7 @@ using System; using System.IO; +using Hyperion.Extensions; namespace Hyperion.ValueSerializers { @@ -24,7 +25,7 @@ public CharSerializer() : base(Manifest, () => WriteValueImpl, () => ReadValueIm public static char ReadValueImpl(Stream stream, byte[] bytes) { - stream.Read(bytes, 0, Size); + stream.ReadFull(bytes, 0, Size); return BitConverter.ToChar(bytes, 0); } diff --git a/src/Hyperion/ValueSerializers/ConsistentArraySerializer.cs b/src/Hyperion/ValueSerializers/ConsistentArraySerializer.cs index ec07500b..6ce232cd 100644 --- a/src/Hyperion/ValueSerializers/ConsistentArraySerializer.cs +++ b/src/Hyperion/ValueSerializers/ConsistentArraySerializer.cs @@ -36,7 +36,7 @@ public override object ReadValue(Stream stream, DeserializerSession session) var size = elementType.GetTypeSize(); var totalSize = size*length; var buffer = session.GetBuffer(totalSize); - stream.Read(buffer, 0, totalSize); + stream.ReadFull(buffer, 0, totalSize); Buffer.BlockCopy(buffer, 0, array, 0, totalSize); } else diff --git a/src/Hyperion/ValueSerializers/DateTimeOffsetSerializer.cs b/src/Hyperion/ValueSerializers/DateTimeOffsetSerializer.cs index c753963d..46a99675 100644 --- a/src/Hyperion/ValueSerializers/DateTimeOffsetSerializer.cs +++ b/src/Hyperion/ValueSerializers/DateTimeOffsetSerializer.cs @@ -9,6 +9,7 @@ using System; using System.IO; +using Hyperion.Extensions; namespace Hyperion.ValueSerializers { @@ -36,7 +37,7 @@ public static DateTimeOffset ReadValueImpl(Stream stream, byte[] bytes) private static DateTimeOffset ReadDateTimeOffset(Stream stream, byte[] bytes) { - stream.Read(bytes, 0, Size); + stream.ReadFull(bytes, 0, Size); var dateTimeTicks = BitConverter.ToInt64(bytes, 0); var offsetTicks = BitConverter.ToInt64(bytes, sizeof(long)); var dateTimeOffset = new DateTimeOffset(dateTimeTicks, TimeSpan.FromTicks(offsetTicks)); diff --git a/src/Hyperion/ValueSerializers/DateTimeSerializer.cs b/src/Hyperion/ValueSerializers/DateTimeSerializer.cs index a608a431..546ff202 100644 --- a/src/Hyperion/ValueSerializers/DateTimeSerializer.cs +++ b/src/Hyperion/ValueSerializers/DateTimeSerializer.cs @@ -9,6 +9,7 @@ using System; using System.IO; +using Hyperion.Extensions; namespace Hyperion.ValueSerializers { @@ -36,7 +37,7 @@ public static DateTime ReadValueImpl(Stream stream, byte[] bytes) private static DateTime ReadDateTime(Stream stream, byte[] bytes) { - stream.Read(bytes, 0, Size); + stream.ReadFull(bytes, 0, Size); var ticks = BitConverter.ToInt64(bytes, 0); var kind = (DateTimeKind) bytes[Size - 1]; //avoid reading a single byte from the stream var dateTime = new DateTime(ticks, kind); diff --git a/src/Hyperion/ValueSerializers/DoubleSerializer.cs b/src/Hyperion/ValueSerializers/DoubleSerializer.cs index d1f2f437..88c43d96 100644 --- a/src/Hyperion/ValueSerializers/DoubleSerializer.cs +++ b/src/Hyperion/ValueSerializers/DoubleSerializer.cs @@ -9,6 +9,7 @@ using System; using System.IO; +using Hyperion.Extensions; namespace Hyperion.ValueSerializers { @@ -30,7 +31,7 @@ public static void WriteValueImpl(Stream stream, double d, byte[] bytes) public static double ReadValueImpl(Stream stream, byte[] bytes) { - stream.Read(bytes, 0, Size); + stream.ReadFull(bytes, 0, Size); return BitConverter.ToDouble(bytes, 0); } diff --git a/src/Hyperion/ValueSerializers/FloatSerializer.cs b/src/Hyperion/ValueSerializers/FloatSerializer.cs index 8988aaab..c518cd8f 100644 --- a/src/Hyperion/ValueSerializers/FloatSerializer.cs +++ b/src/Hyperion/ValueSerializers/FloatSerializer.cs @@ -9,6 +9,7 @@ using System; using System.IO; +using Hyperion.Extensions; namespace Hyperion.ValueSerializers { @@ -30,7 +31,7 @@ public static void WriteValueImpl(Stream stream, float f, byte[] bytes) public static float ReadValueImpl(Stream stream, byte[] bytes) { - stream.Read(bytes, 0, Size); + stream.ReadFull(bytes, 0, Size); return BitConverter.ToSingle(bytes, 0); } diff --git a/src/Hyperion/ValueSerializers/GuidSerializer.cs b/src/Hyperion/ValueSerializers/GuidSerializer.cs index eaaac0f8..d17e2ae3 100644 --- a/src/Hyperion/ValueSerializers/GuidSerializer.cs +++ b/src/Hyperion/ValueSerializers/GuidSerializer.cs @@ -31,7 +31,7 @@ public static void WriteValueImpl(Stream stream, Guid g) public static Guid ReadValueImpl(Stream stream) { var buffer = new byte[16]; - stream.Read(buffer, 0, 16); + stream.ReadFull(buffer, 0, 16); return new Guid(buffer); } } diff --git a/src/Hyperion/ValueSerializers/Int16Serializer.cs b/src/Hyperion/ValueSerializers/Int16Serializer.cs index 3a38333b..8c07fe2b 100644 --- a/src/Hyperion/ValueSerializers/Int16Serializer.cs +++ b/src/Hyperion/ValueSerializers/Int16Serializer.cs @@ -9,6 +9,7 @@ using System; using System.IO; +using Hyperion.Extensions; namespace Hyperion.ValueSerializers { @@ -30,7 +31,7 @@ public static void WriteValueImpl(Stream stream, short sh, byte[] bytes) public static short ReadValueImpl(Stream stream, byte[] bytes) { - stream.Read(bytes, 0, Size); + stream.ReadFull(bytes, 0, Size); return BitConverter.ToInt16(bytes, 0); } diff --git a/src/Hyperion/ValueSerializers/Int32Serializer.cs b/src/Hyperion/ValueSerializers/Int32Serializer.cs index f7358e43..17e297fb 100644 --- a/src/Hyperion/ValueSerializers/Int32Serializer.cs +++ b/src/Hyperion/ValueSerializers/Int32Serializer.cs @@ -9,6 +9,7 @@ using System; using System.IO; +using Hyperion.Extensions; namespace Hyperion.ValueSerializers { @@ -37,7 +38,7 @@ public static void WriteValueImpl(Stream stream, int i, SerializerSession sessio public static int ReadValueImpl(Stream stream, byte[] bytes) { - stream.Read(bytes, 0, Size); + stream.ReadFull(bytes, 0, Size); return BitConverter.ToInt32(bytes, 0); } diff --git a/src/Hyperion/ValueSerializers/Int64Serializer.cs b/src/Hyperion/ValueSerializers/Int64Serializer.cs index d14ef9ab..b9b75160 100644 --- a/src/Hyperion/ValueSerializers/Int64Serializer.cs +++ b/src/Hyperion/ValueSerializers/Int64Serializer.cs @@ -9,6 +9,7 @@ using System; using System.IO; +using Hyperion.Extensions; namespace Hyperion.ValueSerializers { @@ -30,7 +31,7 @@ public static void WriteValueImpl(Stream stream, long l, byte[] bytes) public static long ReadValueImpl(Stream stream, byte[] bytes) { - stream.Read(bytes, 0, Size); + stream.ReadFull(bytes, 0, Size); return BitConverter.ToInt64(bytes, 0); } diff --git a/src/Hyperion/ValueSerializers/UInt16Serializer.cs b/src/Hyperion/ValueSerializers/UInt16Serializer.cs index 397fcbc8..dc2d5185 100644 --- a/src/Hyperion/ValueSerializers/UInt16Serializer.cs +++ b/src/Hyperion/ValueSerializers/UInt16Serializer.cs @@ -9,6 +9,7 @@ using System; using System.IO; +using Hyperion.Extensions; namespace Hyperion.ValueSerializers { @@ -35,7 +36,7 @@ public static void WriteValueImpl(Stream stream, ushort u, SerializerSession ses public static ushort ReadValueImpl(Stream stream, byte[] bytes) { - stream.Read(bytes, 0, Size); + stream.ReadFull(bytes, 0, Size); return BitConverter.ToUInt16(bytes, 0); } diff --git a/src/Hyperion/ValueSerializers/UInt32Serializer.cs b/src/Hyperion/ValueSerializers/UInt32Serializer.cs index 197564d0..93978bf9 100644 --- a/src/Hyperion/ValueSerializers/UInt32Serializer.cs +++ b/src/Hyperion/ValueSerializers/UInt32Serializer.cs @@ -9,6 +9,7 @@ using System; using System.IO; +using Hyperion.Extensions; namespace Hyperion.ValueSerializers { @@ -30,7 +31,7 @@ public static void WriteValueImpl(Stream stream, uint u, byte[] bytes) public static uint ReadValueImpl(Stream stream, byte[] bytes) { - stream.Read(bytes, 0, Size); + stream.ReadFull(bytes, 0, Size); return BitConverter.ToUInt32(bytes, 0); } diff --git a/src/Hyperion/ValueSerializers/UInt64Serializer.cs b/src/Hyperion/ValueSerializers/UInt64Serializer.cs index 662d8666..ac55cbeb 100644 --- a/src/Hyperion/ValueSerializers/UInt64Serializer.cs +++ b/src/Hyperion/ValueSerializers/UInt64Serializer.cs @@ -9,6 +9,7 @@ using System; using System.IO; +using Hyperion.Extensions; namespace Hyperion.ValueSerializers { @@ -30,7 +31,7 @@ public static void WriteValueImpl(Stream stream, ulong ul, byte[] bytes) public static ulong ReadValueImpl(Stream stream, byte[] bytes) { - stream.Read(bytes, 0, Size); + stream.ReadFull(bytes, 0, Size); return BitConverter.ToUInt64(bytes, 0); } From 82eb0f37e01c0c16f433f5632a39287fe71ceb8b Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Tue, 27 Oct 2020 00:08:06 +0700 Subject: [PATCH 04/18] Fix unit test problem (#191) * Remove netcoreapp2.1 from unit test targt framework * Bump xunit.runner.visualstudio to 2.4.3 --- src/Hyperion.Tests/Hyperion.Tests.csproj | 4 ++-- src/common.props | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Hyperion.Tests/Hyperion.Tests.csproj b/src/Hyperion.Tests/Hyperion.Tests.csproj index 2247c51a..67fac9e7 100644 --- a/src/Hyperion.Tests/Hyperion.Tests.csproj +++ b/src/Hyperion.Tests/Hyperion.Tests.csproj @@ -3,7 +3,7 @@ Exe - net461;netcoreapp2.1;netcoreapp3.0 + net461;netcoreapp3.0 true latest Hyperion.Tests.Generator.Program @@ -14,7 +14,7 @@ - + diff --git a/src/common.props b/src/common.props index 82e2f636..c52dabb8 100644 --- a/src/common.props +++ b/src/common.props @@ -15,6 +15,7 @@ 2.4.1 + 2.4.3 16.7.1 1.2.2 From 4f16c3e1018b5bf71f0567d2b365e51f1de22b5c Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 26 Oct 2020 20:24:22 +0000 Subject: [PATCH 05/18] Bump FSharp.Core from 4.7.2 to 5.0.0 (#189) --- src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj b/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj index 75179c29..80af7cad 100644 --- a/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj +++ b/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj @@ -9,7 +9,7 @@ - + From 9c725c03afbc8288a1c853a8ff3e263a892888b8 Mon Sep 17 00:00:00 2001 From: jkuehner Date: Wed, 28 Oct 2020 22:19:32 +0100 Subject: [PATCH 06/18] Create Test for Issue #183 --- src/Hyperion.Tests/Bugs.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Hyperion.Tests/Bugs.cs b/src/Hyperion.Tests/Bugs.cs index a4ebe36c..9783aec4 100644 --- a/src/Hyperion.Tests/Bugs.cs +++ b/src/Hyperion.Tests/Bugs.cs @@ -8,9 +8,11 @@ #endregion using System; +using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; using System.IO; +using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Text; @@ -246,5 +248,26 @@ public Recover(SnapshotSelectionCriteria fromSnapshot, long toSequenceNr = long. /// public long ReplayMax { get; private set; } } + + class Temp + { + public object[] SubArray { get; set; } + public string aa { get; set; } + public Dictionary dc { get; set; } + } + + [Fact] + public void WritesManifestEvenIfKnown1() + { + var stream = new MemoryStream(); + var msg = new Temp() { aa = "huhu", dc = new Dictionary() { { "a", "b" } }, SubArray = new object[] { 1, (byte)2, new object[] { 3 } } }; + var serializer = new Serializer(new SerializerOptions(knownTypes: new[] { typeof(DictionaryEntry), typeof(Dictionary), typeof(Temp), typeof(object[]), })); + serializer.Serialize(msg, stream); + stream.Position = 0; + var a = stream.ToArray(); + var text = string.Join("", a.Select(x => ((char)x).ToString())); + var res = serializer.Deserialize(stream); + Assert.DoesNotContain("System.Collections.Generic.Dictionary", text); + } } } From d13f8dd5bb3cb3cbf16db8529072f0090a65d3d4 Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Thu, 29 Oct 2020 13:39:40 +0700 Subject: [PATCH 07/18] Add a more aggresive unit test --- src/Hyperion.Tests/Bugs.cs | 222 +++++++++++++++++++++++++++++++++++-- 1 file changed, 214 insertions(+), 8 deletions(-) diff --git a/src/Hyperion.Tests/Bugs.cs b/src/Hyperion.Tests/Bugs.cs index 9783aec4..ebd9f562 100644 --- a/src/Hyperion.Tests/Bugs.cs +++ b/src/Hyperion.Tests/Bugs.cs @@ -19,12 +19,20 @@ using FluentAssertions; using Hyperion.Extensions; using Xunit; +using Xunit.Abstractions; namespace Hyperion.Tests { public class Bugs { + private readonly ITestOutputHelper _output; + + public Bugs(ITestOutputHelper output) + { + _output = output; + } + #region issue 58 public enum TrustLevel { Unknown, Suspicious, Partial, Fully } @@ -249,25 +257,223 @@ public Recover(SnapshotSelectionCriteria fromSnapshot, long toSequenceNr = long. public long ReplayMax { get; private set; } } - class Temp + delegate int TestDelegate(int x, int y); + + class Temp : IEquatable { public object[] SubArray { get; set; } - public string aa { get; set; } - public Dictionary dc { get; set; } + public int[] IntArray { get; set; } + public int[,] IntIntArray { get; set; } + public Poco Poco { get; set; } + public string String { get; set; } + public Dictionary Dictionary { get; set; } + public TestDelegate Delegate { get; set; } + public IEnumerable TestEnum { get; set; } + public Exception Exception { get; set; } + public ImmutableList ImmutableList { get; set; } + public ImmutableDictionary ImmutableDictionary { get; set; } + + public bool Equals(Temp other) + { + if (other == null) + throw new Exception("Equals failed."); + if (ReferenceEquals(this, other)) + throw new Exception("Equals failed."); + if (IntIntArray.Rank != other.IntIntArray.Rank) + throw new Exception("Equals failed."); + + for (var i = 0; i < IntIntArray.Rank; ++i) + { + for (var j = 0; j < IntIntArray.GetLength(i); ++j) + { + if (IntIntArray[j, i] != other.IntIntArray[j, i]) + throw new Exception("Equals failed."); + } + } + + if (Exception.GetType() != other.Exception.GetType()) + throw new Exception("Equals failed."); + if (Exception.Message != other.Exception.Message) + throw new Exception("Equals failed."); + if(Exception.InnerException != null + && Exception.InnerException.GetType() != other.Exception.InnerException.GetType()) + throw new Exception("Equals failed."); + + for (var i = 0; i < SubArray.Length; i++) + { + if (SubArray[i].GetType() != other.SubArray[i].GetType()) + throw new Exception("Equals failed."); + + if (SubArray[i] is Array arr) + { + var oArr = (Array)other.SubArray[i]; + for (var j = 0; j < arr.Length; ++j) + { + if (!arr.GetValue(j).Equals(oArr.GetValue(j))) + throw new Exception("Equals failed."); + } + } else if (!SubArray[i].Equals(other.SubArray[i])) + throw new Exception("Equals failed."); + } + + foreach (var key in Dictionary.Keys) + { + if (!Dictionary[key].Equals(other.Dictionary[key])) + throw new Exception("Equals failed."); + } + + foreach (var key in ImmutableDictionary.Keys) + { + if (!ImmutableDictionary[key].Equals(other.ImmutableDictionary[key])) + throw new Exception("Equals failed."); + } + + if (other.Delegate(2, 2) != 4) + throw new Exception("Equals failed."); + + if(!IntArray.SequenceEqual(other.IntArray)) + throw new Exception("Equals failed."); + if(!Equals(Poco, other.Poco)) + throw new Exception("Equals failed."); + if (String != other.String) + throw new Exception("Equals failed."); + if(!TestEnum.SequenceEqual(other.TestEnum)) + throw new Exception("Equals failed."); + if(!ImmutableList.SequenceEqual(other.ImmutableList)) + throw new Exception("Equals failed."); + + return true; + } + + public override bool Equals(object obj) + { + if (obj == null) throw new Exception("Equals failed."); + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) throw new Exception("Equals failed."); + return Equals((Temp) obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = (SubArray != null ? SubArray.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (IntArray != null ? IntArray.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (IntIntArray != null ? IntIntArray.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (Poco != null ? Poco.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (String != null ? String.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (Dictionary != null ? Dictionary.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (Delegate != null ? Delegate.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (TestEnum != null ? TestEnum.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (Exception != null ? Exception.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (ImmutableList != null ? ImmutableList.GetHashCode() : 0); + return hashCode; + } + } + } + + class Poco : IEquatable + { + public Poco() + { } + + public Poco(int intValue, string stringValue) + { + Int = intValue; + String = stringValue; + } + + public int Int { get; set; } + public string String { get; set; } + + public bool Equals(Poco other) + { + if (ReferenceEquals(null, other)) + throw new Exception("Equals failed."); + if (ReferenceEquals(this, other)) + throw new Exception("Equals failed."); + if(Int != other.Int) + throw new Exception("Equals failed."); + if(String != other.String) + throw new Exception("Equals failed."); + return true; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) throw new Exception("Equals failed."); + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) throw new Exception("Equals failed."); + return Equals((Poco) obj); + } + + public override int GetHashCode() + { + unchecked + { + return (Int * 397) ^ (String != null ? String.GetHashCode() : 0); + } + } } [Fact] - public void WritesManifestEvenIfKnown1() + public void WritesManifestEvenIfKnown() { var stream = new MemoryStream(); - var msg = new Temp() { aa = "huhu", dc = new Dictionary() { { "a", "b" } }, SubArray = new object[] { 1, (byte)2, new object[] { 3 } } }; - var serializer = new Serializer(new SerializerOptions(knownTypes: new[] { typeof(DictionaryEntry), typeof(Dictionary), typeof(Temp), typeof(object[]), })); + var msg = new Temp + { + SubArray = new object[] { 1, (byte)2, new object[] { 3 } }, + IntArray = new [] {1, 2, 3, 4, 5}, + IntIntArray = new [,] {{1, 2}, {3,4}, {5,6}, {7,8}}, + Poco = new Poco(999, "666"), + String = "huhu", + Dictionary = new Dictionary + { + { 666, "b" }, + { 999, "testString" }, + { 42, "iMaGiNe" } + }, + Delegate = (x, y) => x * y, + TestEnum = new[]{4,8,9,3,2}, + Exception = new ArgumentException("Test Exception", new IndexOutOfRangeException("-999")), + ImmutableList = new [] {9, 4, 6, 2, 5}.ToImmutableList(), + ImmutableDictionary = new Dictionary + { + { 666, "b" }, + { 999, "testString" }, + { 42, "iMaGiNe" } + }.ToImmutableDictionary(), + }; + var serializer = new Serializer(new SerializerOptions(knownTypes: new[] + { + typeof(object[]), + typeof(int[]), + typeof(int[,]), + typeof(Dictionary), + typeof(DictionaryEntry), + typeof(KeyValuePair), + typeof(Temp), + typeof(TestDelegate), + typeof(Enumerable), + typeof(IEnumerable), + typeof(Exception), + typeof(ArgumentException), + typeof(IndexOutOfRangeException), + typeof(FieldInfo), + typeof(ImmutableList), + typeof(ImmutableList), + typeof(ImmutableDictionary), + typeof(MethodInfo), + typeof(PropertyInfo), + })); serializer.Serialize(msg, stream); stream.Position = 0; var a = stream.ToArray(); - var text = string.Join("", a.Select(x => ((char)x).ToString())); - var res = serializer.Deserialize(stream); + var text = string.Join("", a.Select(x => x < 32 || x > 126 ? "" : ((char)x).ToString())); + _output.WriteLine(text); + var res = (Temp)serializer.Deserialize(stream); Assert.DoesNotContain("System.Collections.Generic.Dictionary", text); + Assert.Equal(msg, res); } } } From 110f91ffe94623e06cc42a130c81527d46bdace6 Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Thu, 29 Oct 2020 13:44:39 +0700 Subject: [PATCH 08/18] Remove modifications that could not be reached/touched by the unit test --- .../ConstructorInfoSerializerFactory.cs | 8 +------- .../SerializerFactories/DictionarySerializerFactory.cs | 8 +------- .../SerializerFactories/EnumerableSerializerFactory.cs | 8 +------- .../SerializerFactories/ExpandoObjectSerializerFactory.cs | 8 +------- .../SerializerFactories/FSharpListSerializerFactory.cs | 8 +------- .../SerializerFactories/FSharpMapSerializerFactory.cs | 8 +------- .../SerializerFactories/FieldInfoSerializerFactory.cs | 8 +------- .../SerializerFactories/MethodInfoSerializerFactory.cs | 8 +------- .../SerializerFactories/PropertyInfoSerializerFactory.cs | 8 +------- 9 files changed, 9 insertions(+), 63 deletions(-) diff --git a/src/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs b/src/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs index 6cf7f5e3..877bc950 100644 --- a/src/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs @@ -32,13 +32,7 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var os = new ObjectSerializer(type); - if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) - { - var wrapper = new KnownTypeObjectSerializer(os, index); - typeMapping.TryAdd(type, wrapper); - } - else - typeMapping.TryAdd(type, os); + typeMapping.TryAdd(type, os); ObjectReader reader = (stream, session) => { var owner = stream.ReadObject(session) as Type; diff --git a/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs b/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs index 4c6fdbec..113317b5 100644 --- a/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs @@ -39,13 +39,7 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type { var preserveObjectReferences = serializer.Options.PreserveObjectReferences; var ser = new ObjectSerializer(type); - if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) - { - var wrapper = new KnownTypeObjectSerializer(ser, index); - typeMapping.TryAdd(type, wrapper); - } - else - typeMapping.TryAdd(type, ser); + typeMapping.TryAdd(type, ser); var dictionaryTypes = GetKeyValuePairType(type); var elementSerializer = serializer.GetSerializerByType(dictionaryTypes.KeyValuePairType); diff --git a/src/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs b/src/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs index 854d40e2..ebadbf2b 100644 --- a/src/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs @@ -136,13 +136,7 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var x = new ObjectSerializer(type); - if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) - { - var wrapper = new KnownTypeObjectSerializer(x, index); - typeMapping.TryAdd(type, wrapper); - } - else - typeMapping.TryAdd(type, x); + typeMapping.TryAdd(type, x); var preserveObjectReferences = serializer.Options.PreserveObjectReferences; diff --git a/src/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs b/src/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs index 48ba56af..b04775a0 100644 --- a/src/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs @@ -29,13 +29,7 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type { var preserveObjectReferences = serializer.Options.PreserveObjectReferences; var ser = new ObjectSerializer(type); - if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) - { - var wrapper = new KnownTypeObjectSerializer(ser, index); - typeMapping.TryAdd(type, wrapper); - } - else - typeMapping.TryAdd(type, ser); + typeMapping.TryAdd(type, ser); var elementSerializer = serializer.GetSerializerByType(typeof(DictionaryEntry)); ObjectReader reader = (stream, session) => diff --git a/src/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs b/src/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs index 4716d355..abcfd41f 100644 --- a/src/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs @@ -48,13 +48,7 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var x = new ObjectSerializer(type); - if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) - { - var wrapper = new KnownTypeObjectSerializer(x, index); - typeMapping.TryAdd(type, wrapper); - } - else - typeMapping.TryAdd(type, x); + typeMapping.TryAdd(type, x); var elementType = GetEnumerableType(type); var arrType = elementType.MakeArrayType(); diff --git a/src/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs b/src/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs index 5d2738e0..55db6c2d 100644 --- a/src/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs @@ -64,13 +64,7 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var x = new ObjectSerializer(type); - if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) - { - var wrapper = new KnownTypeObjectSerializer(x, index); - typeMapping.TryAdd(type, wrapper); - } - else - typeMapping.TryAdd(type, x); + typeMapping.TryAdd(type, x); var keyType = GetKeyType(type); var valueType = GetValyeType(type); diff --git a/src/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs b/src/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs index adf5e1d3..84685233 100644 --- a/src/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs @@ -31,13 +31,7 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var os = new ObjectSerializer(type); - if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) - { - var wrapper = new KnownTypeObjectSerializer(os, index); - typeMapping.TryAdd(type, wrapper); - } - else - typeMapping.TryAdd(type, os); + typeMapping.TryAdd(type, os); ObjectReader reader = (stream, session) => { var name = stream.ReadString(session); diff --git a/src/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs b/src/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs index 7444cf8d..44b63e41 100644 --- a/src/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs @@ -32,13 +32,7 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var os = new ObjectSerializer(type); - if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) - { - var wrapper = new KnownTypeObjectSerializer(os, index); - typeMapping.TryAdd(type, wrapper); - } - else - typeMapping.TryAdd(type, os); + typeMapping.TryAdd(type, os); ObjectReader reader = (stream, session) => { var name = stream.ReadString(session); diff --git a/src/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs b/src/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs index 45d47ad8..c9359518 100644 --- a/src/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs @@ -31,13 +31,7 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type ConcurrentDictionary typeMapping) { var os = new ObjectSerializer(type); - if (serializer.Options.KnownTypesDict.TryGetValue(type, out var index)) - { - var wrapper = new KnownTypeObjectSerializer(os, index); - typeMapping.TryAdd(type, wrapper); - } - else - typeMapping.TryAdd(type, os); + typeMapping.TryAdd(type, os); ObjectReader reader = (stream, session) => { var name = stream.ReadString(session); From e31c339208e3a4baf48944264d37f5bdb17656cb Mon Sep 17 00:00:00 2001 From: Ralf Date: Thu, 29 Oct 2020 15:51:00 +0100 Subject: [PATCH 09/18] throw EndOfStreamException if stream doesn't return enough bytes --- src/Hyperion.Tests/IncompleteStreamTests.cs | 84 +++++++++++++++++++ ...ialStreamTest.cs => PartialStreamTests.cs} | 6 +- src/Hyperion/Extensions/StreamEx.cs | 8 +- 3 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 src/Hyperion.Tests/IncompleteStreamTests.cs rename src/Hyperion.Tests/{PartialStreamTest.cs => PartialStreamTests.cs} (94%) diff --git a/src/Hyperion.Tests/IncompleteStreamTests.cs b/src/Hyperion.Tests/IncompleteStreamTests.cs new file mode 100644 index 00000000..0b2f8183 --- /dev/null +++ b/src/Hyperion.Tests/IncompleteStreamTests.cs @@ -0,0 +1,84 @@ +using System.IO; +using Xunit; + +namespace Hyperion.Tests +{ + public class IncompleteStreamTests : TestBase + { + private const int IncompleteBytes = 4; + + public IncompleteStreamTests() + : base(x => new IncompleteReadStream(x, IncompleteBytes)) + { + } + + [Fact] + public void ThrowsOnEOF() + { + double data = 4; //double has 8 bytes + Serialize(data); + Reset(); + + // manifest requires 1 byte + // incomplete returned bytes are then (IncompleteBytes)4 - 1 = 3 => EOF + Assert.Throws(() => Deserialize()); + } + + private class IncompleteReadStream : Stream + { + private readonly Stream _baseStream; + private readonly int _maxReadBytes; + + private int _totalReadBytes; + + public IncompleteReadStream(Stream baseStream, int maxReadBytes) + { + _baseStream = baseStream; + _maxReadBytes = maxReadBytes; + } + + public override void Flush() + { + _baseStream.Flush(); + } + + public override long Seek(long offset, SeekOrigin origin) + { + return _baseStream.Seek(offset, origin); + } + + public override void SetLength(long value) + { + _baseStream.SetLength(value); + } + + public override int Read(byte[] buffer, int offset, int count) + { + var allBytes = _totalReadBytes + count; + var bytesToRead = allBytes > _maxReadBytes + ? _maxReadBytes - _totalReadBytes + : count; + + var readBytes = _baseStream.Read(buffer, offset, bytesToRead); + _totalReadBytes += readBytes; + return readBytes; + } + + public override void Write(byte[] buffer, int offset, int count) + { + _baseStream.Write(buffer, offset, count); + } + + public override bool CanRead => _baseStream.CanRead; + public override bool CanSeek => _baseStream.CanSeek; + public override bool CanWrite => _baseStream.CanWrite; + public override long Length => _baseStream.Length; + + public override long Position + { + get => _baseStream.Position; + set => _baseStream.Position = value; + } + } + } +} \ No newline at end of file diff --git a/src/Hyperion.Tests/PartialStreamTest.cs b/src/Hyperion.Tests/PartialStreamTests.cs similarity index 94% rename from src/Hyperion.Tests/PartialStreamTest.cs rename to src/Hyperion.Tests/PartialStreamTests.cs index a4ed6b09..1569514d 100644 --- a/src/Hyperion.Tests/PartialStreamTest.cs +++ b/src/Hyperion.Tests/PartialStreamTests.cs @@ -2,13 +2,13 @@ namespace Hyperion.Tests { - public class PartialStreamTest : PrimitivesTest + public class PartialStreamTests : PrimitivesTest { - public PartialStreamTest() + public PartialStreamTests() : base(x => new OneBytePerReadStream(x)) { } - + private class OneBytePerReadStream : Stream { private readonly Stream _baseStream; diff --git a/src/Hyperion/Extensions/StreamEx.cs b/src/Hyperion/Extensions/StreamEx.cs index a2800542..4269930a 100644 --- a/src/Hyperion/Extensions/StreamEx.cs +++ b/src/Hyperion/Extensions/StreamEx.cs @@ -188,8 +188,8 @@ public static string ReadString(this Stream stream, DeserializerSession session) } var buffer = session.GetBuffer(length); - stream.ReadFull(buffer, 0, length); + var res = StringEx.FromUtf8Bytes(buffer, 0, length); return res; } @@ -213,12 +213,16 @@ public static int ReadFull(this Stream stream, byte[] buffer, int offset, int co { var readBytes = stream.Read(buffer, offset + totalReadBytes, count - totalReadBytes); if (readBytes == 0) - break; + break; // EOF totalReadBytes += readBytes; } while (totalReadBytes < count); + // received enough bytes? + if (totalReadBytes != count) + throw new EndOfStreamException("Stream didn't returned sufficient bytes"); + return totalReadBytes; } } From 6127ffad83e692e0d5d87f406e5c557a2c9e183a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 4 Jan 2021 21:51:40 +0000 Subject: [PATCH 10/18] Bump Microsoft.NET.Test.Sdk from 16.7.1 to 16.8.3 (#196) --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index c52dabb8..6ecd14de 100644 --- a/src/common.props +++ b/src/common.props @@ -16,7 +16,7 @@ 2.4.1 2.4.3 - 16.7.1 + 16.8.3 1.2.2 \ No newline at end of file From 3d9e766132b840e7a630b5e0463dfa9fee1e9deb Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 6 Jan 2021 16:32:10 +0000 Subject: [PATCH 11/18] Bump System.Collections.Immutable from 1.7.1 to 5.0.0 (#195) --- src/Hyperion.Tests/Hyperion.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hyperion.Tests/Hyperion.Tests.csproj b/src/Hyperion.Tests/Hyperion.Tests.csproj index 67fac9e7..dbf0c2ba 100644 --- a/src/Hyperion.Tests/Hyperion.Tests.csproj +++ b/src/Hyperion.Tests/Hyperion.Tests.csproj @@ -12,7 +12,7 @@ - + From 03872471d0c850c0a4facf6cfb6bf91ddc7eae4b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 17 Mar 2021 19:54:42 +0000 Subject: [PATCH 12/18] Bump FSharp.Core from 5.0.0 to 5.0.1 (#202) --- src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj b/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj index 80af7cad..ade9902c 100644 --- a/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj +++ b/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj @@ -9,7 +9,7 @@ - + From ada41986eaeaf731eb31592d17dfd68efa25faf5 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 17 Mar 2021 19:59:37 +0000 Subject: [PATCH 13/18] Bump Microsoft.NET.Test.Sdk from 16.8.3 to 16.9.1 (#203) --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index 6ecd14de..5e5fa18e 100644 --- a/src/common.props +++ b/src/common.props @@ -16,7 +16,7 @@ 2.4.1 2.4.3 - 16.8.3 + 16.9.1 1.2.2 \ No newline at end of file From 4605dd3388f5c7ba39fb8163a23c6acb7df460cd Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Thu, 25 Mar 2021 01:22:07 +0700 Subject: [PATCH 14/18] Update the cross framework spec to include complex POCO object, Type serialization, and support for netcoreapp3.1 and net5.0 --- .../CrossFrameworkSerializationTests.cs | 31 +++++++++++-- .../Generator/CrossFrameworkClass.cs | 43 ++++++++++++++++++ .../Generator/CrossFrameworkInitializer.cs | 11 +++++ src/Hyperion.Tests/Generator/Program.cs | 9 +++- src/Hyperion.Tests/Hyperion.Tests.csproj | 2 +- .../mixed_test_file_.netcoreappversionv2.0.tf | Bin 0 -> 743 bytes .../mixed_test_file_.netcoreappversionv2.1.tf | Bin 0 -> 743 bytes .../mixed_test_file_.netcoreappversionv2.2.tf | Bin 0 -> 743 bytes .../mixed_test_file_.netcoreappversionv3.0.tf | Bin 0 -> 743 bytes .../mixed_test_file_.netcoreappversionv3.1.tf | Bin 0 -> 743 bytes .../mixed_test_file_.netcoreappversionv5.0.tf | Bin 0 -> 743 bytes ...ed_test_file_.netframeworkversionv4.6.1.tf | Bin 0 -> 715 bytes .../test_file_.netcoreappversionv3.1.tf | Bin 0 -> 599 bytes .../test_file_.netcoreappversionv5.0.tf | Bin 0 -> 599 bytes 14 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv2.0.tf create mode 100644 src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv2.1.tf create mode 100644 src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv2.2.tf create mode 100644 src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv3.0.tf create mode 100644 src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv3.1.tf create mode 100644 src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv5.0.tf create mode 100644 src/Hyperion.Tests/testfiles/mixed_test_file_.netframeworkversionv4.6.1.tf create mode 100644 src/Hyperion.Tests/testfiles/test_file_.netcoreappversionv3.1.tf create mode 100644 src/Hyperion.Tests/testfiles/test_file_.netcoreappversionv5.0.tf diff --git a/src/Hyperion.Tests/CrossFrameworkSerializationTests.cs b/src/Hyperion.Tests/CrossFrameworkSerializationTests.cs index 69ba00fd..32e9d203 100644 --- a/src/Hyperion.Tests/CrossFrameworkSerializationTests.cs +++ b/src/Hyperion.Tests/CrossFrameworkSerializationTests.cs @@ -2,26 +2,39 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using FluentAssertions; using Hyperion.Tests.Generator; using Xunit; +using Xunit.Abstractions; namespace Hyperion.Tests { public class CrossFrameworkSerializationTests { + private readonly ITestOutputHelper _log; private readonly Serializer _serializer; private readonly CrossFrameworkClass _originalObject; + private readonly CrossFrameworkMixedClass _originalMixedObject; - public CrossFrameworkSerializationTests() + public CrossFrameworkSerializationTests(ITestOutputHelper log) { + _log = log; _serializer = new Serializer(); _originalObject = CrossFrameworkInitializer.Init(); + _originalMixedObject = CrossFrameworkInitializer.InitMixed(); } public static IEnumerable SerializationFiles() { const string defaultOutputPath = CrossFrameworkInitializer.DefaultOutputPath; - var testFiles = Directory.GetFiles(defaultOutputPath, "*.tf"); + var testFiles = Directory.GetFiles(defaultOutputPath, "test_file_.*.tf"); + return testFiles.Select(x => new object[] { x }); + } + + public static IEnumerable MixedSerializationFiles() + { + const string defaultOutputPath = CrossFrameworkInitializer.DefaultOutputPath; + var testFiles = Directory.GetFiles(defaultOutputPath, "mixed_test_file_.*.tf"); return testFiles.Select(x => new object[] { x }); } @@ -32,8 +45,20 @@ public void CanSerializeCrossFramework(string fileName) using (var fileStream = new FileStream(fileName, FileMode.Open)) { var crossFrameworkClass = _serializer.Deserialize(fileStream); + _originalObject.Should() + .Be(crossFrameworkClass, $"[CrossFrameworkClass] {fileName} deserialization should work."); + } + } - Assert.Equal(_originalObject, crossFrameworkClass); + [Theory] + [MemberData(nameof(MixedSerializationFiles))] + public void CanSerializeComplexObjectCrossFramework(string fileName) + { + using (var fileStream = new FileStream(fileName, FileMode.Open)) + { + var deserialized = _serializer.Deserialize(fileStream); + _originalMixedObject.Should() + .Be(deserialized, $"[CrossFrameworkMixedClass] {fileName} deserialization should work."); } } } diff --git a/src/Hyperion.Tests/Generator/CrossFrameworkClass.cs b/src/Hyperion.Tests/Generator/CrossFrameworkClass.cs index 081021c0..41e16cda 100644 --- a/src/Hyperion.Tests/Generator/CrossFrameworkClass.cs +++ b/src/Hyperion.Tests/Generator/CrossFrameworkClass.cs @@ -122,4 +122,47 @@ private bool Equals(CrossFrameworkClass other) && Struct.Equals(other.Struct); } } + + public interface ICrossFrameworkA + { + string Name { get; set; } + } + + public interface ICrossFrameworkB : ICrossFrameworkA + { + string Sound { get; set; } + } + + public class CrossFrameworkBase : ICrossFrameworkB + { + public string Name { get; set; } + public string Sound { get; set; } + } + + public class CrossFrameworkMixedClass : CrossFrameworkBase + { + public Type FriendType { get; set; } + public CrossFrameworkClass Data { get; set; } + + public override bool Equals(object obj) + { + if (!(obj is CrossFrameworkMixedClass other)) + return false; + return other.Equals(this); + } + + protected bool Equals(CrossFrameworkMixedClass other) + { + if (other.Sound != Sound || other.Name != Name) + return false; + return other.Data.Equals(Data); + } + + public override int GetHashCode() + { + int hash = Name.GetHashCode(); + hash = (hash * 397) ^ Sound.GetHashCode(); + return (Data != null ? (hash * 397) ^ Data.GetHashCode() : hash); + } + } } \ No newline at end of file diff --git a/src/Hyperion.Tests/Generator/CrossFrameworkInitializer.cs b/src/Hyperion.Tests/Generator/CrossFrameworkInitializer.cs index dae3431f..b263e7c4 100644 --- a/src/Hyperion.Tests/Generator/CrossFrameworkInitializer.cs +++ b/src/Hyperion.Tests/Generator/CrossFrameworkInitializer.cs @@ -6,6 +6,17 @@ public static class CrossFrameworkInitializer { public const string DefaultOutputPath = "../../../testfiles"; + public static CrossFrameworkMixedClass InitMixed() + { + return new CrossFrameworkMixedClass + { + Name = "Cookie", + Sound = "Bark", + FriendType = typeof(CrossFrameworkClass), + Data = Init() + }; + } + public static CrossFrameworkClass Init() { return new CrossFrameworkClass() diff --git a/src/Hyperion.Tests/Generator/Program.cs b/src/Hyperion.Tests/Generator/Program.cs index c0ae7045..69f597fa 100644 --- a/src/Hyperion.Tests/Generator/Program.cs +++ b/src/Hyperion.Tests/Generator/Program.cs @@ -30,14 +30,21 @@ private static void Main(string[] args) } CrossFrameworkClass crossFrameworkClass = CrossFrameworkInitializer.Init(); + var crossFrameworkMixedClass = CrossFrameworkInitializer.InitMixed(); string fileName = $"test_file_{FrameworkName.ToLowerInvariant()}.tf"; string fullPath = Path.Combine(outputPath, fileName); - using (var fileStream = new FileStream(fullPath, FileMode.Create)) { Serializer.Serialize(crossFrameworkClass, fileStream); } + + fileName = $"mixed_test_file_{FrameworkName.ToLowerInvariant()}.tf"; + fullPath = Path.Combine(outputPath, fileName); + using (var fileStream = new FileStream(fullPath, FileMode.Create)) + { + Serializer.Serialize(crossFrameworkMixedClass, fileStream); + } } } } \ No newline at end of file diff --git a/src/Hyperion.Tests/Hyperion.Tests.csproj b/src/Hyperion.Tests/Hyperion.Tests.csproj index dbf0c2ba..3686b3a8 100644 --- a/src/Hyperion.Tests/Hyperion.Tests.csproj +++ b/src/Hyperion.Tests/Hyperion.Tests.csproj @@ -3,7 +3,7 @@ Exe - net461;netcoreapp3.0 + net461;netcoreapp3.1;net5.0 true latest Hyperion.Tests.Generator.Program diff --git a/src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv2.0.tf b/src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv2.0.tf new file mode 100644 index 0000000000000000000000000000000000000000..4cc8d17f28d6e6a8e7e50972dda690e849c7641b GIT binary patch literal 743 zcma)4%}xR_5MB;MFGe3>F5H%NNsz=S2i$*Ah=r2P;(`tM>N(%mncy)t8|oTWlT@A44;&q-tq+w6TyrL zVY9@Y?~d{(K*c#1te#)r-e2|u%72V-gNk=#?u^{##s6~c$~@aJd|x0#W7rr=9%V&GkMj(ry~~Bz8SgM*QYs4r z1W9$CmMaPhEBd^x3RleUC0yqcp%p^owAlvqwSdBKFfEvLB*_?}IeWbMIBVXFnDCsO!%vixCx;9>Rxg;IegfTMAI1Ox literal 0 HcmV?d00001 diff --git a/src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv2.1.tf b/src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv2.1.tf new file mode 100644 index 0000000000000000000000000000000000000000..4cc8d17f28d6e6a8e7e50972dda690e849c7641b GIT binary patch literal 743 zcma)4%}xR_5MB;MFGe3>F5H%NNsz=S2i$*Ah=r2P;(`tM>N(%mncy)t8|oTWlT@A44;&q-tq+w6TyrL zVY9@Y?~d{(K*c#1te#)r-e2|u%72V-gNk=#?u^{##s6~c$~@aJd|x0#W7rr=9%V&GkMj(ry~~Bz8SgM*QYs4r z1W9$CmMaPhEBd^x3RleUC0yqcp%p^owAlvqwSdBKFfEvLB*_?}IeWbMIBVXFnDCsO!%vixCx;9>Rxg;IegfTMAI1Ox literal 0 HcmV?d00001 diff --git a/src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv2.2.tf b/src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv2.2.tf new file mode 100644 index 0000000000000000000000000000000000000000..4cc8d17f28d6e6a8e7e50972dda690e849c7641b GIT binary patch literal 743 zcma)4%}xR_5MB;MFGe3>F5H%NNsz=S2i$*Ah=r2P;(`tM>N(%mncy)t8|oTWlT@A44;&q-tq+w6TyrL zVY9@Y?~d{(K*c#1te#)r-e2|u%72V-gNk=#?u^{##s6~c$~@aJd|x0#W7rr=9%V&GkMj(ry~~Bz8SgM*QYs4r z1W9$CmMaPhEBd^x3RleUC0yqcp%p^owAlvqwSdBKFfEvLB*_?}IeWbMIBVXFnDCsO!%vixCx;9>Rxg;IegfTMAI1Ox literal 0 HcmV?d00001 diff --git a/src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv3.0.tf b/src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv3.0.tf new file mode 100644 index 0000000000000000000000000000000000000000..4cc8d17f28d6e6a8e7e50972dda690e849c7641b GIT binary patch literal 743 zcma)4%}xR_5MB;MFGe3>F5H%NNsz=S2i$*Ah=r2P;(`tM>N(%mncy)t8|oTWlT@A44;&q-tq+w6TyrL zVY9@Y?~d{(K*c#1te#)r-e2|u%72V-gNk=#?u^{##s6~c$~@aJd|x0#W7rr=9%V&GkMj(ry~~Bz8SgM*QYs4r z1W9$CmMaPhEBd^x3RleUC0yqcp%p^owAlvqwSdBKFfEvLB*_?}IeWbMIBVXFnDCsO!%vixCx;9>Rxg;IegfTMAI1Ox literal 0 HcmV?d00001 diff --git a/src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv3.1.tf b/src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv3.1.tf new file mode 100644 index 0000000000000000000000000000000000000000..4cc8d17f28d6e6a8e7e50972dda690e849c7641b GIT binary patch literal 743 zcma)4%}xR_5MB;MFGe3>F5H%NNsz=S2i$*Ah=r2P;(`tM>N(%mncy)t8|oTWlT@A44;&q-tq+w6TyrL zVY9@Y?~d{(K*c#1te#)r-e2|u%72V-gNk=#?u^{##s6~c$~@aJd|x0#W7rr=9%V&GkMj(ry~~Bz8SgM*QYs4r z1W9$CmMaPhEBd^x3RleUC0yqcp%p^owAlvqwSdBKFfEvLB*_?}IeWbMIBVXFnDCsO!%vixCx;9>Rxg;IegfTMAI1Ox literal 0 HcmV?d00001 diff --git a/src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv5.0.tf b/src/Hyperion.Tests/testfiles/mixed_test_file_.netcoreappversionv5.0.tf new file mode 100644 index 0000000000000000000000000000000000000000..4cc8d17f28d6e6a8e7e50972dda690e849c7641b GIT binary patch literal 743 zcma)4%}xR_5MB;MFGe3>F5H%NNsz=S2i$*Ah=r2P;(`tM>N(%mncy)t8|oTWlT@A44;&q-tq+w6TyrL zVY9@Y?~d{(K*c#1te#)r-e2|u%72V-gNk=#?u^{##s6~c$~@aJd|x0#W7rr=9%V&GkMj(ry~~Bz8SgM*QYs4r z1W9$CmMaPhEBd^x3RleUC0yqcp%p^owAlvqwSdBKFfEvLB*_?}IeWbMIBVXFnDCsO!%vixCx;9>Rxg;IegfTMAI1Ox literal 0 HcmV?d00001 diff --git a/src/Hyperion.Tests/testfiles/mixed_test_file_.netframeworkversionv4.6.1.tf b/src/Hyperion.Tests/testfiles/mixed_test_file_.netframeworkversionv4.6.1.tf new file mode 100644 index 0000000000000000000000000000000000000000..8de4aed34223ccca678f6c4e3f36cb693ef0b862 GIT binary patch literal 715 zcma)4%}xR_5MB;MFGe3>JaAh!OM)auIp78~Ch7rSpe(b{&}~WEMMzARc-N=%J$!^Z z#UBDe!z7)rO*`MrH&fRMg5YK`Ma`9r9?@76U86+JtkO}Ul`%cda(q&Ha>wU5OawC~ zgv}6lxj)NJf{Jr4SU$hLy}uj=wEs2Y4JzJ|xeIceiT|v%D~o))%Btr$CD&gVi+R+Y zr#Q8wJA~Y%N((*+YlK(}j(jH|M`PFsDXPAX>gZ9CqqO&h5dSb7CrnCZVSpg%rBCh3 zl3+>8+p=`!>_Nh9ArV?3G|rn%DumL59Wx1yRvgB03>_gj4#8@rrUnF)Lpm{`? zlgwDWm7}0wXBUIWfh0jyj`fr)7bf?n? zlgwDWm7}0wXBUIWfh0jyj`fr)7bf?n Date: Thu, 25 Mar 2021 01:34:19 +0700 Subject: [PATCH 15/18] Update build system to support .NET 3.1 and 5.0 --- build-system/azure-pipeline.template.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build-system/azure-pipeline.template.yaml b/build-system/azure-pipeline.template.yaml index feba5487..38166d80 100644 --- a/build-system/azure-pipeline.template.yaml +++ b/build-system/azure-pipeline.template.yaml @@ -16,6 +16,15 @@ jobs: clean: false # whether to fetch clean each time submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules persistCredentials: true + - task: UseDotNet@2 + displayName: 'Use .NET 5 SDK 5.0.101' + inputs: + version: 5.0.101 + - task: UseDotNet@2 + displayName: 'Use .NET Core Runtime 3.1.10' + inputs: + packageType: runtime + version: 3.1.10 # Linux or macOS - task: Bash@3 displayName: Linux / OSX Build From 6b9543d79cad6153e58c3b31cf0113df8013bebf Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Thu, 25 Mar 2021 01:48:57 +0700 Subject: [PATCH 16/18] Add FriendType comparison in Equal() --- src/Hyperion.Tests/Generator/CrossFrameworkClass.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hyperion.Tests/Generator/CrossFrameworkClass.cs b/src/Hyperion.Tests/Generator/CrossFrameworkClass.cs index 41e16cda..17d3966b 100644 --- a/src/Hyperion.Tests/Generator/CrossFrameworkClass.cs +++ b/src/Hyperion.Tests/Generator/CrossFrameworkClass.cs @@ -153,7 +153,7 @@ public override bool Equals(object obj) protected bool Equals(CrossFrameworkMixedClass other) { - if (other.Sound != Sound || other.Name != Name) + if (other.Sound != Sound || other.Name != Name || other.FriendType != FriendType) return false; return other.Data.Equals(Data); } From 4bc1c7a3134e23b1527f33e6c75a1102c21151a1 Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Thu, 25 Mar 2021 02:49:14 +0700 Subject: [PATCH 17/18] update build system --- build.fsx | 171 +++++++++++++++++++++++++++++++++++++++--------------- build.ps1 | 56 ++---------------- build.sh | 17 ------ 3 files changed, 128 insertions(+), 116 deletions(-) diff --git a/build.fsx b/build.fsx index 33ba702c..c3e5b00d 100644 --- a/build.fsx +++ b/build.fsx @@ -8,6 +8,7 @@ open System.Text open Fake open Fake.DotNetCli open Fake.DocFxHelper +open Fake.NuGet.Install // Information about the project for Nuget and Assembly info files let product = "Hyperion" @@ -18,27 +19,42 @@ let signingName = "Hyperion" let signingDescription = "A high performance polymorphic serializer for the .NET framework" let signingUrl = "" +// Directories +let toolsDir = __SOURCE_DIRECTORY__ @@ "tools" +let output = __SOURCE_DIRECTORY__ @@ "bin" +let outputTests = __SOURCE_DIRECTORY__ @@ "TestResults" +let outputPerfTests = __SOURCE_DIRECTORY__ @@ "PerfResults" +let outputBinaries = output @@ "binaries" +let outputBinariesNet461 = outputBinaries @@ "net461" +let outputBinariesNetStandard = outputBinaries @@ "netstandard2.0" +let outputBinariesNet = outputBinaries @@ "net5.0" +let outputNuGet = output @@ "nuget" // Read release notes and version let solutionFile = FindFirstMatchingFile "*.sln" __SOURCE_DIRECTORY__ // dynamically look up the solution let buildNumber = environVarOrDefault "BUILD_NUMBER" "0" let hasTeamCity = (not (buildNumber = "0")) // check if we have the TeamCity environment variable for build # set let preReleaseVersionSuffix = "beta" + (if (not (buildNumber = "0")) then (buildNumber) else DateTime.UtcNow.Ticks.ToString()) -let versionSuffix = - match (getBuildParam "nugetprerelease") with - | "dev" -> preReleaseVersionSuffix - | _ -> "" let releaseNotes = - File.ReadLines "./RELEASE_NOTES.md" + File.ReadLines (__SOURCE_DIRECTORY__ @@ "RELEASE_NOTES.md") |> ReleaseNotesHelper.parseReleaseNotes -// Directories -let toolsDir = __SOURCE_DIRECTORY__ @@ "tools" -let output = __SOURCE_DIRECTORY__ @@ "bin" -let outputTests = __SOURCE_DIRECTORY__ @@ "TestResults" -let outputPerfTests = __SOURCE_DIRECTORY__ @@ "PerfResults" -let outputNuGet = output @@ "nuget" +let versionFromReleaseNotes = + match releaseNotes.SemVer.PreRelease with + | Some r -> r.Origin + | None -> "" + +let versionSuffix = + match (getBuildParam "nugetprerelease") with + | "dev" -> preReleaseVersionSuffix + | "" -> versionFromReleaseNotes + | str -> str + +// Configuration values for tests +let testNetFrameworkVersion = "net461" +let testNetCoreVersion = "netcoreapp3.1" +let testNetVersion = "net5.0" Target "Clean" (fun _ -> ActivateFinalTarget "KillCreatedProcesses" @@ -46,8 +62,15 @@ Target "Clean" (fun _ -> CleanDir output CleanDir outputTests CleanDir outputPerfTests + CleanDir outputBinaries CleanDir outputNuGet + CleanDir outputBinariesNet461 + CleanDir outputBinariesNetStandard + CleanDir outputBinariesNet CleanDir "docs/_site" + + CleanDirs !! "./**/bin" + CleanDirs !! "./**/obj" ) Target "AssemblyInfo" (fun _ -> @@ -56,17 +79,20 @@ Target "AssemblyInfo" (fun _ -> ) Target "Build" (fun _ -> + let additionalArgs = if versionSuffix.Length > 0 then [sprintf "/p:VersionSuffix=%s" versionSuffix] else [] DotNetCli.Build (fun p -> { p with Project = solutionFile - Configuration = configuration }) // "Rebuild" + Configuration = configuration + AdditionalArgs = additionalArgs }) // "Rebuild" ) //-------------------------------------------------------------------------------- // Tests targets //-------------------------------------------------------------------------------- + module internal ResultHandling = let (|OK|Failure|) = function | 0 -> OK @@ -94,8 +120,32 @@ Target "RunTests" (fun _ -> let runSingleProject project = let arguments = match (hasTeamCity) with - | true -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --results-directory %s -- -parallel none -teamcity" (outputTests)) - | false -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --results-directory %s -- -parallel none" (outputTests)) + | true -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none -teamcity" testNetFrameworkVersion outputTests) + | false -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none" testNetFrameworkVersion outputTests) + + let result = ExecProcess(fun info -> + info.FileName <- "dotnet" + info.WorkingDirectory <- (Directory.GetParent project).FullName + info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0) + + ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result + + CreateDir outputTests + projects |> Seq.iter (log) + projects |> Seq.iter (runSingleProject) +) + +Target "RunTestsNetCore" (fun _ -> + let projects = + match (isWindows) with + | true -> !! "./src/**/*.Tests.csproj" + | _ -> !! "./src/**/*.Tests.csproj" // if you need to filter specs for Linux vs. Windows, do it here + + let runSingleProject project = + let arguments = + match (hasTeamCity) with + | true -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none -teamcity" testNetCoreVersion outputTests) + | false -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none" testNetCoreVersion outputTests) let result = ExecProcess(fun info -> info.FileName <- "dotnet" @@ -104,44 +154,64 @@ Target "RunTests" (fun _ -> ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result + CreateDir outputTests + projects |> Seq.iter (log) + projects |> Seq.iter (runSingleProject) +) + +Target "RunTestsNet" (fun _ -> + let projects = + match (isWindows) with + | true -> !! "./src/**/*.Tests.csproj" + | _ -> !! "./src/**/*.Tests.csproj" // if you need to filter specs for Linux vs. Windows, do it here + + let runSingleProject project = + let arguments = + match (hasTeamCity) with + | true -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none -teamcity" testNetVersion outputTests) + | false -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none" testNetVersion outputTests) + + let result = ExecProcess(fun info -> + info.FileName <- "dotnet" + info.WorkingDirectory <- (Directory.GetParent project).FullName + info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0) + + ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result + + CreateDir outputTests projects |> Seq.iter (log) projects |> Seq.iter (runSingleProject) ) Target "NBench" <| fun _ -> - let nbenchTestPath = findToolInSubPath "NBench.Runner.exe" (toolsDir @@ "NBench.Runner*") - printfn "Using NBench.Runner: %s" nbenchTestPath - - let nbenchTestAssemblies = !! "./src/**/bin/**/*Tests.Performance.dll" // doesn't support .NET Core at the moment - - let runNBench assembly = - let includes = getBuildParam "include" - let excludes = getBuildParam "exclude" - let teamcityStr = (getBuildParam "teamcity") - let enableTeamCity = - match teamcityStr with - | null -> false - | "" -> false - | _ -> bool.Parse teamcityStr - - let args = StringBuilder() - |> append assembly - |> append (sprintf "output-directory=\"%s\"" outputPerfTests) - |> append (sprintf "concurrent=\"%b\"" true) - |> append (sprintf "trace=\"%b\"" true) - |> append (sprintf "teamcity=\"%b\"" enableTeamCity) - |> appendIfNotNullOrEmpty includes "include=" - |> appendIfNotNullOrEmpty excludes "include=" + ensureDirectory outputPerfTests + let projects = + match (isWindows) with + | true -> !! "./src/**/*Tests.Performance.csproj" + | _ -> !! "./src/**/*Tests.Performance.csproj" // if you need to filter specs for Linux vs. Windows, do it here + + projects |> Seq.iter(fun project -> + let args = new StringBuilder() + |> append "run" + |> append "--no-build" + |> append "-c" + |> append configuration + |> append " -- " + |> append "--output" + |> append outputPerfTests + |> append "--concurrent" + |> append "true" + |> append "--trace" + |> append "true" + |> append "--diagnostic" |> toText - let result = ExecProcess(fun info -> - info.FileName <- nbenchTestPath - info.WorkingDirectory <- (Path.GetDirectoryName (FullName nbenchTestPath)) - info.Arguments <- args) (System.TimeSpan.FromMinutes 45.0) (* Reasonably long-running task. *) - - if result <> 0 then failwithf "NBench.Runner failed. %s %s" nbenchTestPath args - - nbenchTestAssemblies |> Seq.iter runNBench + let result = ExecProcess(fun info -> + info.FileName <- "dotnet" + info.WorkingDirectory <- (Directory.GetParent project).FullName + info.Arguments <- args) (System.TimeSpan.FromMinutes 15.0) (* Reasonably long-running task. *) + if result <> 0 then failwithf "NBench.Runner failed. %s %s" "dotnet" args + ) //-------------------------------------------------------------------------------- @@ -301,23 +371,30 @@ Target "Help" <| fun _ -> Target "BuildRelease" DoNothing Target "All" DoNothing Target "Nuget" DoNothing +Target "RunTestsFull" DoNothing +Target "RunTestsNetCoreFull" DoNothing // build dependencies "Clean" ==> "AssemblyInfo" ==> "Build" ==> "BuildRelease" // tests dependencies "Build" ==> "RunTests" +"Build" ==> "RunTestsNetCore" +"Build" ==> "RunTestsNet" +"Build" ==> "NBench" // nuget dependencies -"Clean" ==> "Build" ==> "CreateNuget" +"BuildRelease" ==> "CreateNuget" "CreateNuget" ==> "SignPackages" ==> "PublishNuget" ==> "Nuget" // docs -"Clean" ==> "BuildRelease" ==> "Docfx" +"BuildRelease" ==> "Docfx" // all "BuildRelease" ==> "All" "RunTests" ==> "All" +"RunTestsNetCore" ==> "All" +"RunTestsNet" ==> "All" "NBench" ==> "All" "Nuget" ==> "All" diff --git a/build.ps1 b/build.ps1 index d2581ca4..953f4cc9 100644 --- a/build.ps1 +++ b/build.ps1 @@ -29,14 +29,11 @@ Param( [string[]]$ScriptArgs ) -$FakeVersion = "4.61.2" -$DotNetChannel = "LTS"; -$DotNetVersion = "3.0.100"; -$DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1"; -$NugetVersion = "4.1.0"; +$FakeVersion = "4.63.2" +$NugetVersion = "5.8.0"; $NugetUrl = "https://dist.nuget.org/win-x86-commandline/v$NugetVersion/nuget.exe" -$ProtobufVersion = "3.2.0" -$DocfxVersion = "2.40.5" +$ProtobufVersion = "3.13.0" +$DocfxVersion = "2.48.1" # Make sure tools folder exists $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent @@ -46,51 +43,6 @@ if (!(Test-Path $ToolPath)) { New-Item -Path $ToolPath -Type directory | out-null } -########################################################################### -# INSTALL .NET CORE CLI -########################################################################### - -Function Remove-PathVariable([string]$VariableToRemove) -{ - $path = [Environment]::GetEnvironmentVariable("PATH", "User") - if ($path -ne $null) - { - $newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove } - [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User") - } - - $path = [Environment]::GetEnvironmentVariable("PATH", "Process") - if ($path -ne $null) - { - $newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove } - [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process") - } -} - -# Get .NET Core CLI path if installed. -$FoundDotNetCliVersion = $null; -if (Get-Command dotnet -ErrorAction SilentlyContinue) { - $FoundDotNetCliVersion = dotnet --version; - $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 - $env:DOTNET_CLI_TELEMETRY_OPTOUT=1 -} - -if($FoundDotNetCliVersion -ne $DotNetVersion) { - $InstallPath = Join-Path $PSScriptRoot ".dotnet" - if (!(Test-Path $InstallPath)) { - mkdir -Force $InstallPath | Out-Null; - } - (New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1"); - & $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath -Architecture x64; - - Remove-PathVariable "$InstallPath" - $env:PATH = "$InstallPath;$env:PATH" - $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 - $env:DOTNET_CLI_TELEMETRY_OPTOUT=1 - $env:DOTNET_ROOT=$InstallPath -} - - ########################################################################### # INSTALL NUGET ########################################################################### diff --git a/build.sh b/build.sh index 230cfe96..05d67196 100644 --- a/build.sh +++ b/build.sh @@ -41,23 +41,6 @@ if [ ! -d "$TOOLS_DIR" ]; then mkdir "$TOOLS_DIR" fi -########################################################################### -# INSTALL .NET CORE CLI -########################################################################### - -echo "Installing .NET CLI..." -if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then - mkdir "$SCRIPT_DIR/.dotnet" -fi -curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" $DOTNET_INSTALLER_URL -bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_VERSION --channel $DOTNET_CHANNEL --install-dir .dotnet --no-path -export PATH="$SCRIPT_DIR/.dotnet":$PATH -export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 -export DOTNET_CLI_TELEMETRY_OPTOUT=1 -chmod -R 0755 ".dotnet" -"$SCRIPT_DIR/.dotnet/dotnet" --info - - ########################################################################### # INSTALL NUGET ########################################################################### From 201035359e7841c3e2445355050b267eefdc07f9 Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Thu, 25 Mar 2021 03:31:48 +0700 Subject: [PATCH 18/18] Update RELEASE_NOTES.md, preparing for 0.9.17 release (#205) --- RELEASE_NOTES.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b0edd6b7..95a29b12 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,10 @@ -### 0.9.16 June 17 2020 #### -* [Bump Microsoft.NET.Test.Sdk from 16.5.0 to 16.6.1](https://github.com/akkadotnet/Hyperion/pull/174) -* [Add deserialization support for ReadOnlyDictionary](https://github.com/akkadotnet/Hyperion/pull/177) -* [Bump FluentAssertions from 5.10.2 to 5.10.3](https://github.com/akkadotnet/Hyperion/pull/171) -* [Bump System.Collections.Immutable from 1.7.0 to 1.7.1](https://github.com/akkadotnet/Hyperion/pull/175) -* [Bump BenchmarkDotNet from 0.12.0 to 0.12.1](https://github.com/akkadotnet/Hyperion/pull/172) +### 0.9.17 March 25 2021 #### +* [Bump Microsoft.NET.Test.Sdk from 16.6.1 to 16.7.1](https://github.com/akkadotnet/Hyperion/pull/182) +* [Fix unit test problem](https://github.com/akkadotnet/Hyperion/pull/191) +* [Bump FSharp.Core from 4.7.2 to 5.0.0](https://github.com/akkadotnet/Hyperion/pull/189) +* [Fix issue #40 regarding partial streams](https://github.com/akkadotnet/Hyperion/pull/185) +* [Fix Hyperion not using known serializers when defined](https://github.com/akkadotnet/Hyperion/pull/184) +* [Bump Microsoft.NET.Test.Sdk from 16.7.1 to 16.8.3](https://github.com/akkadotnet/Hyperion/pull/196) +* [Bump System.Collections.Immutable from 1.7.1 to 5.0.0](https://github.com/akkadotnet/Hyperion/pull/195) +* [Bump FSharp.Core from 5.0.0 to 5.0.1](https://github.com/akkadotnet/Hyperion/pull/202) +* [Update the cross framework spec to include complex POCO object, Type serialization, and support for netcoreapp3.1 and net5.0](https://github.com/akkadotnet/Hyperion/pull/204)