From 9c725c03afbc8288a1c853a8ff3e263a892888b8 Mon Sep 17 00:00:00 2001 From: jkuehner Date: Wed, 28 Oct 2020 22:19:32 +0100 Subject: [PATCH] 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); + } } }