From 26022db3655c42b3c8caf02bde57fec8d8776b47 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Wed, 5 Sep 2018 22:34:57 +0900 Subject: [PATCH 01/36] Add unit tests for conversion from DateTime[Offset] to Timestamp. --- .../TimestampTest.Conversion.cs | 375 ++++++++++++++++++ .../TimestampTest.Conversion.tt | 29 ++ 2 files changed, 404 insertions(+) diff --git a/test/MsgPack.UnitTest/TimestampTest.Conversion.cs b/test/MsgPack.UnitTest/TimestampTest.Conversion.cs index e57acad2f..2dd85b81b 100644 --- a/test/MsgPack.UnitTest/TimestampTest.Conversion.cs +++ b/test/MsgPack.UnitTest/TimestampTest.Conversion.cs @@ -285,6 +285,7 @@ private static void AssertSubseconds( Timestamp target, DateTime expected ) Assert.That( target.Microsecond, Is.EqualTo( ticks / 10 ), "Microsecond" ); Assert.That( target.Nanosecond, Is.EqualTo( ( ticks % 10 ) * 100 ), "Nanosecond" ); } + [Test] public void TestFromDateTimeOffset_UtcNow_OK() { @@ -536,5 +537,379 @@ private static void AssertSubseconds( Timestamp target, DateTimeOffset expected Assert.That( target.Microsecond, Is.EqualTo( ticks / 10 ), "Microsecond" ); Assert.That( target.Nanosecond, Is.EqualTo( ( ticks % 10 ) * 100 ), "Nanosecond" ); } + +#if !NET35 && !SILVERLIGHT && !NETSTANDARD1_1 + + [Test] + public void TestFromDateTime_UnixEpoc_OK() + { + var source = DateTimeOffset.FromUnixTimeMilliseconds( 0 ).DateTime; + var target = Timestamp.FromDateTime( source ); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + } + + [Test] + public void TestFromDateTime_UnixEpocMinus1Millisecond_OK() + { + var source = DateTimeOffset.FromUnixTimeMilliseconds( -1 ).DateTime; + var target = Timestamp.FromDateTime( source ); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + } + + [Test] + public void TestFromDateTime_UnixEpocPlus1Millisecond_OK() + { + var source = DateTimeOffset.FromUnixTimeMilliseconds( 1 ).DateTime; + var target = Timestamp.FromDateTime( source ); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + } + + [Test] + public void TestFromDateTime_UnixEpocMinusSecond_OK() + { + var source = DateTimeOffset.FromUnixTimeSeconds( -1 ).DateTime; + var target = Timestamp.FromDateTime( source ); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + } + + [Test] + public void TestFromDateTime_UnixEpocPlus1Second_OK() + { + var source = DateTimeOffset.FromUnixTimeSeconds( 1 ).DateTime; + var target = Timestamp.FromDateTime( source ); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + } + + [Test] + public void TestToDateTime_UnixEpoc_OK() + { + var source = default( Timestamp ); + var target = source.ToDateTime(); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + AssertUtc( target ); + } + + [Test] + public void TestToDateTime_UnixEpocMinus1Millisecond_OK() + { + var source = default( Timestamp ).Add( TimeSpan.FromMilliseconds( -1 ) ); + var target = source.ToDateTime(); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + AssertUtc( target ); + } + + [Test] + public void TestToDateTime_UnixEpocPlus1Millisecond_OK() + { + var source = default( Timestamp ).Add( TimeSpan.FromMilliseconds( 1 ) ); + var target = source.ToDateTime(); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + AssertUtc( target ); + } + + [Test] + public void TestToDateTime_UnixEpocMinus1Second_OK() + { + var source = default( Timestamp ).Add( TimeSpan.FromSeconds( -1 ) ); + var target = source.ToDateTime(); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + AssertUtc( target ); + } + + [Test] + public void TestToDateTime_UnixEpocPlus1Second_OK() + { + var source = default( Timestamp ).Add( TimeSpan.FromSeconds( 1 ) ); + var target = source.ToDateTime(); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + AssertUtc( target ); + } + + [Test] + public void TestFromDateTimeOffset_UnixEpoc_OK() + { + var source = DateTimeOffset.FromUnixTimeMilliseconds( 0 ); + var target = Timestamp.FromDateTimeOffset( source ); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + } + + [Test] + public void TestFromDateTimeOffset_UnixEpocMinus1Millisecond_OK() + { + var source = DateTimeOffset.FromUnixTimeMilliseconds( -1 ); + var target = Timestamp.FromDateTimeOffset( source ); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + } + + [Test] + public void TestFromDateTimeOffset_UnixEpocPlus1Millisecond_OK() + { + var source = DateTimeOffset.FromUnixTimeMilliseconds( 1 ); + var target = Timestamp.FromDateTimeOffset( source ); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + } + + [Test] + public void TestFromDateTimeOffset_UnixEpocMinus1Second_OK() + { + var source = DateTimeOffset.FromUnixTimeSeconds( -1 ); + var target = Timestamp.FromDateTimeOffset( source ); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + } + + [Test] + public void TestFromDateTimeOffset_UnixEpocPlus1Second_OK() + { + var source = DateTimeOffset.FromUnixTimeSeconds( 1 ); + var target = Timestamp.FromDateTimeOffset( source ); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + } + + [Test] + public void TestToDateTimeOffset_UnixEpoc_OK() + { + var source = default( Timestamp ); + var target = source.ToDateTimeOffset(); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + AssertUtc( target ); + } + + [Test] + public void TestToDateTimeOffset_UnixEpocMinus1Millisecond_OK() + { + var source = default( Timestamp ).Add( TimeSpan.FromMilliseconds( -1 ) ); + var target = source.ToDateTimeOffset(); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + AssertUtc( target ); + } + + [Test] + public void TestToDateTimeOffset_UnixEpocPlus1Millisecond_OK() + { + var source = default( Timestamp ).Add( TimeSpan.FromMilliseconds( 1 ) ); + var target = source.ToDateTimeOffset(); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + AssertUtc( target ); + } + + [Test] + public void TestToDateTimeOffset_UnixEpocMinus1Second_OK() + { + var source = default( Timestamp ).Add( TimeSpan.FromSeconds( -1 ) ); + var target = source.ToDateTimeOffset(); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + AssertUtc( target ); + } + + [Test] + public void TestToDateTimeOffset_UnixEpocPlus1Second_OK() + { + var source = default( Timestamp ).Add( TimeSpan.FromSeconds( 1 ) ); + var target = source.ToDateTimeOffset(); + var expected = source; + Assert.That( target.Year, Is.EqualTo( expected.Year ), "Year" ); + Assert.That( target.Month, Is.EqualTo( expected.Month ), "Month" ); + Assert.That( target.Day, Is.EqualTo( expected.Day ), "Day" ); + Assert.That( target.DayOfYear, Is.EqualTo( expected.DayOfYear ), "DayOfYear" ); + Assert.That( target.DayOfWeek, Is.EqualTo( expected.DayOfWeek ), "DayOfWeek" ); + Assert.That( target.Hour, Is.EqualTo( expected.Hour ), "Hour" ); + Assert.That( target.Minute, Is.EqualTo( expected.Minute ), "Minute" ); + Assert.That( target.Second, Is.EqualTo( expected.Second ), "Second" ); + Assert.That( target.Millisecond, Is.EqualTo( expected.Millisecond ), "Millisecond" ); + AssertSubseconds( target, expected ); + AssertUtc( target ); + } + +#endif // NET35 && !SILVERLIGHT && !NETSTANDARD1_1 } } diff --git a/test/MsgPack.UnitTest/TimestampTest.Conversion.tt b/test/MsgPack.UnitTest/TimestampTest.Conversion.tt index d0030d8a3..1621c3772 100644 --- a/test/MsgPack.UnitTest/TimestampTest.Conversion.tt +++ b/test/MsgPack.UnitTest/TimestampTest.Conversion.tt @@ -126,9 +126,38 @@ foreach ( var type in new [] { "DateTime", "DateTimeOffset" } ) Assert.That( target.Microsecond, Is.EqualTo( ticks / 10 ), "Microsecond" ); Assert.That( target.Nanosecond, Is.EqualTo( ( ticks % 10 ) * 100 ), "Nanosecond" ); } + <# } #> +#if !NET35 && !SILVERLIGHT && !NETSTANDARD1_1 + +<# + WriteConversionTest( "FromDateTime_UnixEpoc_OK", "DateTimeOffset.FromUnixTimeMilliseconds( 0 ).DateTime", "Timestamp.FromDateTime( {0} )", null, null ); + WriteConversionTest( "FromDateTime_UnixEpocMinus1Millisecond_OK", "DateTimeOffset.FromUnixTimeMilliseconds( -1 ).DateTime", "Timestamp.FromDateTime( {0} )", null, null ); + WriteConversionTest( "FromDateTime_UnixEpocPlus1Millisecond_OK", "DateTimeOffset.FromUnixTimeMilliseconds( 1 ).DateTime", "Timestamp.FromDateTime( {0} )", null, null ); + WriteConversionTest( "FromDateTime_UnixEpocMinusSecond_OK", "DateTimeOffset.FromUnixTimeSeconds( -1 ).DateTime", "Timestamp.FromDateTime( {0} )", null, null ); + WriteConversionTest( "FromDateTime_UnixEpocPlus1Second_OK", "DateTimeOffset.FromUnixTimeSeconds( 1 ).DateTime", "Timestamp.FromDateTime( {0} )", null, null ); + + WriteConversionTest( "ToDateTime_UnixEpoc_OK", "default( Timestamp )", "{0}.ToDateTime()", null, "AssertUtc( {0} )" ); + WriteConversionTest( "ToDateTime_UnixEpocMinus1Millisecond_OK", "default( Timestamp ).Add( TimeSpan.FromMilliseconds( -1 ) )", "{0}.ToDateTime()", null, "AssertUtc( {0} )" ); + WriteConversionTest( "ToDateTime_UnixEpocPlus1Millisecond_OK", "default( Timestamp ).Add( TimeSpan.FromMilliseconds( 1 ) )", "{0}.ToDateTime()", null, "AssertUtc( {0} )" ); + WriteConversionTest( "ToDateTime_UnixEpocMinus1Second_OK", "default( Timestamp ).Add( TimeSpan.FromSeconds( -1 ) )", "{0}.ToDateTime()", null, "AssertUtc( {0} )" ); + WriteConversionTest( "ToDateTime_UnixEpocPlus1Second_OK", "default( Timestamp ).Add( TimeSpan.FromSeconds( 1 ) )", "{0}.ToDateTime()", null, "AssertUtc( {0} )" ); + + WriteConversionTest( "FromDateTimeOffset_UnixEpoc_OK", "DateTimeOffset.FromUnixTimeMilliseconds( 0 )", "Timestamp.FromDateTimeOffset( {0} )", null, null ); + WriteConversionTest( "FromDateTimeOffset_UnixEpocMinus1Millisecond_OK", "DateTimeOffset.FromUnixTimeMilliseconds( -1 )", "Timestamp.FromDateTimeOffset( {0} )", null, null ); + WriteConversionTest( "FromDateTimeOffset_UnixEpocPlus1Millisecond_OK", "DateTimeOffset.FromUnixTimeMilliseconds( 1 )", "Timestamp.FromDateTimeOffset( {0} )", null, null ); + WriteConversionTest( "FromDateTimeOffset_UnixEpocMinus1Second_OK", "DateTimeOffset.FromUnixTimeSeconds( -1 )", "Timestamp.FromDateTimeOffset( {0} )", null, null ); + WriteConversionTest( "FromDateTimeOffset_UnixEpocPlus1Second_OK", "DateTimeOffset.FromUnixTimeSeconds( 1 )", "Timestamp.FromDateTimeOffset( {0} )", null, null ); + + WriteConversionTest( "ToDateTimeOffset_UnixEpoc_OK", "default( Timestamp )", "{0}.ToDateTimeOffset()", null, "AssertUtc( {0} )" ); + WriteConversionTest( "ToDateTimeOffset_UnixEpocMinus1Millisecond_OK", "default( Timestamp ).Add( TimeSpan.FromMilliseconds( -1 ) )", "{0}.ToDateTimeOffset()", null, "AssertUtc( {0} )" ); + WriteConversionTest( "ToDateTimeOffset_UnixEpocPlus1Millisecond_OK", "default( Timestamp ).Add( TimeSpan.FromMilliseconds( 1 ) )", "{0}.ToDateTimeOffset()", null, "AssertUtc( {0} )" ); + WriteConversionTest( "ToDateTimeOffset_UnixEpocMinus1Second_OK", "default( Timestamp ).Add( TimeSpan.FromSeconds( -1 ) )", "{0}.ToDateTimeOffset()", null, "AssertUtc( {0} )" ); + WriteConversionTest( "ToDateTimeOffset_UnixEpocPlus1Second_OK", "default( Timestamp ).Add( TimeSpan.FromSeconds( 1 ) )", "{0}.ToDateTimeOffset()", null, "AssertUtc( {0} )" ); +#> +#endif // NET35 && !SILVERLIGHT && !NETSTANDARD1_1 } } <#+ From 78b511f1ceb6fe933578046ebd642cc333deae27 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Wed, 5 Sep 2018 23:17:25 +0900 Subject: [PATCH 02/36] Fix exception in conversion from DateTime[Offset] to Timestamp. #296 If the date time is before Unix epoc and it has subsecond value, internal divrem operation returns negative remains and it causes exception. This commit add adjustment for this situation. --- src/MsgPack/Timestamp.Conversion.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/MsgPack/Timestamp.Conversion.cs b/src/MsgPack/Timestamp.Conversion.cs index f6fbc24ef..56b28063c 100644 --- a/src/MsgPack/Timestamp.Conversion.cs +++ b/src/MsgPack/Timestamp.Conversion.cs @@ -133,6 +133,14 @@ private static void FromOffsetTicks( long ticks, out long unixEpocSeconds, out i long remaining; unixEpocSeconds = DivRem( ticks, SecondsToTicks, out remaining ); nanoSeconds = unchecked( ( int )remaining ) * 100; + if ( nanoSeconds < 0 ) + { + // In this case, we must adjust these values + // from "negative nanosec from nearest larger negative integer" + // to "positive nanosec from nearest smaller nagative integer". + unixEpocSeconds -= 1; + nanoSeconds = ( MaxNanoSeconds + 1 ) + nanoSeconds; + } } /// From 44912facba43f0d285d1333a2ee4437df9f85276 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Wed, 5 Sep 2018 23:17:39 +0900 Subject: [PATCH 03/36] Fix changelog. --- CHANGES.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 0de4aca8e..326598977 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -753,3 +753,8 @@ Release 1.0.0 2018-6-14 * Fix map keys order emitted by asymmetric (serialization only) serializer are inconsistent across platform. * Fix Unity build does not honor serialization related attributes correctly. * Fix internal inconsitency between serialization related attributes detection and their parameter retrieval. + +Release 1.0.1 2018-09-09 + + BUG FIXES + * Fix conversion from DateTime[Offset] to Timestamp failure for before Unix epoc. #296 From b707db201ae23c23db443a78c521a04def596e27 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sun, 9 Sep 2018 16:52:24 +0900 Subject: [PATCH 04/36] Renew test certificate --- ...sgPack.UnitTest.BclExtensions.WinRT.csproj | 5 +++-- ...tTest.BclExtensions.WinRT_TemporaryKey.pfx | Bin 2536 -> 2536 bytes .../MsgPack.UnitTest.Uwp.Aot.csproj | 2 +- .../MsgPack.UnitTest.Uwp.Aot_TemporaryKey.pfx | Bin 2536 -> 2536 bytes .../MsgPack.UnitTest.Uwp.csproj | 5 +++-- .../MsgPack.UnitTest.Uwp_TemporaryKey.pfx | Bin 2536 -> 2536 bytes .../MsgPack.UnitTest.WinRT.csproj | 5 +++-- .../MsgPack.UnitTest.WinRT_TemporaryKey.pfx | Bin 2536 -> 2536 bytes 8 files changed, 10 insertions(+), 7 deletions(-) diff --git a/test/MsgPack.UnitTest.BclExtensions.WinRT/MsgPack.UnitTest.BclExtensions.WinRT.csproj b/test/MsgPack.UnitTest.BclExtensions.WinRT/MsgPack.UnitTest.BclExtensions.WinRT.csproj index d1374018d..f262117be 100644 --- a/test/MsgPack.UnitTest.BclExtensions.WinRT/MsgPack.UnitTest.BclExtensions.WinRT.csproj +++ b/test/MsgPack.UnitTest.BclExtensions.WinRT/MsgPack.UnitTest.BclExtensions.WinRT.csproj @@ -15,7 +15,7 @@ MsgPack.UnitTest.BclExtensions.WinRT_TemporaryKey.pfx ..\..\ true - 34322AD6CF171CC843FCCE936CB6B9B616B961E1 + AA68CFB533B03B5B4FAD8AE85A404BD5936CB7C7 8.1 12 @@ -23,7 +23,8 @@ - + + $(DefineConstants);NETFX_CORE;NETSTANDARD1_1;FEATURE_TAP;MSTEST ;2008 diff --git a/test/MsgPack.UnitTest.BclExtensions.WinRT/MsgPack.UnitTest.BclExtensions.WinRT_TemporaryKey.pfx b/test/MsgPack.UnitTest.B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2%06rC!)K_IfRFBVap`J zM8SWT{}`B)IrwJ*7qB2ipE0?cbaD(nvzWuLMo{rxOy$<*8oExBP9YekPxIO<%qQZe z$@g+Hru${4R@w_aJ=3~iAbi-~lg7?MJdMTL7)t^r?%-=5#d&S?b6@3NXybO3*3^j^>`x*o&8>%$ZhKzrd*1n*rLQKXlb zK|LrFrGgFA36ITvi#VDFq3h0V%jn2X1fFauFwzQf1&}6jXsD(I!~y##_DJhDKFf6- zS~e&Q&7BK6f;XQ))+NEZ>y6{Y&S|nLQI=$%8qY<>MI z^UY+J@)DyAM2v97b@pG_nnak{hMIpJ-0Wm&-vPc~p&>xudVX7S^1N_%0~o`&r+Z8{ zacI-E(&vrUk-qPQ;o^EF&ArUW{4i>JqxYkcji1h1cF5;d3kP4(hxNRA-7{0~20mDF z;NvAQqF>S^x6+5BC37wGGs)MyR7$f97_n*;YkAphd62cS_A3N*+ay{EtT}%p6+6L= zwpQMsY+B;}hU>weu8@BvbleB+RKpQ6?Aneg-2JzcbIZB% zl}c$8{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} MsgPack.UnitTest.Uwp.Aot_TemporaryKey.pfx 14.0 - C125CA52683091C62F7746FF9A159E44B2A18673 + 880646284800F8F3356B8C7E3E734562D8BB304F diff --git a/test/MsgPack.UnitTest.Uwp.Aot/MsgPack.UnitTest.Uwp.Aot_TemporaryKey.pfx b/test/MsgPack.UnitTest.Uwp.Aot/MsgPack.UnitTest.Uwp.Aot_TemporaryKey.pfx index bdea5d9135657d2b969e5d5c99421111534fcac8..8a0d0bd470c6ec815e7ac310d4683765e23db5e3 100644 GIT binary patch delta 2372 zcmV-K3A^^_6X+9vFoFr(0s#Xsf(e)g2`Yw2hW8Bt2LYgh35f)P3576%34t(z1@Z<7 zDuzgg_YDCD0ic2f;{<{Q-!Os&+c1I!*9HqJhDe6@4FL=a0Ro_c1okk31oAK(1_~;M zNQUcrnP4h^)V%meI^Ip3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);+cx%=GL%Pu( zdK#0j<>Y|XkO_dGjyn$V%%Iab(82*iF+6__3(g~R-_^n6Q&dm|Ee+Ca*W}P+li}Vm zfY65m9LMWhA9ndUKO;;>VPwJR#x8HItPnY|{67C`C`M2KeZuVJ=wh0I&1m)CS^qW;=!DHRHxCIG3>T5=o%K+sp4=|M~aCeyn+}lSgw?3mp`ekS~9nHbVLu z(#Zd?l%PQ+sCo3em`0sq%BhL$`D4qo8QZV9m_V-er9{}uSjHkc;|^j_k6nV1&iC$y z{6vr;uGPo&VOH!qWv?nsish-v3gAQz7e(6{U@$u{A20_71uG5%0vZGqTc$e(+fGr` qF>dX72rBtwMkTa71QfnM+bR@8N8>ZA!flq&s`~WzZJ;;;0te7MiCyae diff --git a/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj b/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj index 081f56673..6f5dfbce1 100644 --- a/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj +++ b/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj @@ -14,11 +14,12 @@ {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} MsgPack.UnitTest.Uwp_TemporaryKey.pfx 14.0 - 0CEFF2E3DC6DD3A7245B2FB641B6DE056C5A79D9 + 807856C98966D121CA69C33F7D6475CF03AA8633 - + + $(DefineConstants);NETFX_CORE;WINDOWS_UWP;NETSTANDARD1_3;FEATURE_TAP ;2008 false diff --git a/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp_TemporaryKey.pfx b/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp_TemporaryKey.pfx index d9a6dd76134fc2988d3c40cb918207f3285d700f..604dac0b06b2be4477b423f66665c174ef9a9e0e 100644 GIT binary patch delta 2283 zcmVo5xuSUJ;wqk4wxcIS_+kg_D z+AvK`xgWM5bqN3C2e0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D=DSXvSr=;OQW}h2CYzZuL!jR zlXn=fDRby>G|;+1a3{hZUQ^G_*kU$}FymQ?Sra_>{+wPOM0PRa!GGlxJg55(!R}Yq zKW?XCO8n~d*N>fsTAm5<+~Y;P9{wCy%t7);)x?;z)CW~KF!%M69kKAjZG3xlI_#78 znZgtxXH0nIRG-E*;OtZ%TfFR|P>hZuTFX9y`wo31A#GEw0xo3CaG`6C@0C|Dbcz)8 zf=+p(*mpRjKrCPpoPX@+LI&0|lu@`EcobC?;&GxhzalSP9FG71K83)o0A*AlrJaz^ zw4FX{xBDZ3NwCSt$Q_*OWx}(}4@a|bt={*Sc7TD{@fFE5RqyFG>tnoaZ+84*s99cYDV;Z6%zr19IVo?*{#xoD8+owD zjd~$w?im*pKg?jGNbt-sWJW}V|3{PuER>Iy6(2%Ve2k>obgVXW&UFd=-2Q;Y_>aBHW-(bqvy~blZxy45t|kUV)Qv)>_ww(HoK4;o^N13C0??7EEu>*- zK5XxK4YrpsMt^B2k;(6Xr5bSpgyZDlQzu;LPZ*Hw#7mNktyQ-|LX(LXQ;VLkiqYtj zlzX5#6-5ILt|hrl!PXcnA>*SwMI)^UdPd>n?-3HAn%J&g3MH+x{-mu4Fgq|GFb4(& zD-Ht!8Uz&O%Z&gYNy3_^94xE3yC;d512 {BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} MsgPack.UnitTest.WinRT_TemporaryKey.pfx - A411E1A11B99FF48CFDEDA3098F7F4D0FB6D746D + DEBDFCC31BC8F851996AD84C394EA999CA3ED9D1 8.1 12 @@ -19,7 +19,8 @@ - + + $(DefineConstants);NETFX_CORE;NETSTANDARD1_1;FEATURE_TAP;MSTEST ;2008 diff --git a/test/MsgPack.UnitTest.WinRT/MsgPack.UnitTest.WinRT_TemporaryKey.pfx b/test/MsgPack.UnitTest.WinRT/MsgPack.UnitTest.WinRT_TemporaryKey.pfx index 66ea08c7a9b446649253983aa236f7a10c0fe1b8..194d5586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g5;#(C_!03cuobK~`te*d+w4!(_BKZ1??I-7SnrtWK zFd3{<;G4szk!kfD@)Y}Of}5lJ>Fk{ zT#=Hr0UcoSFmh~}j-^-WjE{H&(`0xe1Z{FQQX^fy8Ha6*LvP6%tbb$Zri(*DMy-Xn zV!J!LvASQB*zr;N%!_smIXGfrMaabg_E?7~oEo}kZV}~xlMX=310;gPna_{XyO^~$ z=tV+40j^v`*;|>VKW6bFZm{eeQjBliJFP(4u5b0goHB%%P}DML7~%6{RgWCDB6ia+ zmtdfDRPM|{sWI*_L4ROa@}_##ds*5(j1`;5g|!0zrefQr>lY$O;Bu2vqk^UxPQXK- z1q2MHmw5#rO!yXP-r83T^D+_oX-QK6O|>hMAitjI50MO|Z`#K{?E$0IRxx)mOIeVh z#WdJd=DxnUQ93(8O8t-O$F-!V?|G-rFf-NXVj-61V#rB!Lw^iY>Pkm|@>d>K0<0xr z?w5{!VN$K=*;J|zLk8n9rbJRj#A!X;sH0Ay2DgzIcFw!>$JFdYwoxWQDtI=}c+x_ogvaIvV^XaDA?SH|@+G^WPfR^=n zxRfvE_*t>uet&+{(r$qU!|>d=o-~)QNkDq!l74F<9ml`C&}AKU#nCJ$07`##GH%2k zQ*4q&$i|WN?Ex&65N3l8`C&2DQ$cMcg+sHdIU1+1Gs*`7Tbcq;u$s;DFgq|GFb4(& zD-Ht!8Uz$@ny~9IVNh<4{2g7(ho522^k(h^6jP0DhZK41TO?iigkR27eRXzGab*Gm F2heiPV*>yH From 90433c8f18131da45c05eadaca7646e1c40ebef7 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sun, 9 Sep 2018 16:25:55 +0900 Subject: [PATCH 05/36] Code cleanup. * Add ChangeLog entry. * Code formatting according to .editorconfig settings including member name. * Fix XML syntax error. * Add Unit test for all projects. --- CHANGES.txt | 5 + src/MsgPack/Serialization/BindingOptions.cs | 23 ++- .../Serialization/SerializationContext.cs | 24 +-- .../Serialization/SerializationTarget.cs | 146 +++++++++--------- .../MessagePackMemberSkipTest.cs | 8 + 5 files changed, 109 insertions(+), 97 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 326598977..db2afa3b8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -758,3 +758,8 @@ Release 1.0.1 2018-09-09 BUG FIXES * Fix conversion from DateTime[Offset] to Timestamp failure for before Unix epoc. #296 + +Release 1.1 + + NEW FEATURE + * Allow programatically ignoring arbitary members via BindingOptions. Thank you @ShrenikOne #282 diff --git a/src/MsgPack/Serialization/BindingOptions.cs b/src/MsgPack/Serialization/BindingOptions.cs index 741dc3953..29090576d 100644 --- a/src/MsgPack/Serialization/BindingOptions.cs +++ b/src/MsgPack/Serialization/BindingOptions.cs @@ -21,7 +21,6 @@ // #endregion -- License Terms -- - using System; using System.Collections.Generic; using System.Linq; @@ -34,9 +33,9 @@ namespace MsgPack.Serialization public class BindingOptions { /// - /// Private mapping of types & their member skip list, which needs to ignore as part of serialization. + /// Private mapping of types & their member skip list, which needs to ignore as part of serialization. /// - private readonly IDictionary> typeIgnoringMembersMap = new Dictionary>(); + private readonly IDictionary> _typeIgnoringMembersMap = new Dictionary>(); /// /// Sets the member skip list for a specific target type. @@ -45,15 +44,15 @@ public class BindingOptions /// The member skip list. public void SetIgnoringMembers( Type targetType, IEnumerable memberSkipList ) { - lock ( this.typeIgnoringMembersMap ) + lock ( this._typeIgnoringMembersMap ) { - if ( this.typeIgnoringMembersMap.ContainsKey( targetType ) ) + if ( this._typeIgnoringMembersMap.ContainsKey( targetType ) ) { - this.typeIgnoringMembersMap[ targetType ] = memberSkipList; + this._typeIgnoringMembersMap[ targetType ] = memberSkipList; } else { - this.typeIgnoringMembersMap.Add( targetType, memberSkipList ); + this._typeIgnoringMembersMap.Add( targetType, memberSkipList ); } } } @@ -65,11 +64,11 @@ public void SetIgnoringMembers( Type targetType, IEnumerable memberSkipL /// Returns member skip list for a specific target type. public IEnumerable GetIgnoringMembers( Type targetType ) { - lock ( this.typeIgnoringMembersMap ) + lock ( this._typeIgnoringMembersMap ) { - if ( this.typeIgnoringMembersMap.ContainsKey( targetType ) ) + if ( this._typeIgnoringMembersMap.ContainsKey( targetType ) ) { - return this.typeIgnoringMembersMap[ targetType ]; + return this._typeIgnoringMembersMap[ targetType ]; } else { @@ -84,9 +83,9 @@ public IEnumerable GetIgnoringMembers( Type targetType ) /// Returns all registered types specific ignoring members. public IDictionary> GetAllIgnoringMembers() { - lock ( this.typeIgnoringMembersMap ) + lock ( this._typeIgnoringMembersMap ) { - return this.typeIgnoringMembersMap.ToDictionary( item => item.Key, item => ( IEnumerable )item.Value.ToArray() ); + return this._typeIgnoringMembersMap.ToDictionary( item => item.Key, item => ( IEnumerable )item.Value.ToArray() ); } } } diff --git a/src/MsgPack/Serialization/SerializationContext.cs b/src/MsgPack/Serialization/SerializationContext.cs index 1a91f72dd..2d33d0204 100644 --- a/src/MsgPack/Serialization/SerializationContext.cs +++ b/src/MsgPack/Serialization/SerializationContext.cs @@ -241,13 +241,13 @@ public SerializationMethod SerializationMethod { case SerializationMethod.Array: case SerializationMethod.Map: - { - break; - } + { + break; + } default: - { - throw new ArgumentOutOfRangeException( "value" ); - } + { + throw new ArgumentOutOfRangeException( "value" ); + } } Contract.EndContractBlock(); @@ -356,13 +356,13 @@ public DateTimeConversionMethod DefaultDateTimeConversionMethod case DateTimeConversionMethod.Native: case DateTimeConversionMethod.UnixEpoc: case DateTimeConversionMethod.Timestamp: - { - break; - } + { + break; + } default: - { - throw new ArgumentOutOfRangeException( "value" ); - } + { + throw new ArgumentOutOfRangeException( "value" ); + } } Contract.EndContractBlock(); diff --git a/src/MsgPack/Serialization/SerializationTarget.cs b/src/MsgPack/Serialization/SerializationTarget.cs index c31bd31ca..8efe8ab1b 100644 --- a/src/MsgPack/Serialization/SerializationTarget.cs +++ b/src/MsgPack/Serialization/SerializationTarget.cs @@ -122,18 +122,18 @@ private static string DetermineCorrespondingMemberName( ParameterInfo parameterI switch ( membersArray.Length ) { case 0: - { - return null; - } + { + return null; + } case 1: - { - return membersArray[ 0 ].MemberName; - } + { + return membersArray[ 0 ].MemberName; + } default: - { - ThrowAmbigiousMatchException( parameterInfo, membersArray ); - return null; - } + { + ThrowAmbigiousMatchException( parameterInfo, membersArray ); + return null; + } } } @@ -312,26 +312,26 @@ private static bool DetermineCanDeserialize( ConstructorKind kind, Serialization switch ( kind ) { case ConstructorKind.Marked: - { - Trace( "SerializationTarget::DetermineCanDeserialize({0}, {1}) -> true: Marked", targetType, kind ); - return true; - } + { + Trace( "SerializationTarget::DetermineCanDeserialize({0}, {1}) -> true: Marked", targetType, kind ); + return true; + } case ConstructorKind.Parameterful: - { - var result = HasAnyCorrespondingMembers( correspondingMemberNames ); - Trace( "SerializationTarget::DetermineCanDeserialize({0}, {1}) -> {2}: HasAnyCorrespondingMembers", targetType, kind, result ); - return result; - } + { + var result = HasAnyCorrespondingMembers( correspondingMemberNames ); + Trace( "SerializationTarget::DetermineCanDeserialize({0}, {1}) -> {2}: HasAnyCorrespondingMembers", targetType, kind, result ); + return result; + } case ConstructorKind.Default: - { - Trace( "SerializationTarget::DetermineCanDeserialize({0}, {1}) -> {2}: Default", targetType, kind, allowDefault ); - return allowDefault; - } + { + Trace( "SerializationTarget::DetermineCanDeserialize({0}, {1}) -> {2}: Default", targetType, kind, allowDefault ); + return allowDefault; + } default: - { - Contract.Assert( kind == ConstructorKind.None || kind == ConstructorKind.Ambiguous, "kind == ConstructorKind.None || kind == ConstructorKind.Ambiguous : " + kind ); - return false; - } + { + Contract.Assert( kind == ConstructorKind.None || kind == ConstructorKind.Ambiguous, "kind == ConstructorKind.None || kind == ConstructorKind.Ambiguous : " + kind ); + return false; + } } } @@ -637,25 +637,25 @@ private static ConstructorInfo FindDeserializationConstructor( SerializationCont switch ( markedConstructors.Count ) { case 0: - { - break; - } + { + break; + } case 1: - { - // OK use it for deserialization. - constructorKind = ConstructorKind.Marked; - return markedConstructors[ 0 ]; - } + { + // OK use it for deserialization. + constructorKind = ConstructorKind.Marked; + return markedConstructors[ 0 ]; + } default: - { - throw new SerializationException( - String.Format( - CultureInfo.CurrentCulture, - "There are multiple constructors marked with MessagePackDeserializationConstrutorAttribute in type '{0}'.", - targetType - ) - ); - } + { + throw new SerializationException( + String.Format( + CultureInfo.CurrentCulture, + "There are multiple constructors marked with MessagePackDeserializationConstrutorAttribute in type '{0}'.", + targetType + ) + ); + } } // A constructor which has most parameters will be used. @@ -667,43 +667,43 @@ private static ConstructorInfo FindDeserializationConstructor( SerializationCont switch ( mostRichConstructors.Length ) { case 1: - { - if ( mostRichConstructors[ 0 ].GetParameters().Length == 0 ) - { - if ( context.CompatibilityOptions.AllowAsymmetricSerializer ) - { - constructorKind = ConstructorKind.Default; - return mostRichConstructors[ 0 ]; - } - else - { - throw NewTypeCannotBeSerializedException( targetType ); - } - } - - // OK try use it but it may not handle deserialization correctly. - constructorKind = ConstructorKind.Parameterful; - return mostRichConstructors[ 0 ]; - } - default: + { + if ( mostRichConstructors[ 0 ].GetParameters().Length == 0 ) { if ( context.CompatibilityOptions.AllowAsymmetricSerializer ) { - constructorKind = ConstructorKind.Ambiguous; - return null; + constructorKind = ConstructorKind.Default; + return mostRichConstructors[ 0 ]; } else { - throw new SerializationException( - String.Format( - CultureInfo.CurrentCulture, - "Cannot serialize type '{0}' because it does not have any serializable fields nor properties, and serializer generator failed to determine constructor to deserialize among({1}).", - targetType, - String.Join( ", ", mostRichConstructors.Select( ctor => ctor.ToString() ).ToArray() ) - ) - ); + throw NewTypeCannotBeSerializedException( targetType ); } } + + // OK try use it but it may not handle deserialization correctly. + constructorKind = ConstructorKind.Parameterful; + return mostRichConstructors[ 0 ]; + } + default: + { + if ( context.CompatibilityOptions.AllowAsymmetricSerializer ) + { + constructorKind = ConstructorKind.Ambiguous; + return null; + } + else + { + throw new SerializationException( + String.Format( + CultureInfo.CurrentCulture, + "Cannot serialize type '{0}' because it does not have any serializable fields nor properties, and serializer generator failed to determine constructor to deserialize among({1}).", + targetType, + String.Join( ", ", mostRichConstructors.Select( ctor => ctor.ToString() ).ToArray() ) + ) + ); + } + } } } diff --git a/test/MsgPack.UnitTest/MessagePackMemberSkipTest.cs b/test/MsgPack.UnitTest/MessagePackMemberSkipTest.cs index dd55d86b5..5cddb9065 100644 --- a/test/MsgPack.UnitTest/MessagePackMemberSkipTest.cs +++ b/test/MsgPack.UnitTest/MessagePackMemberSkipTest.cs @@ -27,7 +27,15 @@ using MsgPack.Serialization; +#if !MSTEST using NUnit.Framework; // For running checking +#else +using TestFixtureAttribute = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; +using TestAttribute = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +using TimeoutAttribute = NUnit.Framework.TimeoutAttribute; +using Assert = NUnit.Framework.Assert; +using Is = NUnit.Framework.Is; +#endif namespace MsgPack { From a24607dcb1270992c96e0139e1f347b2f93872b7 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Mon, 10 Sep 2018 22:04:25 +0900 Subject: [PATCH 06/36] Fix Sync.Test.json to ignore Assets/ subdirectory. --- Sync.Test.json | 1 + 1 file changed, 1 insertion(+) diff --git a/Sync.Test.json b/Sync.Test.json index 02c5272a3..2677a2afa 100644 --- a/Sync.Test.json +++ b/Sync.Test.json @@ -297,6 +297,7 @@ "base": "MsgPack.UnitTest.Uwp", "globs": [ {"type": "include", "path": "../../src/MsgPack/Tuple`n.cs"}, + {"type": "remove", "path": "./Assets/**/*.cs"}, {"type": "remove", "path": "../MsgPack.UnitTest/AssertEx.cs"}, {"type": "remove", "path": "../MsgPack.UnitTest/gen/**/*.cs"}, {"type": "include", "path": "../MsgPack.UnitTest/gen35/**/*.cs"}, From c343d15219eac0c3f757bcfc1c403ceaa9b51135 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sun, 9 Sep 2018 17:47:07 +0900 Subject: [PATCH 07/36] Synchronize projects. --- src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj | 6 +++--- .../MsgPack.Silverlight.WindowsPhone.csproj | 6 +++--- src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj | 6 +++--- src/MsgPack.Unity/MsgPack.Unity.csproj | 6 +++--- src/MsgPack.Uwp/MsgPack.Uwp.csproj | 6 +++--- .../MsgPack.UnitTest.Silverlight.5.FullTrust.csproj | 3 +++ .../MsgPack.UnitTest.Silverlight.5.csproj | 3 +++ .../MsgPack.UnitTest.Silverlight.WindowsPhone.csproj | 3 +++ .../MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop.csproj | 3 +++ .../MsgPack.UnitTest.Uwp.Aot.csproj | 3 +++ test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj | 3 +++ .../MsgPack.UnitTest.WinRT.WindowsPhone.csproj | 3 +++ test/MsgPack.UnitTest.WinRT/MsgPack.UnitTest.WinRT.csproj | 3 +++ .../MsgPack.UnitTest.Xamarin.Android.csproj | 5 ++++- .../MsgPack.UnitTest.Xamarin.iOS.csproj | 3 +++ 15 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj b/src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj index 45b5284a5..16e46f9da 100644 --- a/src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj +++ b/src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj @@ -245,6 +245,9 @@ Serialization\ReflectionExtensions.ConstructorDelegate.cs + + Serialization\BindingOptions.cs + Serialization\CollectionDetailedKind.cs @@ -673,9 +676,6 @@ Serialization\SerializationCompatibilityOptions.cs - - - Serialization\BindingOptions.cs Serialization\SerializationContext.cs diff --git a/src/MsgPack.Silverlight.WindowsPhone/MsgPack.Silverlight.WindowsPhone.csproj b/src/MsgPack.Silverlight.WindowsPhone/MsgPack.Silverlight.WindowsPhone.csproj index 399b5796f..442277183 100644 --- a/src/MsgPack.Silverlight.WindowsPhone/MsgPack.Silverlight.WindowsPhone.csproj +++ b/src/MsgPack.Silverlight.WindowsPhone/MsgPack.Silverlight.WindowsPhone.csproj @@ -216,6 +216,9 @@ ReflectionAbstractions.cs + + Serialization\BindingOptions.cs + Serialization\CollectionDetailedKind.cs @@ -680,9 +683,6 @@ Serialization\SerializationCompatibilityOptions.cs - - - Serialization\BindingOptions.cs Serialization\SerializationContext.cs diff --git a/src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj b/src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj index 00a022cb8..e2776c167 100644 --- a/src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj +++ b/src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj @@ -220,6 +220,9 @@ Serialization\Tracer.cs + + Serialization\BindingOptions.cs + Serialization\CollectionDetailedKind.cs @@ -651,9 +654,6 @@ Serialization\SerializationCompatibilityOptions.cs - - - Serialization\BindingOptions.cs Serialization\SerializationContext.cs diff --git a/src/MsgPack.Unity/MsgPack.Unity.csproj b/src/MsgPack.Unity/MsgPack.Unity.csproj index 53ca4e7a3..3809104fe 100644 --- a/src/MsgPack.Unity/MsgPack.Unity.csproj +++ b/src/MsgPack.Unity/MsgPack.Unity.csproj @@ -234,13 +234,13 @@ ReflectionAbstractions.cs - - - Serialization\BindingOptions.cs Serialization\Tracer.cs + + Serialization\BindingOptions.cs + Serialization\CollectionDetailedKind.cs diff --git a/src/MsgPack.Uwp/MsgPack.Uwp.csproj b/src/MsgPack.Uwp/MsgPack.Uwp.csproj index f32d07373..b3f453e85 100644 --- a/src/MsgPack.Uwp/MsgPack.Uwp.csproj +++ b/src/MsgPack.Uwp/MsgPack.Uwp.csproj @@ -244,6 +244,9 @@ ReflectionAbstractions.cs + + Serialization\BindingOptions.cs + Serialization\CollectionDetailedKind.cs @@ -723,9 +726,6 @@ Serialization\SerializationCompatibilityOptions.cs - - - Serialization\BindingOptions.cs Serialization\SerializationContext.cs diff --git a/test/MsgPack.UnitTest.Silverlight.5.FullTrust/MsgPack.UnitTest.Silverlight.5.FullTrust.csproj b/test/MsgPack.UnitTest.Silverlight.5.FullTrust/MsgPack.UnitTest.Silverlight.5.FullTrust.csproj index ae00ef81f..d1b79c9db 100644 --- a/test/MsgPack.UnitTest.Silverlight.5.FullTrust/MsgPack.UnitTest.Silverlight.5.FullTrust.csproj +++ b/test/MsgPack.UnitTest.Silverlight.5.FullTrust/MsgPack.UnitTest.Silverlight.5.FullTrust.csproj @@ -136,6 +136,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.Silverlight.5/MsgPack.UnitTest.Silverlight.5.csproj b/test/MsgPack.UnitTest.Silverlight.5/MsgPack.UnitTest.Silverlight.5.csproj index 4ec3ed4d8..68a03a547 100644 --- a/test/MsgPack.UnitTest.Silverlight.5/MsgPack.UnitTest.Silverlight.5.csproj +++ b/test/MsgPack.UnitTest.Silverlight.5/MsgPack.UnitTest.Silverlight.5.csproj @@ -121,6 +121,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.Silverlight.WindowsPhone/MsgPack.UnitTest.Silverlight.WindowsPhone.csproj b/test/MsgPack.UnitTest.Silverlight.WindowsPhone/MsgPack.UnitTest.Silverlight.WindowsPhone.csproj index b799f51f8..a9c359ebe 100644 --- a/test/MsgPack.UnitTest.Silverlight.WindowsPhone/MsgPack.UnitTest.Silverlight.WindowsPhone.csproj +++ b/test/MsgPack.UnitTest.Silverlight.WindowsPhone/MsgPack.UnitTest.Silverlight.WindowsPhone.csproj @@ -99,6 +99,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop.csproj b/test/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop.csproj index c32f912e9..253381245 100644 --- a/test/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop.csproj +++ b/test/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop.csproj @@ -442,6 +442,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.Uwp.Aot/MsgPack.UnitTest.Uwp.Aot.csproj b/test/MsgPack.UnitTest.Uwp.Aot/MsgPack.UnitTest.Uwp.Aot.csproj index 405c158f6..5619c491c 100644 --- a/test/MsgPack.UnitTest.Uwp.Aot/MsgPack.UnitTest.Uwp.Aot.csproj +++ b/test/MsgPack.UnitTest.Uwp.Aot/MsgPack.UnitTest.Uwp.Aot.csproj @@ -1551,6 +1551,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj b/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj index 6f5dfbce1..58e9423ca 100644 --- a/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj +++ b/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj @@ -1534,6 +1534,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.WinRT.WindowsPhone/MsgPack.UnitTest.WinRT.WindowsPhone.csproj b/test/MsgPack.UnitTest.WinRT.WindowsPhone/MsgPack.UnitTest.WinRT.WindowsPhone.csproj index 3aca36e1c..fe28e24b0 100644 --- a/test/MsgPack.UnitTest.WinRT.WindowsPhone/MsgPack.UnitTest.WinRT.WindowsPhone.csproj +++ b/test/MsgPack.UnitTest.WinRT.WindowsPhone/MsgPack.UnitTest.WinRT.WindowsPhone.csproj @@ -122,6 +122,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.WinRT/MsgPack.UnitTest.WinRT.csproj b/test/MsgPack.UnitTest.WinRT/MsgPack.UnitTest.WinRT.csproj index ef2acfe77..856d1dc81 100644 --- a/test/MsgPack.UnitTest.WinRT/MsgPack.UnitTest.WinRT.csproj +++ b/test/MsgPack.UnitTest.WinRT/MsgPack.UnitTest.WinRT.csproj @@ -128,6 +128,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.Xamarin.Android/MsgPack.UnitTest.Xamarin.Android.csproj b/test/MsgPack.UnitTest.Xamarin.Android/MsgPack.UnitTest.Xamarin.Android.csproj index 286251f05..26abce614 100644 --- a/test/MsgPack.UnitTest.Xamarin.Android/MsgPack.UnitTest.Xamarin.Android.csproj +++ b/test/MsgPack.UnitTest.Xamarin.Android/MsgPack.UnitTest.Xamarin.Android.csproj @@ -58,6 +58,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs @@ -263,7 +266,7 @@ - + Designer diff --git a/test/MsgPack.UnitTest.Xamarin.iOS/MsgPack.UnitTest.Xamarin.iOS.csproj b/test/MsgPack.UnitTest.Xamarin.iOS/MsgPack.UnitTest.Xamarin.iOS.csproj index 5fb06be4c..3619a69a6 100644 --- a/test/MsgPack.UnitTest.Xamarin.iOS/MsgPack.UnitTest.Xamarin.iOS.csproj +++ b/test/MsgPack.UnitTest.Xamarin.iOS/MsgPack.UnitTest.Xamarin.iOS.csproj @@ -58,6 +58,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs From 3dc60b6f8c4ec07874e07947a29608e8d9ea107e Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sun, 9 Sep 2018 16:48:10 +0900 Subject: [PATCH 08/36] Add SerializationCompatibilityLevel. --- CHANGES.txt | 4 + .../SerializationCompatibilityLevel.cs | 46 ++++++++ .../Serialization/SerializationContext.cs | 105 +++++++++++++++--- 3 files changed, 138 insertions(+), 17 deletions(-) create mode 100644 src/MsgPack/Serialization/SerializationCompatibilityLevel.cs diff --git a/CHANGES.txt b/CHANGES.txt index db2afa3b8..9dffa6710 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -761,5 +761,9 @@ Release 1.0.1 2018-09-09 Release 1.1 + BUG FIXES + * Fix conversion from DateTime[Offset] to Timestamp failure for before Unix epoc. #296 (port from 1.0.x branch) + NEW FEATURE * Allow programatically ignoring arbitary members via BindingOptions. Thank you @ShrenikOne #282 + * To prevent accidental Timestamp serialization in existing code, SerializationContext.ConfigureClassic(SerializationCompatibilityLevel) and SerializationContext.CreateClassicContext(SerializationCompatibilityLevel) are added. #296 diff --git a/src/MsgPack/Serialization/SerializationCompatibilityLevel.cs b/src/MsgPack/Serialization/SerializationCompatibilityLevel.cs new file mode 100644 index 000000000..3232cf851 --- /dev/null +++ b/src/MsgPack/Serialization/SerializationCompatibilityLevel.cs @@ -0,0 +1,46 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2018 FUJIWARA, Yusuke and contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Contributors: +// Samuel Cragg +// +#endregion -- License Terms -- + +namespace MsgPack.Serialization +{ + /// + /// Represents compatibility level. + /// + public enum SerializationCompatibilityLevel + { + /// + /// Use latest feature. Almost backward compatible, but some compatibities are broken. + /// + Latest = 0, + + /// + /// Compatible for version 0.5.x or former. + /// + Version0_5, + + /// + /// Compatible for version 0.6.x, 0.7.x, 0.8.x, and 0.9.x. + /// + Version0_9 + } +} diff --git a/src/MsgPack/Serialization/SerializationContext.cs b/src/MsgPack/Serialization/SerializationContext.cs index 2d33d0204..8d445eb4f 100644 --- a/src/MsgPack/Serialization/SerializationContext.cs +++ b/src/MsgPack/Serialization/SerializationContext.cs @@ -478,14 +478,26 @@ private MessagePackSerializer OnResolveSerializer( PolymorphismSchema sche } /// - /// Configures as new classic instance. + /// Configures as new classic instance as compatible for ver 0.5. /// /// The previously set context as . /// + [Obsolete( "Use ConfigureClassic(SerializationCompatibilityLevel) instead." )] public static SerializationContext ConfigureClassic() { + return ConfigureClassic( SerializationCompatibilityLevel.Version0_5 ); + } + + /// + /// Configures as new classic instance as compatible for sepcified version. + /// + /// A to specify compatibility level. + /// The previously set context as . + /// + public static SerializationContext ConfigureClassic(SerializationCompatibilityLevel compatibilityLevel) + { #if !UNITY - return Interlocked.Exchange( ref _default, CreateClassicContext() ); + return Interlocked.Exchange( ref _default, CreateClassicContext( compatibilityLevel) ); #else lock ( DefaultContextSyncRoot ) { @@ -502,34 +514,93 @@ public static SerializationContext ConfigureClassic() /// /// A new which is configured as same as 0.5. /// + [Obsolete( "Use CreateClassicContext(SerializationCompatibilityLevel) instead." )] + public static SerializationContext CreateClassicContext() + { + return CreateClassicContext( SerializationCompatibilityLevel.Version0_5 ); + } + + /// + /// Creates a new which is configured as compatible for the specified version. + /// + /// A to specify compatibility level. + /// + /// A new which is configured as compatible for the specified version. + /// /// - /// There are breaking changes of properties to improve API usability and to prevent accidental failure. - /// This method returns a which configured as classic style settings as follows: + /// + /// There are breaking changes of properties to improve API usability and to prevent accidental failure. + /// This method returns a which configured as classic style settings as follows: + /// /// /// /// - /// Default (as of 0.6) - /// Classic (before 0.6) + /// Latest (as of 0.6) + /// Version0_9 (as of 0.6) + /// Version0_5 (formally, "classic", before 0.6) /// /// - /// Packed object members order (if members are not marked with nor System.Runtime.Serialization.DataMemberAttribute and serializer uses ) - /// As declared (metadata table order) - /// As lexicographical - /// - /// - /// value + /// and value + /// value. /// Native representation (100-nano ticks, preserving .) /// UTC, milliseconds Unix epoc. /// + /// + /// Usage of ext types + /// Allowed + /// Allowed + /// Prohibited + /// + /// + /// Binary (such as Byte[]) representation + /// Bin types + /// Bin types + /// Raw types + /// + /// + /// Strings which lengthes are between 17 to 255 + /// Str8 type + /// Str8 types + /// Raw16 type + /// /// + /// + /// In short, prohibits deserialization error in legacy implementation + /// which do not recognize ext types, str8 type, and/or bin types. + /// prohibits only serialization for datetime + /// to keep compatibility for 0.9.x instead of maximize datetime serialization for modern implementations which uses msgpack timestamp type, + /// which is composite ext type, nano-second precision Unix epoc time. + /// /// - public static SerializationContext CreateClassicContext() + public static SerializationContext CreateClassicContext( SerializationCompatibilityLevel compatibilityLevel ) { - return - new SerializationContext( PackerCompatibilityOptions.Classic ) + switch ( compatibilityLevel ) + { + case SerializationCompatibilityLevel.Version0_5: { - DefaultDateTimeConversionMethod = DateTimeConversionMethod.UnixEpoc - }; + return + new SerializationContext( PackerCompatibilityOptions.Classic ) + { + DefaultDateTimeConversionMethod = DateTimeConversionMethod.UnixEpoc + }; + } + case SerializationCompatibilityLevel.Version0_9: + { + return + new SerializationContext( PackerCompatibilityOptions.None ) + { + DefaultDateTimeConversionMethod = DateTimeConversionMethod.Native + }; + } + case SerializationCompatibilityLevel.Latest: + { + return new SerializationContext( PackerCompatibilityOptions.None ); + } + default: + { + throw new ArgumentOutOfRangeException( "Unknown SerializationCompatibilityLevel value." ); + } + } } /// From c3b63c008a8039057a694d19ce871f64c8013728 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sun, 9 Sep 2018 17:47:21 +0900 Subject: [PATCH 09/36] Synchronize projects. --- src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj | 3 +++ .../MsgPack.Silverlight.WindowsPhone.csproj | 3 +++ src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj | 3 +++ src/MsgPack.Unity/MsgPack.Unity.csproj | 3 +++ src/MsgPack.Uwp/MsgPack.Uwp.csproj | 3 +++ 5 files changed, 15 insertions(+) diff --git a/src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj b/src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj index 16e46f9da..f8d9dc0c1 100644 --- a/src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj +++ b/src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj @@ -674,6 +674,9 @@ Serialization\ResolveSerializerEventArgs.cs + + Serialization\SerializationCompatibilityLevel.cs + Serialization\SerializationCompatibilityOptions.cs diff --git a/src/MsgPack.Silverlight.WindowsPhone/MsgPack.Silverlight.WindowsPhone.csproj b/src/MsgPack.Silverlight.WindowsPhone/MsgPack.Silverlight.WindowsPhone.csproj index 442277183..13939a92b 100644 --- a/src/MsgPack.Silverlight.WindowsPhone/MsgPack.Silverlight.WindowsPhone.csproj +++ b/src/MsgPack.Silverlight.WindowsPhone/MsgPack.Silverlight.WindowsPhone.csproj @@ -681,6 +681,9 @@ Serialization\ResolveSerializerEventArgs.cs + + Serialization\SerializationCompatibilityLevel.cs + Serialization\SerializationCompatibilityOptions.cs diff --git a/src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj b/src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj index e2776c167..c7665009a 100644 --- a/src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj +++ b/src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj @@ -652,6 +652,9 @@ Serialization\ResolveSerializerEventArgs.cs + + Serialization\SerializationCompatibilityLevel.cs + Serialization\SerializationCompatibilityOptions.cs diff --git a/src/MsgPack.Unity/MsgPack.Unity.csproj b/src/MsgPack.Unity/MsgPack.Unity.csproj index 3809104fe..8d8d7361f 100644 --- a/src/MsgPack.Unity/MsgPack.Unity.csproj +++ b/src/MsgPack.Unity/MsgPack.Unity.csproj @@ -658,6 +658,9 @@ Serialization\ResolveSerializerEventArgs.cs + + Serialization\SerializationCompatibilityLevel.cs + Serialization\SerializationCompatibilityOptions.cs diff --git a/src/MsgPack.Uwp/MsgPack.Uwp.csproj b/src/MsgPack.Uwp/MsgPack.Uwp.csproj index b3f453e85..6865b97e6 100644 --- a/src/MsgPack.Uwp/MsgPack.Uwp.csproj +++ b/src/MsgPack.Uwp/MsgPack.Uwp.csproj @@ -724,6 +724,9 @@ Serialization\ResolveSerializerEventArgs.cs + + Serialization\SerializationCompatibilityLevel.cs + Serialization\SerializationCompatibilityOptions.cs From fcc15726ffd20b8a3abc162b1036ac982a1a7207 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sun, 9 Sep 2018 17:27:10 +0900 Subject: [PATCH 10/36] Add/fix unit tests to test compatibility levels correctly. --- ...deDomBasedAutoMessagePackSerializerTest.cs | 127 ++++++++++++++--- ...deDomBasedAutoMessagePackSerializerTest.cs | 127 ++++++++++++++--- ...FieldBasedAutoMessagePackSerializerTest.cs | 127 ++++++++++++++--- ...ationBasedAutoMessagePackSerializerTest.cs | 90 ++++++++++-- ...ctionBasedAutoMessagePackSerializerTest.cs | 127 ++++++++++++++--- .../AutoMessagePackSerializerTest.ttinclude | 129 +++++++++++++++--- ...FieldBasedAutoMessagePackSerializerTest.cs | 127 ++++++++++++++--- ...ationBasedAutoMessagePackSerializerTest.cs | 90 ++++++++++-- ...ctionBasedAutoMessagePackSerializerTest.cs | 127 ++++++++++++++--- .../PreGeneratedSerializerActivator.cs | 24 +++- .../Serialization/RegressionTests.cs | 2 +- .../Serialization/SerializationContextTest.cs | 81 +++++++++-- .../TimestampSerializationTest.cs | 12 +- 13 files changed, 1005 insertions(+), 185 deletions(-) diff --git a/test/MsgPack.UnitTest.CodeDom/Serialization/ArrayCodeDomBasedAutoMessagePackSerializerTest.cs b/test/MsgPack.UnitTest.CodeDom/Serialization/ArrayCodeDomBasedAutoMessagePackSerializerTest.cs index 65f18287a..574d83dca 100644 --- a/test/MsgPack.UnitTest.CodeDom/Serialization/ArrayCodeDomBasedAutoMessagePackSerializerTest.cs +++ b/test/MsgPack.UnitTest.CodeDom/Serialization/ArrayCodeDomBasedAutoMessagePackSerializerTest.cs @@ -92,13 +92,13 @@ private static SerializationContext GetSerializationContext() private static SerializationContext NewSerializationContext() { - return NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + return NewSerializationContext( SerializationCompatibilityLevel.Latest ); } - private static SerializationContext NewSerializationContext( PackerCompatibilityOptions compatibilityOptions, DateTimeConversionMethod dateTimeConversionMethod ) + private static SerializationContext NewSerializationContext( SerializationCompatibilityLevel compatibilityLevel ) { - var context = new SerializationContext( compatibilityOptions ) { SerializationMethod = SerializationMethod.Array }; - context.DefaultDateTimeConversionMethod = dateTimeConversionMethod; + var context = SerializationContext.CreateClassicContext( compatibilityLevel ); + context.SerializationMethod = SerializationMethod.Array; context.SerializerOptions.EmitterFlavor = EmitterFlavor.CodeDomBased; #if SILVERLIGHT && !SILVERLIGHT_PRIVILEGED context.SerializerOptions.DisablePrivilegedAccess = true; @@ -278,10 +278,38 @@ public void TestDateTimeOffset() } [Test] - public void TestDateTimeNative() + public void TestDateTimeLatest() + { + TestCore( + DateTime.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTime(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeOffsetLatest() + { + TestCore( + DateTimeOffset.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTimeOffset(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeClassic0_9() { TestCore( - DateTime.Now, + DateTime.Now, // Use now because Native mode should serialize its kind stream => DateTime.FromBinary( Unpacking.UnpackInt64( stream ) ), ( x, y ) => x.Equals( y ), context => @@ -292,10 +320,10 @@ public void TestDateTimeNative() } [Test] - public void TestDateTimeOffsetNative() + public void TestDateTimeOffsetClassic0_9() { TestCore( - DateTimeOffset.Now, + DateTimeOffset.Now, // Use now because Native mode should serialize its kind stream => { var array = Unpacking.UnpackArray( stream ); @@ -310,7 +338,7 @@ public void TestDateTimeOffsetNative() } [Test] - public void TestDateTimeClassic() + public void TestDateTimeClassic0_5() { TestCore( DateTime.UtcNow, @@ -324,7 +352,7 @@ public void TestDateTimeClassic() } [Test] - public void TestDateTimeOffsetClassic() + public void TestDateTimeOffsetClassic0_5() { TestCore( DateTimeOffset.UtcNow, @@ -1468,7 +1496,8 @@ private async Task TestTupleAsyncCore( T expected, int arity ) [Test] public void TestEmptyBytes() { - var serializer = this.CreateTarget( GetSerializationContext() ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { serializer.Pack( stream, new byte[ 0 ] ); @@ -1479,9 +1508,9 @@ public void TestEmptyBytes() } [Test] - public void TestEmptyBytes_Classic() + public void TestEmptyBytes_Classic0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -1492,6 +1521,20 @@ public void TestEmptyBytes_Classic() } } + [Test] + public void TestEmptyBytes_Classic0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = this.CreateTarget( context ); + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[ 0 ] ); + Assert.That( stream.Length, Is.EqualTo( 2 ), BitConverter.ToString( stream.ToArray() ) ); + stream.Position = 0; + Assert.That( serializer.Unpack( stream ), Is.EqualTo( new byte[ 0 ] ) ); + } + } + [Test] public void TestEmptyString() { @@ -4380,10 +4423,10 @@ public void TestFullPackableUnpackable_PackToMessageAndUnpackFromMessageUsed() #endif // FEATURE_TAP [Test] - public void TestBinary_ClassicContext() + public void TestBinary_ClassicContext0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); - var serializer = context.GetSerializer(); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -4392,10 +4435,37 @@ public void TestBinary_ClassicContext() } } + [Test] + public void TestBinary_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) );; + } + } + + [Test] + public void TestBinary_DefaultContext() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) ); + } + } + [Test] public void TestBinary_ContextWithPackerCompatilibyOptionsNone() { - var context = NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + context.CompatibilityOptions.PackerCompatibilityOptions = PackerCompatibilityOptions.None; var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) @@ -4405,9 +4475,9 @@ public void TestBinary_ContextWithPackerCompatilibyOptionsNone() } } [Test] - public void TestExt_ClassicContext() + public void TestExt_ClassicContext0_5() { - var context = NewSerializationContext( SerializationContext.CreateClassicContext().CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.CreateClassicContext().DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); context.Serializers.RegisterOverride( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); @@ -4421,10 +4491,27 @@ public void TestExt_ClassicContext() } } + [Test] + public void TestExt_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + context.Serializers.Register( new CustomDateTimeSerealizer() ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + var date = DateTime.UtcNow; + serializer.Pack( stream, date ); + stream.Position = 0; + var unpacked = serializer.Unpack( stream ); + Assert.That( unpacked.ToString( "yyyyMMddHHmmssfff" ), Is.EqualTo( date.ToString( "yyyyMMddHHmmssfff" ) ) ); + } + } + [Test] public void TestExt_DefaultContext() { - var context = NewSerializationContext( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.Default.DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); context.Serializers.Register( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); diff --git a/test/MsgPack.UnitTest.CodeDom/Serialization/MapCodeDomBasedAutoMessagePackSerializerTest.cs b/test/MsgPack.UnitTest.CodeDom/Serialization/MapCodeDomBasedAutoMessagePackSerializerTest.cs index f7e10d905..0830279d3 100644 --- a/test/MsgPack.UnitTest.CodeDom/Serialization/MapCodeDomBasedAutoMessagePackSerializerTest.cs +++ b/test/MsgPack.UnitTest.CodeDom/Serialization/MapCodeDomBasedAutoMessagePackSerializerTest.cs @@ -93,13 +93,13 @@ private static SerializationContext GetSerializationContext() private static SerializationContext NewSerializationContext() { - return NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + return NewSerializationContext( SerializationCompatibilityLevel.Latest ); } - private static SerializationContext NewSerializationContext( PackerCompatibilityOptions compatibilityOptions, DateTimeConversionMethod dateTimeConversionMethod ) + private static SerializationContext NewSerializationContext( SerializationCompatibilityLevel compatibilityLevel ) { - var context = new SerializationContext( compatibilityOptions ) { SerializationMethod = SerializationMethod.Map }; - context.DefaultDateTimeConversionMethod = dateTimeConversionMethod; + var context = SerializationContext.CreateClassicContext( compatibilityLevel ); + context.SerializationMethod = SerializationMethod.Map; context.SerializerOptions.EmitterFlavor = EmitterFlavor.CodeDomBased; #if SILVERLIGHT && !SILVERLIGHT_PRIVILEGED context.SerializerOptions.DisablePrivilegedAccess = true; @@ -279,10 +279,38 @@ public void TestDateTimeOffset() } [Test] - public void TestDateTimeNative() + public void TestDateTimeLatest() + { + TestCore( + DateTime.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTime(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeOffsetLatest() + { + TestCore( + DateTimeOffset.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTimeOffset(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeClassic0_9() { TestCore( - DateTime.Now, + DateTime.Now, // Use now because Native mode should serialize its kind stream => DateTime.FromBinary( Unpacking.UnpackInt64( stream ) ), ( x, y ) => x.Equals( y ), context => @@ -293,10 +321,10 @@ public void TestDateTimeNative() } [Test] - public void TestDateTimeOffsetNative() + public void TestDateTimeOffsetClassic0_9() { TestCore( - DateTimeOffset.Now, + DateTimeOffset.Now, // Use now because Native mode should serialize its kind stream => { var array = Unpacking.UnpackArray( stream ); @@ -311,7 +339,7 @@ public void TestDateTimeOffsetNative() } [Test] - public void TestDateTimeClassic() + public void TestDateTimeClassic0_5() { TestCore( DateTime.UtcNow, @@ -325,7 +353,7 @@ public void TestDateTimeClassic() } [Test] - public void TestDateTimeOffsetClassic() + public void TestDateTimeOffsetClassic0_5() { TestCore( DateTimeOffset.UtcNow, @@ -1469,7 +1497,8 @@ private async Task TestTupleAsyncCore( T expected, int arity ) [Test] public void TestEmptyBytes() { - var serializer = this.CreateTarget( GetSerializationContext() ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { serializer.Pack( stream, new byte[ 0 ] ); @@ -1480,9 +1509,9 @@ public void TestEmptyBytes() } [Test] - public void TestEmptyBytes_Classic() + public void TestEmptyBytes_Classic0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -1493,6 +1522,20 @@ public void TestEmptyBytes_Classic() } } + [Test] + public void TestEmptyBytes_Classic0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = this.CreateTarget( context ); + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[ 0 ] ); + Assert.That( stream.Length, Is.EqualTo( 2 ), BitConverter.ToString( stream.ToArray() ) ); + stream.Position = 0; + Assert.That( serializer.Unpack( stream ), Is.EqualTo( new byte[ 0 ] ) ); + } + } + [Test] public void TestEmptyString() { @@ -4457,10 +4500,10 @@ public void TestFullPackableUnpackable_PackToMessageAndUnpackFromMessageUsed() #endif // FEATURE_TAP [Test] - public void TestBinary_ClassicContext() + public void TestBinary_ClassicContext0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); - var serializer = context.GetSerializer(); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -4469,10 +4512,37 @@ public void TestBinary_ClassicContext() } } + [Test] + public void TestBinary_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) );; + } + } + + [Test] + public void TestBinary_DefaultContext() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) ); + } + } + [Test] public void TestBinary_ContextWithPackerCompatilibyOptionsNone() { - var context = NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + context.CompatibilityOptions.PackerCompatibilityOptions = PackerCompatibilityOptions.None; var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) @@ -4482,9 +4552,9 @@ public void TestBinary_ContextWithPackerCompatilibyOptionsNone() } } [Test] - public void TestExt_ClassicContext() + public void TestExt_ClassicContext0_5() { - var context = NewSerializationContext( SerializationContext.CreateClassicContext().CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.CreateClassicContext().DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); context.Serializers.RegisterOverride( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); @@ -4498,10 +4568,27 @@ public void TestExt_ClassicContext() } } + [Test] + public void TestExt_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + context.Serializers.Register( new CustomDateTimeSerealizer() ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + var date = DateTime.UtcNow; + serializer.Pack( stream, date ); + stream.Position = 0; + var unpacked = serializer.Unpack( stream ); + Assert.That( unpacked.ToString( "yyyyMMddHHmmssfff" ), Is.EqualTo( date.ToString( "yyyyMMddHHmmssfff" ) ) ); + } + } + [Test] public void TestExt_DefaultContext() { - var context = NewSerializationContext( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.Default.DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); context.Serializers.Register( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); diff --git a/test/MsgPack.UnitTest/Serialization/ArrayFieldBasedAutoMessagePackSerializerTest.cs b/test/MsgPack.UnitTest/Serialization/ArrayFieldBasedAutoMessagePackSerializerTest.cs index 9fe454b99..d46157954 100644 --- a/test/MsgPack.UnitTest/Serialization/ArrayFieldBasedAutoMessagePackSerializerTest.cs +++ b/test/MsgPack.UnitTest/Serialization/ArrayFieldBasedAutoMessagePackSerializerTest.cs @@ -92,13 +92,13 @@ private static SerializationContext GetSerializationContext() private static SerializationContext NewSerializationContext() { - return NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + return NewSerializationContext( SerializationCompatibilityLevel.Latest ); } - private static SerializationContext NewSerializationContext( PackerCompatibilityOptions compatibilityOptions, DateTimeConversionMethod dateTimeConversionMethod ) + private static SerializationContext NewSerializationContext( SerializationCompatibilityLevel compatibilityLevel ) { - var context = new SerializationContext( compatibilityOptions ) { SerializationMethod = SerializationMethod.Array }; - context.DefaultDateTimeConversionMethod = dateTimeConversionMethod; + var context = SerializationContext.CreateClassicContext( compatibilityLevel ); + context.SerializationMethod = SerializationMethod.Array; context.SerializerOptions.EmitterFlavor = EmitterFlavor.FieldBased; #if SILVERLIGHT && !SILVERLIGHT_PRIVILEGED context.SerializerOptions.DisablePrivilegedAccess = true; @@ -278,10 +278,38 @@ public void TestDateTimeOffset() } [Test] - public void TestDateTimeNative() + public void TestDateTimeLatest() + { + TestCore( + DateTime.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTime(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeOffsetLatest() + { + TestCore( + DateTimeOffset.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTimeOffset(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeClassic0_9() { TestCore( - DateTime.Now, + DateTime.Now, // Use now because Native mode should serialize its kind stream => DateTime.FromBinary( Unpacking.UnpackInt64( stream ) ), ( x, y ) => x.Equals( y ), context => @@ -292,10 +320,10 @@ public void TestDateTimeNative() } [Test] - public void TestDateTimeOffsetNative() + public void TestDateTimeOffsetClassic0_9() { TestCore( - DateTimeOffset.Now, + DateTimeOffset.Now, // Use now because Native mode should serialize its kind stream => { var array = Unpacking.UnpackArray( stream ); @@ -310,7 +338,7 @@ public void TestDateTimeOffsetNative() } [Test] - public void TestDateTimeClassic() + public void TestDateTimeClassic0_5() { TestCore( DateTime.UtcNow, @@ -324,7 +352,7 @@ public void TestDateTimeClassic() } [Test] - public void TestDateTimeOffsetClassic() + public void TestDateTimeOffsetClassic0_5() { TestCore( DateTimeOffset.UtcNow, @@ -1468,7 +1496,8 @@ private async Task TestTupleAsyncCore( T expected, int arity ) [Test] public void TestEmptyBytes() { - var serializer = this.CreateTarget( GetSerializationContext() ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { serializer.Pack( stream, new byte[ 0 ] ); @@ -1479,9 +1508,9 @@ public void TestEmptyBytes() } [Test] - public void TestEmptyBytes_Classic() + public void TestEmptyBytes_Classic0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -1492,6 +1521,20 @@ public void TestEmptyBytes_Classic() } } + [Test] + public void TestEmptyBytes_Classic0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = this.CreateTarget( context ); + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[ 0 ] ); + Assert.That( stream.Length, Is.EqualTo( 2 ), BitConverter.ToString( stream.ToArray() ) ); + stream.Position = 0; + Assert.That( serializer.Unpack( stream ), Is.EqualTo( new byte[ 0 ] ) ); + } + } + [Test] public void TestEmptyString() { @@ -4380,10 +4423,10 @@ public void TestFullPackableUnpackable_PackToMessageAndUnpackFromMessageUsed() #endif // FEATURE_TAP [Test] - public void TestBinary_ClassicContext() + public void TestBinary_ClassicContext0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); - var serializer = context.GetSerializer(); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -4392,10 +4435,37 @@ public void TestBinary_ClassicContext() } } + [Test] + public void TestBinary_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) );; + } + } + + [Test] + public void TestBinary_DefaultContext() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) ); + } + } + [Test] public void TestBinary_ContextWithPackerCompatilibyOptionsNone() { - var context = NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + context.CompatibilityOptions.PackerCompatibilityOptions = PackerCompatibilityOptions.None; var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) @@ -4405,9 +4475,9 @@ public void TestBinary_ContextWithPackerCompatilibyOptionsNone() } } [Test] - public void TestExt_ClassicContext() + public void TestExt_ClassicContext0_5() { - var context = NewSerializationContext( SerializationContext.CreateClassicContext().CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.CreateClassicContext().DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); context.Serializers.RegisterOverride( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); @@ -4421,10 +4491,27 @@ public void TestExt_ClassicContext() } } + [Test] + public void TestExt_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + context.Serializers.Register( new CustomDateTimeSerealizer() ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + var date = DateTime.UtcNow; + serializer.Pack( stream, date ); + stream.Position = 0; + var unpacked = serializer.Unpack( stream ); + Assert.That( unpacked.ToString( "yyyyMMddHHmmssfff" ), Is.EqualTo( date.ToString( "yyyyMMddHHmmssfff" ) ) ); + } + } + [Test] public void TestExt_DefaultContext() { - var context = NewSerializationContext( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.Default.DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); context.Serializers.Register( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); diff --git a/test/MsgPack.UnitTest/Serialization/ArrayGenerationBasedAutoMessagePackSerializerTest.cs b/test/MsgPack.UnitTest/Serialization/ArrayGenerationBasedAutoMessagePackSerializerTest.cs index 3b2e72e92..017eaba9a 100644 --- a/test/MsgPack.UnitTest/Serialization/ArrayGenerationBasedAutoMessagePackSerializerTest.cs +++ b/test/MsgPack.UnitTest/Serialization/ArrayGenerationBasedAutoMessagePackSerializerTest.cs @@ -92,12 +92,12 @@ private static SerializationContext GetSerializationContext() private static SerializationContext NewSerializationContext() { - return NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + return NewSerializationContext( SerializationCompatibilityLevel.Latest ); } - private static SerializationContext NewSerializationContext( PackerCompatibilityOptions compatibilityOptions, DateTimeConversionMethod dateTimeConversionMethod ) + private static SerializationContext NewSerializationContext( SerializationCompatibilityLevel compatibilityLevel ) { - var context = PreGeneratedSerializerActivator.CreateContext( SerializationMethod.Array, compatibilityOptions ); + var context = PreGeneratedSerializerActivator.CreateContext( SerializationMethod.Array, compatibilityLevel ); // Register serializers for abstract class testing context.Serializers.Register( new EchoKeyedCollection_2MessagePackSerializer( context, null ) @@ -204,10 +204,38 @@ public void TestDateTimeOffset() } [Test] - public void TestDateTimeNative() + public void TestDateTimeLatest() { TestCore( - DateTime.Now, + DateTime.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTime(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeOffsetLatest() + { + TestCore( + DateTimeOffset.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTimeOffset(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeClassic0_9() + { + TestCore( + DateTime.Now, // Use now because Native mode should serialize its kind stream => DateTime.FromBinary( Unpacking.UnpackInt64( stream ) ), ( x, y ) => x.Equals( y ), context => @@ -218,10 +246,10 @@ public void TestDateTimeNative() } [Test] - public void TestDateTimeOffsetNative() + public void TestDateTimeOffsetClassic0_9() { TestCore( - DateTimeOffset.Now, + DateTimeOffset.Now, // Use now because Native mode should serialize its kind stream => { var array = Unpacking.UnpackArray( stream ); @@ -236,7 +264,7 @@ public void TestDateTimeOffsetNative() } [Test] - public void TestDateTimeClassic() + public void TestDateTimeClassic0_5() { TestCore( DateTime.UtcNow, @@ -250,7 +278,7 @@ public void TestDateTimeClassic() } [Test] - public void TestDateTimeOffsetClassic() + public void TestDateTimeOffsetClassic0_5() { TestCore( DateTimeOffset.UtcNow, @@ -573,7 +601,8 @@ public void TestCharArrayContent() [Test] public void TestEmptyBytes() { - var serializer = this.CreateTarget( GetSerializationContext() ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { serializer.Pack( stream, new byte[ 0 ] ); @@ -584,9 +613,9 @@ public void TestEmptyBytes() } [Test] - public void TestEmptyBytes_Classic() + public void TestEmptyBytes_Classic0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -597,6 +626,20 @@ public void TestEmptyBytes_Classic() } } + [Test] + public void TestEmptyBytes_Classic0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = this.CreateTarget( context ); + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[ 0 ] ); + Assert.That( stream.Length, Is.EqualTo( 2 ), BitConverter.ToString( stream.ToArray() ) ); + stream.Position = 0; + Assert.That( serializer.Unpack( stream ), Is.EqualTo( new byte[ 0 ] ) ); + } + } + [Test] public void TestEmptyString() { @@ -1021,9 +1064,9 @@ public void TestIDictionaryValueType_Success() } [Test] - public void TestExt_ClassicContext() + public void TestExt_ClassicContext0_5() { - var context = NewSerializationContext( SerializationContext.CreateClassicContext().CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.CreateClassicContext().DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); context.Serializers.RegisterOverride( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); @@ -1037,10 +1080,27 @@ public void TestExt_ClassicContext() } } + [Test] + public void TestExt_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + context.Serializers.Register( new CustomDateTimeSerealizer() ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + var date = DateTime.UtcNow; + serializer.Pack( stream, date ); + stream.Position = 0; + var unpacked = serializer.Unpack( stream ); + Assert.That( unpacked.ToString( "yyyyMMddHHmmssfff" ), Is.EqualTo( date.ToString( "yyyyMMddHHmmssfff" ) ) ); + } + } + [Test] public void TestExt_DefaultContext() { - var context = NewSerializationContext( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.Default.DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); context.Serializers.Register( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); diff --git a/test/MsgPack.UnitTest/Serialization/ArrayReflectionBasedAutoMessagePackSerializerTest.cs b/test/MsgPack.UnitTest/Serialization/ArrayReflectionBasedAutoMessagePackSerializerTest.cs index c4a01a855..91c43e82e 100644 --- a/test/MsgPack.UnitTest/Serialization/ArrayReflectionBasedAutoMessagePackSerializerTest.cs +++ b/test/MsgPack.UnitTest/Serialization/ArrayReflectionBasedAutoMessagePackSerializerTest.cs @@ -92,13 +92,13 @@ private static SerializationContext GetSerializationContext() private static SerializationContext NewSerializationContext() { - return NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + return NewSerializationContext( SerializationCompatibilityLevel.Latest ); } - private static SerializationContext NewSerializationContext( PackerCompatibilityOptions compatibilityOptions, DateTimeConversionMethod dateTimeConversionMethod ) + private static SerializationContext NewSerializationContext( SerializationCompatibilityLevel compatibilityLevel ) { - var context = new SerializationContext( compatibilityOptions ) { SerializationMethod = SerializationMethod.Array }; - context.DefaultDateTimeConversionMethod = dateTimeConversionMethod; + var context = SerializationContext.CreateClassicContext( compatibilityLevel ); + context.SerializationMethod = SerializationMethod.Array; context.SerializerOptions.EmitterFlavor = EmitterFlavor.ReflectionBased; #if SILVERLIGHT && !SILVERLIGHT_PRIVILEGED context.SerializerOptions.DisablePrivilegedAccess = true; @@ -278,10 +278,38 @@ public void TestDateTimeOffset() } [Test] - public void TestDateTimeNative() + public void TestDateTimeLatest() + { + TestCore( + DateTime.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTime(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeOffsetLatest() + { + TestCore( + DateTimeOffset.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTimeOffset(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeClassic0_9() { TestCore( - DateTime.Now, + DateTime.Now, // Use now because Native mode should serialize its kind stream => DateTime.FromBinary( Unpacking.UnpackInt64( stream ) ), ( x, y ) => x.Equals( y ), context => @@ -292,10 +320,10 @@ public void TestDateTimeNative() } [Test] - public void TestDateTimeOffsetNative() + public void TestDateTimeOffsetClassic0_9() { TestCore( - DateTimeOffset.Now, + DateTimeOffset.Now, // Use now because Native mode should serialize its kind stream => { var array = Unpacking.UnpackArray( stream ); @@ -310,7 +338,7 @@ public void TestDateTimeOffsetNative() } [Test] - public void TestDateTimeClassic() + public void TestDateTimeClassic0_5() { TestCore( DateTime.UtcNow, @@ -324,7 +352,7 @@ public void TestDateTimeClassic() } [Test] - public void TestDateTimeOffsetClassic() + public void TestDateTimeOffsetClassic0_5() { TestCore( DateTimeOffset.UtcNow, @@ -1468,7 +1496,8 @@ private async Task TestTupleAsyncCore( T expected, int arity ) [Test] public void TestEmptyBytes() { - var serializer = this.CreateTarget( GetSerializationContext() ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { serializer.Pack( stream, new byte[ 0 ] ); @@ -1479,9 +1508,9 @@ public void TestEmptyBytes() } [Test] - public void TestEmptyBytes_Classic() + public void TestEmptyBytes_Classic0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -1492,6 +1521,20 @@ public void TestEmptyBytes_Classic() } } + [Test] + public void TestEmptyBytes_Classic0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = this.CreateTarget( context ); + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[ 0 ] ); + Assert.That( stream.Length, Is.EqualTo( 2 ), BitConverter.ToString( stream.ToArray() ) ); + stream.Position = 0; + Assert.That( serializer.Unpack( stream ), Is.EqualTo( new byte[ 0 ] ) ); + } + } + [Test] public void TestEmptyString() { @@ -4380,10 +4423,10 @@ public void TestFullPackableUnpackable_PackToMessageAndUnpackFromMessageUsed() #endif // FEATURE_TAP [Test] - public void TestBinary_ClassicContext() + public void TestBinary_ClassicContext0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); - var serializer = context.GetSerializer(); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -4392,10 +4435,37 @@ public void TestBinary_ClassicContext() } } + [Test] + public void TestBinary_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) );; + } + } + + [Test] + public void TestBinary_DefaultContext() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) ); + } + } + [Test] public void TestBinary_ContextWithPackerCompatilibyOptionsNone() { - var context = NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + context.CompatibilityOptions.PackerCompatibilityOptions = PackerCompatibilityOptions.None; var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) @@ -4405,9 +4475,9 @@ public void TestBinary_ContextWithPackerCompatilibyOptionsNone() } } [Test] - public void TestExt_ClassicContext() + public void TestExt_ClassicContext0_5() { - var context = NewSerializationContext( SerializationContext.CreateClassicContext().CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.CreateClassicContext().DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); context.Serializers.RegisterOverride( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); @@ -4421,10 +4491,27 @@ public void TestExt_ClassicContext() } } + [Test] + public void TestExt_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + context.Serializers.Register( new CustomDateTimeSerealizer() ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + var date = DateTime.UtcNow; + serializer.Pack( stream, date ); + stream.Position = 0; + var unpacked = serializer.Unpack( stream ); + Assert.That( unpacked.ToString( "yyyyMMddHHmmssfff" ), Is.EqualTo( date.ToString( "yyyyMMddHHmmssfff" ) ) ); + } + } + [Test] public void TestExt_DefaultContext() { - var context = NewSerializationContext( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.Default.DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); context.Serializers.Register( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); diff --git a/test/MsgPack.UnitTest/Serialization/AutoMessagePackSerializerTest.ttinclude b/test/MsgPack.UnitTest/Serialization/AutoMessagePackSerializerTest.ttinclude index 6f1d80413..8a00a2592 100644 --- a/test/MsgPack.UnitTest/Serialization/AutoMessagePackSerializerTest.ttinclude +++ b/test/MsgPack.UnitTest/Serialization/AutoMessagePackSerializerTest.ttinclude @@ -150,17 +150,17 @@ namespace MsgPack.Serialization private static SerializationContext NewSerializationContext() { - return NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + return NewSerializationContext( SerializationCompatibilityLevel.Latest ); } - private static SerializationContext NewSerializationContext( PackerCompatibilityOptions compatibilityOptions, DateTimeConversionMethod dateTimeConversionMethod ) + private static SerializationContext NewSerializationContext( SerializationCompatibilityLevel compatibilityLevel ) { <#+ if ( !forIos ) { #> - var context = new SerializationContext( compatibilityOptions ) { SerializationMethod = SerializationMethod.<#= serializationMethod #> }; - context.DefaultDateTimeConversionMethod = dateTimeConversionMethod; + var context = SerializationContext.CreateClassicContext( compatibilityLevel ); + context.SerializationMethod = SerializationMethod.<#= serializationMethod #>; context.SerializerOptions.EmitterFlavor = EmitterFlavor.<#= emitterFlavor #>; #if SILVERLIGHT && !SILVERLIGHT_PRIVILEGED context.SerializerOptions.DisablePrivilegedAccess = true; @@ -171,7 +171,7 @@ namespace MsgPack.Serialization else { #> - var context = PreGeneratedSerializerActivator.CreateContext( SerializationMethod.Array, compatibilityOptions ); + var context = PreGeneratedSerializerActivator.CreateContext( SerializationMethod.Array, compatibilityLevel ); // Register serializers for abstract class testing context.Serializers.Register( new EchoKeyedCollection_2MessagePackSerializer( context, null ) @@ -370,10 +370,38 @@ namespace MsgPack.Serialization } [Test] - public void TestDateTimeNative() + public void TestDateTimeLatest() { TestCore( - DateTime.Now, + DateTime.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTime(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeOffsetLatest() + { + TestCore( + DateTimeOffset.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTimeOffset(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeClassic0_9() + { + TestCore( + DateTime.Now, // Use now because Native mode should serialize its kind stream => DateTime.FromBinary( Unpacking.UnpackInt64( stream ) ), ( x, y ) => x.Equals( y ), context => @@ -384,10 +412,10 @@ namespace MsgPack.Serialization } [Test] - public void TestDateTimeOffsetNative() + public void TestDateTimeOffsetClassic0_9() { TestCore( - DateTimeOffset.Now, + DateTimeOffset.Now, // Use now because Native mode should serialize its kind stream => { var array = Unpacking.UnpackArray( stream ); @@ -402,7 +430,7 @@ namespace MsgPack.Serialization } [Test] - public void TestDateTimeClassic() + public void TestDateTimeClassic0_5() { TestCore( DateTime.UtcNow, @@ -416,7 +444,7 @@ namespace MsgPack.Serialization } [Test] - public void TestDateTimeOffsetClassic() + public void TestDateTimeOffsetClassic0_5() { TestCore( DateTimeOffset.UtcNow, @@ -1517,7 +1545,8 @@ namespace MsgPack.Serialization [Test] public void TestEmptyBytes() { - var serializer = this.CreateTarget( GetSerializationContext() ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { serializer.Pack( stream, new byte[ 0 ] ); @@ -1528,9 +1557,9 @@ namespace MsgPack.Serialization } [Test] - public void TestEmptyBytes_Classic() + public void TestEmptyBytes_Classic0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -1541,6 +1570,20 @@ namespace MsgPack.Serialization } } + [Test] + public void TestEmptyBytes_Classic0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = this.CreateTarget( context ); + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[ 0 ] ); + Assert.That( stream.Length, Is.EqualTo( 2 ), BitConverter.ToString( stream.ToArray() ) ); + stream.Position = 0; + Assert.That( serializer.Unpack( stream ), Is.EqualTo( new byte[ 0 ] ) ); + } + } + [Test] public void TestEmptyString() { @@ -2600,10 +2643,10 @@ namespace MsgPack.Serialization #endif // FEATURE_TAP [Test] - public void TestBinary_ClassicContext() + public void TestBinary_ClassicContext0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); - var serializer = context.GetSerializer(); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -2612,10 +2655,37 @@ namespace MsgPack.Serialization } } + [Test] + public void TestBinary_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) );; + } + } + + [Test] + public void TestBinary_DefaultContext() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) ); + } + } + [Test] public void TestBinary_ContextWithPackerCompatilibyOptionsNone() { - var context = NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + context.CompatibilityOptions.PackerCompatibilityOptions = PackerCompatibilityOptions.None; var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) @@ -2628,9 +2698,9 @@ namespace MsgPack.Serialization } #> [Test] - public void TestExt_ClassicContext() + public void TestExt_ClassicContext0_5() { - var context = NewSerializationContext( SerializationContext.CreateClassicContext().CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.CreateClassicContext().DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); context.Serializers.RegisterOverride( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); @@ -2644,10 +2714,27 @@ namespace MsgPack.Serialization } } + [Test] + public void TestExt_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + context.Serializers.Register( new CustomDateTimeSerealizer() ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + var date = DateTime.UtcNow; + serializer.Pack( stream, date ); + stream.Position = 0; + var unpacked = serializer.Unpack( stream ); + Assert.That( unpacked.ToString( "yyyyMMddHHmmssfff" ), Is.EqualTo( date.ToString( "yyyyMMddHHmmssfff" ) ) ); + } + } + [Test] public void TestExt_DefaultContext() { - var context = NewSerializationContext( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.Default.DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); context.Serializers.Register( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); diff --git a/test/MsgPack.UnitTest/Serialization/MapFieldBasedAutoMessagePackSerializerTest.cs b/test/MsgPack.UnitTest/Serialization/MapFieldBasedAutoMessagePackSerializerTest.cs index 80af2f0c9..70a4e2fa9 100644 --- a/test/MsgPack.UnitTest/Serialization/MapFieldBasedAutoMessagePackSerializerTest.cs +++ b/test/MsgPack.UnitTest/Serialization/MapFieldBasedAutoMessagePackSerializerTest.cs @@ -93,13 +93,13 @@ private static SerializationContext GetSerializationContext() private static SerializationContext NewSerializationContext() { - return NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + return NewSerializationContext( SerializationCompatibilityLevel.Latest ); } - private static SerializationContext NewSerializationContext( PackerCompatibilityOptions compatibilityOptions, DateTimeConversionMethod dateTimeConversionMethod ) + private static SerializationContext NewSerializationContext( SerializationCompatibilityLevel compatibilityLevel ) { - var context = new SerializationContext( compatibilityOptions ) { SerializationMethod = SerializationMethod.Map }; - context.DefaultDateTimeConversionMethod = dateTimeConversionMethod; + var context = SerializationContext.CreateClassicContext( compatibilityLevel ); + context.SerializationMethod = SerializationMethod.Map; context.SerializerOptions.EmitterFlavor = EmitterFlavor.FieldBased; #if SILVERLIGHT && !SILVERLIGHT_PRIVILEGED context.SerializerOptions.DisablePrivilegedAccess = true; @@ -279,10 +279,38 @@ public void TestDateTimeOffset() } [Test] - public void TestDateTimeNative() + public void TestDateTimeLatest() + { + TestCore( + DateTime.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTime(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeOffsetLatest() + { + TestCore( + DateTimeOffset.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTimeOffset(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeClassic0_9() { TestCore( - DateTime.Now, + DateTime.Now, // Use now because Native mode should serialize its kind stream => DateTime.FromBinary( Unpacking.UnpackInt64( stream ) ), ( x, y ) => x.Equals( y ), context => @@ -293,10 +321,10 @@ public void TestDateTimeNative() } [Test] - public void TestDateTimeOffsetNative() + public void TestDateTimeOffsetClassic0_9() { TestCore( - DateTimeOffset.Now, + DateTimeOffset.Now, // Use now because Native mode should serialize its kind stream => { var array = Unpacking.UnpackArray( stream ); @@ -311,7 +339,7 @@ public void TestDateTimeOffsetNative() } [Test] - public void TestDateTimeClassic() + public void TestDateTimeClassic0_5() { TestCore( DateTime.UtcNow, @@ -325,7 +353,7 @@ public void TestDateTimeClassic() } [Test] - public void TestDateTimeOffsetClassic() + public void TestDateTimeOffsetClassic0_5() { TestCore( DateTimeOffset.UtcNow, @@ -1469,7 +1497,8 @@ private async Task TestTupleAsyncCore( T expected, int arity ) [Test] public void TestEmptyBytes() { - var serializer = this.CreateTarget( GetSerializationContext() ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { serializer.Pack( stream, new byte[ 0 ] ); @@ -1480,9 +1509,9 @@ public void TestEmptyBytes() } [Test] - public void TestEmptyBytes_Classic() + public void TestEmptyBytes_Classic0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -1493,6 +1522,20 @@ public void TestEmptyBytes_Classic() } } + [Test] + public void TestEmptyBytes_Classic0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = this.CreateTarget( context ); + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[ 0 ] ); + Assert.That( stream.Length, Is.EqualTo( 2 ), BitConverter.ToString( stream.ToArray() ) ); + stream.Position = 0; + Assert.That( serializer.Unpack( stream ), Is.EqualTo( new byte[ 0 ] ) ); + } + } + [Test] public void TestEmptyString() { @@ -4457,10 +4500,10 @@ public void TestFullPackableUnpackable_PackToMessageAndUnpackFromMessageUsed() #endif // FEATURE_TAP [Test] - public void TestBinary_ClassicContext() + public void TestBinary_ClassicContext0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); - var serializer = context.GetSerializer(); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -4469,10 +4512,37 @@ public void TestBinary_ClassicContext() } } + [Test] + public void TestBinary_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) );; + } + } + + [Test] + public void TestBinary_DefaultContext() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) ); + } + } + [Test] public void TestBinary_ContextWithPackerCompatilibyOptionsNone() { - var context = NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + context.CompatibilityOptions.PackerCompatibilityOptions = PackerCompatibilityOptions.None; var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) @@ -4482,9 +4552,9 @@ public void TestBinary_ContextWithPackerCompatilibyOptionsNone() } } [Test] - public void TestExt_ClassicContext() + public void TestExt_ClassicContext0_5() { - var context = NewSerializationContext( SerializationContext.CreateClassicContext().CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.CreateClassicContext().DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); context.Serializers.RegisterOverride( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); @@ -4498,10 +4568,27 @@ public void TestExt_ClassicContext() } } + [Test] + public void TestExt_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + context.Serializers.Register( new CustomDateTimeSerealizer() ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + var date = DateTime.UtcNow; + serializer.Pack( stream, date ); + stream.Position = 0; + var unpacked = serializer.Unpack( stream ); + Assert.That( unpacked.ToString( "yyyyMMddHHmmssfff" ), Is.EqualTo( date.ToString( "yyyyMMddHHmmssfff" ) ) ); + } + } + [Test] public void TestExt_DefaultContext() { - var context = NewSerializationContext( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.Default.DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); context.Serializers.Register( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); diff --git a/test/MsgPack.UnitTest/Serialization/MapGenerationBasedAutoMessagePackSerializerTest.cs b/test/MsgPack.UnitTest/Serialization/MapGenerationBasedAutoMessagePackSerializerTest.cs index 1ed3ee3dd..4dc4485b9 100644 --- a/test/MsgPack.UnitTest/Serialization/MapGenerationBasedAutoMessagePackSerializerTest.cs +++ b/test/MsgPack.UnitTest/Serialization/MapGenerationBasedAutoMessagePackSerializerTest.cs @@ -92,12 +92,12 @@ private static SerializationContext GetSerializationContext() private static SerializationContext NewSerializationContext() { - return NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + return NewSerializationContext( SerializationCompatibilityLevel.Latest ); } - private static SerializationContext NewSerializationContext( PackerCompatibilityOptions compatibilityOptions, DateTimeConversionMethod dateTimeConversionMethod ) + private static SerializationContext NewSerializationContext( SerializationCompatibilityLevel compatibilityLevel ) { - var context = PreGeneratedSerializerActivator.CreateContext( SerializationMethod.Array, compatibilityOptions ); + var context = PreGeneratedSerializerActivator.CreateContext( SerializationMethod.Array, compatibilityLevel ); // Register serializers for abstract class testing context.Serializers.Register( new EchoKeyedCollection_2MessagePackSerializer( context, null ) @@ -204,10 +204,38 @@ public void TestDateTimeOffset() } [Test] - public void TestDateTimeNative() + public void TestDateTimeLatest() { TestCore( - DateTime.Now, + DateTime.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTime(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeOffsetLatest() + { + TestCore( + DateTimeOffset.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTimeOffset(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeClassic0_9() + { + TestCore( + DateTime.Now, // Use now because Native mode should serialize its kind stream => DateTime.FromBinary( Unpacking.UnpackInt64( stream ) ), ( x, y ) => x.Equals( y ), context => @@ -218,10 +246,10 @@ public void TestDateTimeNative() } [Test] - public void TestDateTimeOffsetNative() + public void TestDateTimeOffsetClassic0_9() { TestCore( - DateTimeOffset.Now, + DateTimeOffset.Now, // Use now because Native mode should serialize its kind stream => { var array = Unpacking.UnpackArray( stream ); @@ -236,7 +264,7 @@ public void TestDateTimeOffsetNative() } [Test] - public void TestDateTimeClassic() + public void TestDateTimeClassic0_5() { TestCore( DateTime.UtcNow, @@ -250,7 +278,7 @@ public void TestDateTimeClassic() } [Test] - public void TestDateTimeOffsetClassic() + public void TestDateTimeOffsetClassic0_5() { TestCore( DateTimeOffset.UtcNow, @@ -573,7 +601,8 @@ public void TestCharArrayContent() [Test] public void TestEmptyBytes() { - var serializer = this.CreateTarget( GetSerializationContext() ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { serializer.Pack( stream, new byte[ 0 ] ); @@ -584,9 +613,9 @@ public void TestEmptyBytes() } [Test] - public void TestEmptyBytes_Classic() + public void TestEmptyBytes_Classic0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -597,6 +626,20 @@ public void TestEmptyBytes_Classic() } } + [Test] + public void TestEmptyBytes_Classic0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = this.CreateTarget( context ); + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[ 0 ] ); + Assert.That( stream.Length, Is.EqualTo( 2 ), BitConverter.ToString( stream.ToArray() ) ); + stream.Position = 0; + Assert.That( serializer.Unpack( stream ), Is.EqualTo( new byte[ 0 ] ) ); + } + } + [Test] public void TestEmptyString() { @@ -1021,9 +1064,9 @@ public void TestIDictionaryValueType_Success() } [Test] - public void TestExt_ClassicContext() + public void TestExt_ClassicContext0_5() { - var context = NewSerializationContext( SerializationContext.CreateClassicContext().CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.CreateClassicContext().DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); context.Serializers.RegisterOverride( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); @@ -1037,10 +1080,27 @@ public void TestExt_ClassicContext() } } + [Test] + public void TestExt_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + context.Serializers.Register( new CustomDateTimeSerealizer() ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + var date = DateTime.UtcNow; + serializer.Pack( stream, date ); + stream.Position = 0; + var unpacked = serializer.Unpack( stream ); + Assert.That( unpacked.ToString( "yyyyMMddHHmmssfff" ), Is.EqualTo( date.ToString( "yyyyMMddHHmmssfff" ) ) ); + } + } + [Test] public void TestExt_DefaultContext() { - var context = NewSerializationContext( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.Default.DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); context.Serializers.Register( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); diff --git a/test/MsgPack.UnitTest/Serialization/MapReflectionBasedAutoMessagePackSerializerTest.cs b/test/MsgPack.UnitTest/Serialization/MapReflectionBasedAutoMessagePackSerializerTest.cs index 2fbeb31fb..6a694ebe0 100644 --- a/test/MsgPack.UnitTest/Serialization/MapReflectionBasedAutoMessagePackSerializerTest.cs +++ b/test/MsgPack.UnitTest/Serialization/MapReflectionBasedAutoMessagePackSerializerTest.cs @@ -93,13 +93,13 @@ private static SerializationContext GetSerializationContext() private static SerializationContext NewSerializationContext() { - return NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + return NewSerializationContext( SerializationCompatibilityLevel.Latest ); } - private static SerializationContext NewSerializationContext( PackerCompatibilityOptions compatibilityOptions, DateTimeConversionMethod dateTimeConversionMethod ) + private static SerializationContext NewSerializationContext( SerializationCompatibilityLevel compatibilityLevel ) { - var context = new SerializationContext( compatibilityOptions ) { SerializationMethod = SerializationMethod.Map }; - context.DefaultDateTimeConversionMethod = dateTimeConversionMethod; + var context = SerializationContext.CreateClassicContext( compatibilityLevel ); + context.SerializationMethod = SerializationMethod.Map; context.SerializerOptions.EmitterFlavor = EmitterFlavor.ReflectionBased; #if SILVERLIGHT && !SILVERLIGHT_PRIVILEGED context.SerializerOptions.DisablePrivilegedAccess = true; @@ -279,10 +279,38 @@ public void TestDateTimeOffset() } [Test] - public void TestDateTimeNative() + public void TestDateTimeLatest() + { + TestCore( + DateTime.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTime(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeOffsetLatest() + { + TestCore( + DateTimeOffset.UtcNow, + stream => Timestamp.Decode( Unpacking.UnpackExtendedTypeObject( stream ) ).ToDateTimeOffset(), + ( x, y ) => x.Equals( y ), + context => + { + context.DefaultDateTimeConversionMethod = DateTimeConversionMethod.Timestamp; + } + ); + } + + [Test] + public void TestDateTimeClassic0_9() { TestCore( - DateTime.Now, + DateTime.Now, // Use now because Native mode should serialize its kind stream => DateTime.FromBinary( Unpacking.UnpackInt64( stream ) ), ( x, y ) => x.Equals( y ), context => @@ -293,10 +321,10 @@ public void TestDateTimeNative() } [Test] - public void TestDateTimeOffsetNative() + public void TestDateTimeOffsetClassic0_9() { TestCore( - DateTimeOffset.Now, + DateTimeOffset.Now, // Use now because Native mode should serialize its kind stream => { var array = Unpacking.UnpackArray( stream ); @@ -311,7 +339,7 @@ public void TestDateTimeOffsetNative() } [Test] - public void TestDateTimeClassic() + public void TestDateTimeClassic0_5() { TestCore( DateTime.UtcNow, @@ -325,7 +353,7 @@ public void TestDateTimeClassic() } [Test] - public void TestDateTimeOffsetClassic() + public void TestDateTimeOffsetClassic0_5() { TestCore( DateTimeOffset.UtcNow, @@ -1469,7 +1497,8 @@ private async Task TestTupleAsyncCore( T expected, int arity ) [Test] public void TestEmptyBytes() { - var serializer = this.CreateTarget( GetSerializationContext() ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { serializer.Pack( stream, new byte[ 0 ] ); @@ -1480,9 +1509,9 @@ public void TestEmptyBytes() } [Test] - public void TestEmptyBytes_Classic() + public void TestEmptyBytes_Classic0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); var serializer = this.CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -1493,6 +1522,20 @@ public void TestEmptyBytes_Classic() } } + [Test] + public void TestEmptyBytes_Classic0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = this.CreateTarget( context ); + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[ 0 ] ); + Assert.That( stream.Length, Is.EqualTo( 2 ), BitConverter.ToString( stream.ToArray() ) ); + stream.Position = 0; + Assert.That( serializer.Unpack( stream ), Is.EqualTo( new byte[ 0 ] ) ); + } + } + [Test] public void TestEmptyString() { @@ -4457,10 +4500,10 @@ public void TestFullPackableUnpackable_PackToMessageAndUnpackFromMessageUsed() #endif // FEATURE_TAP [Test] - public void TestBinary_ClassicContext() + public void TestBinary_ClassicContext0_5() { - var context = NewSerializationContext( PackerCompatibilityOptions.Classic, DateTimeConversionMethod.Native ); - var serializer = context.GetSerializer(); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) { @@ -4469,10 +4512,37 @@ public void TestBinary_ClassicContext() } } + [Test] + public void TestBinary_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) );; + } + } + + [Test] + public void TestBinary_DefaultContext() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + serializer.Pack( stream, new byte[] { 1 } ); + Assert.That( stream.ToArray(), Is.EqualTo( new byte[] { MessagePackCode.Bin8, 1, 1 } ) ); + } + } + [Test] public void TestBinary_ContextWithPackerCompatilibyOptionsNone() { - var context = NewSerializationContext( PackerCompatibilityOptions.None, DateTimeConversionMethod.Timestamp ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); + context.CompatibilityOptions.PackerCompatibilityOptions = PackerCompatibilityOptions.None; var serializer = CreateTarget( context ); using ( var stream = new MemoryStream() ) @@ -4482,9 +4552,9 @@ public void TestBinary_ContextWithPackerCompatilibyOptionsNone() } } [Test] - public void TestExt_ClassicContext() + public void TestExt_ClassicContext0_5() { - var context = NewSerializationContext( SerializationContext.CreateClassicContext().CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.CreateClassicContext().DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_5 ); context.Serializers.RegisterOverride( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); @@ -4498,10 +4568,27 @@ public void TestExt_ClassicContext() } } + [Test] + public void TestExt_ClassicContext0_9() + { + var context = NewSerializationContext( SerializationCompatibilityLevel.Version0_9 ); + context.Serializers.Register( new CustomDateTimeSerealizer() ); + var serializer = CreateTarget( context ); + + using ( var stream = new MemoryStream() ) + { + var date = DateTime.UtcNow; + serializer.Pack( stream, date ); + stream.Position = 0; + var unpacked = serializer.Unpack( stream ); + Assert.That( unpacked.ToString( "yyyyMMddHHmmssfff" ), Is.EqualTo( date.ToString( "yyyyMMddHHmmssfff" ) ) ); + } + } + [Test] public void TestExt_DefaultContext() { - var context = NewSerializationContext( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, SerializationContext.Default.DefaultDateTimeConversionMethod ); + var context = NewSerializationContext( SerializationCompatibilityLevel.Latest ); context.Serializers.Register( new CustomDateTimeSerealizer() ); var serializer = CreateTarget( context ); diff --git a/test/MsgPack.UnitTest/Serialization/PreGeneratedSerializerActivator.cs b/test/MsgPack.UnitTest/Serialization/PreGeneratedSerializerActivator.cs index f091126da..199f0d883 100644 --- a/test/MsgPack.UnitTest/Serialization/PreGeneratedSerializerActivator.cs +++ b/test/MsgPack.UnitTest/Serialization/PreGeneratedSerializerActivator.cs @@ -1,4 +1,4 @@ -#region -- License Terms -- +#region -- License Terms -- // // MessagePack for CLI // @@ -105,6 +105,28 @@ public static SerializationContext CreateContext( SerializationMethod method, Pa context.Serializers.Register( entry.Key, entry.Value, null, null, SerializerRegistrationOptions.None ); } +#if !AOT + context.SerializerOptions.DisableRuntimeCodeGeneration = true; +#endif // !AOT + return context; + } + + /// + /// Creates new for generation based testing. + /// + /// . + /// for built-in serializers. + /// A new for generation based testing. + public static SerializationContext CreateContext( SerializationMethod method, SerializationCompatibilityLevel compatibilityLevel ) + { + var context = SerializationContext.CreateClassicContext( compatibilityLevel ); + context.SerializationMethod = method; + + foreach ( var entry in _serializers ) + { + context.Serializers.Register( entry.Key, entry.Value, null, null, SerializerRegistrationOptions.None ); + } + #if !AOT context.SerializerOptions.DisableRuntimeCodeGeneration = true; #endif // !AOT diff --git a/test/MsgPack.UnitTest/Serialization/RegressionTests.cs b/test/MsgPack.UnitTest/Serialization/RegressionTests.cs index 65bdf4434..ed4cad3ac 100644 --- a/test/MsgPack.UnitTest/Serialization/RegressionTests.cs +++ b/test/MsgPack.UnitTest/Serialization/RegressionTests.cs @@ -83,7 +83,7 @@ public void TestIssue70() [Test] public void TestIssue73() { - var original = SerializationContext.ConfigureClassic(); + var original = SerializationContext.ConfigureClassic( SerializationCompatibilityLevel.Version0_5 ); try { var value = diff --git a/test/MsgPack.UnitTest/Serialization/SerializationContextTest.cs b/test/MsgPack.UnitTest/Serialization/SerializationContextTest.cs index ded981b53..003396651 100644 --- a/test/MsgPack.UnitTest/Serialization/SerializationContextTest.cs +++ b/test/MsgPack.UnitTest/Serialization/SerializationContextTest.cs @@ -2,7 +2,7 @@ // // MessagePack for CLI // -// Copyright (C) 2010-2017 FUJIWARA, Yusuke +// Copyright (C) 2010-2018 FUJIWARA, Yusuke // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -213,11 +213,12 @@ public void TestDefault_SafeAndEasySettings() } [Test] - public void TestCreateClassicContext_Version0_5_Compatible() + public void TestCreateClassicContext_Version0_5_Version0_5_Compatible() { - var context = SerializationContext.CreateClassicContext(); + var context = SerializationContext.CreateClassicContext( SerializationCompatibilityLevel.Version0_5 ); Assert.That( context, Is.Not.Null ); Assert.That( context.DefaultDateTimeConversionMethod, Is.EqualTo( DateTimeConversionMethod.UnixEpoc ) ); + Assert.That( context.CompatibilityOptions.PackerCompatibilityOptions, Is.EqualTo( PackerCompatibilityOptions.Classic ) ); Assert.That( context.EnumSerializationOptions.SerializationMethod, Is.EqualTo( EnumSerializationMethod.ByName ) ); #if !AOT && !UNITY && !SILVERLIGHT Assert.That( context.SerializerOptions.GeneratorOption, Is.EqualTo( SerializationMethodGeneratorOption.Fast ) ); @@ -226,27 +227,29 @@ public void TestCreateClassicContext_Version0_5_Compatible() } [Test] - public void TestConfigureClassic_DefaultIsReplaced() + public void TestConfigureClassic_Version0_5_DefaultIsReplaced() { var previous = SerializationContext.Default; try { - var result = SerializationContext.ConfigureClassic(); + var result = SerializationContext.ConfigureClassic( SerializationCompatibilityLevel.Version0_5 ); // result is old. Assert.That( result, Is.SameAs( previous ) ); // result is default settings. Assert.That( result, Is.Not.Null ); Assert.That( result.DefaultDateTimeConversionMethod, Is.EqualTo( DateTimeConversionMethod.Timestamp ) ); + Assert.That( result.CompatibilityOptions.PackerCompatibilityOptions, Is.EqualTo( PackerCompatibilityOptions.None ) ); Assert.That( result.EnumSerializationOptions.SerializationMethod, Is.EqualTo( EnumSerializationMethod.ByName ) ); #if !AOT && !UNITY && !SILVERLIGHT Assert.That( result.SerializerOptions.GeneratorOption, Is.EqualTo( SerializationMethodGeneratorOption.Fast ) ); #endif // !AOT && !UNITY && !SILVERLIGHT Assert.That( result.SerializationMethod, Is.EqualTo( SerializationMethod.Array ) ); - // default is now classic + // default is now classic 0.5 Assert.That( SerializationContext.Default, Is.Not.Null ); Assert.That( SerializationContext.Default.DefaultDateTimeConversionMethod, Is.EqualTo( DateTimeConversionMethod.UnixEpoc ) ); + Assert.That( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, Is.EqualTo( PackerCompatibilityOptions.Classic ) ); Assert.That( SerializationContext.Default.EnumSerializationOptions.SerializationMethod, Is.EqualTo( EnumSerializationMethod.ByName ) ); #if !AOT && !UNITY && !SILVERLIGHT Assert.That( SerializationContext.Default.SerializerOptions.GeneratorOption, Is.EqualTo( SerializationMethodGeneratorOption.Fast ) ); @@ -260,6 +263,66 @@ public void TestConfigureClassic_DefaultIsReplaced() // Verify restore Assert.That( SerializationContext.Default.DefaultDateTimeConversionMethod, Is.EqualTo( DateTimeConversionMethod.Timestamp ) ); + Assert.That( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, Is.EqualTo( PackerCompatibilityOptions.None ) ); + Assert.That( SerializationContext.Default.EnumSerializationOptions.SerializationMethod, Is.EqualTo( EnumSerializationMethod.ByName ) ); +#if !AOT && !UNITY && !SILVERLIGHT + Assert.That( SerializationContext.Default.SerializerOptions.GeneratorOption, Is.EqualTo( SerializationMethodGeneratorOption.Fast ) ); +#endif // !AOT && !UNITY && !SILVERLIGHT + Assert.That( SerializationContext.Default.SerializationMethod, Is.EqualTo( SerializationMethod.Array ) ); + } + + [Test] + public void TestCreateClassicContext_Version0_9_Version0_9_Compatible() + { + var context = SerializationContext.CreateClassicContext( SerializationCompatibilityLevel.Version0_9 ); + Assert.That( context, Is.Not.Null ); + Assert.That( context.DefaultDateTimeConversionMethod, Is.EqualTo( DateTimeConversionMethod.Native ) ); + Assert.That( context.CompatibilityOptions.PackerCompatibilityOptions, Is.EqualTo( PackerCompatibilityOptions.None ) ); + Assert.That( context.EnumSerializationOptions.SerializationMethod, Is.EqualTo( EnumSerializationMethod.ByName ) ); +#if !AOT && !UNITY && !SILVERLIGHT + Assert.That( context.SerializerOptions.GeneratorOption, Is.EqualTo( SerializationMethodGeneratorOption.Fast ) ); +#endif // !AOT && !UNITY && !SILVERLIGHT + Assert.That( context.SerializationMethod, Is.EqualTo( SerializationMethod.Array ) ); + } + + [Test] + public void TestConfigureClassic_Version0_9_DefaultIsReplaced() + { + var previous = SerializationContext.Default; + try + { + var result = SerializationContext.ConfigureClassic( SerializationCompatibilityLevel.Version0_9 ); + + // result is old. + Assert.That( result, Is.SameAs( previous ) ); + // result is default settings. + Assert.That( result, Is.Not.Null ); + Assert.That( result.DefaultDateTimeConversionMethod, Is.EqualTo( DateTimeConversionMethod.Timestamp ) ); + Assert.That( result.CompatibilityOptions.PackerCompatibilityOptions, Is.EqualTo( PackerCompatibilityOptions.None ) ); + Assert.That( result.EnumSerializationOptions.SerializationMethod, Is.EqualTo( EnumSerializationMethod.ByName ) ); +#if !AOT && !UNITY && !SILVERLIGHT + Assert.That( result.SerializerOptions.GeneratorOption, Is.EqualTo( SerializationMethodGeneratorOption.Fast ) ); +#endif // !AOT && !UNITY && !SILVERLIGHT + Assert.That( result.SerializationMethod, Is.EqualTo( SerializationMethod.Array ) ); + + // default is now classic 0.9 + Assert.That( SerializationContext.Default, Is.Not.Null ); + Assert.That( SerializationContext.Default.DefaultDateTimeConversionMethod, Is.EqualTo( DateTimeConversionMethod.Native ) ); + Assert.That( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, Is.EqualTo( PackerCompatibilityOptions.None ) ); + Assert.That( SerializationContext.Default.EnumSerializationOptions.SerializationMethod, Is.EqualTo( EnumSerializationMethod.ByName ) ); +#if !AOT && !UNITY && !SILVERLIGHT + Assert.That( SerializationContext.Default.SerializerOptions.GeneratorOption, Is.EqualTo( SerializationMethodGeneratorOption.Fast ) ); +#endif // !AOT && !UNITY && !SILVERLIGHT + Assert.That( SerializationContext.Default.SerializationMethod, Is.EqualTo( SerializationMethod.Array ) ); + } + finally + { + SerializationContext.Default = previous; + } + + // Verify restore + Assert.That( SerializationContext.Default.DefaultDateTimeConversionMethod, Is.EqualTo( DateTimeConversionMethod.Timestamp ) ); + Assert.That( SerializationContext.Default.CompatibilityOptions.PackerCompatibilityOptions, Is.EqualTo( PackerCompatibilityOptions.None ) ); Assert.That( SerializationContext.Default.EnumSerializationOptions.SerializationMethod, Is.EqualTo( EnumSerializationMethod.ByName ) ); #if !AOT && !UNITY && !SILVERLIGHT Assert.That( SerializationContext.Default.SerializerOptions.GeneratorOption, Is.EqualTo( SerializationMethodGeneratorOption.Fast ) ); @@ -289,7 +352,7 @@ public void TestIssue27_Dictionary() var context = new SerializationContext(); using ( var buffer = new MemoryStream() ) { - var serializer = context.GetSerializer>(); + var serializer = context.GetSerializer>(); var dic = new Dictionary { { "A", "A" } }; serializer.Pack( buffer, dic ); buffer.Position = 0; @@ -307,7 +370,7 @@ public void TestIssue27_List() var context = new SerializationContext(); using ( var buffer = new MemoryStream() ) { - var serializer = context.GetSerializer>(); + var serializer = context.GetSerializer>(); var list = new List { "A" }; serializer.Pack( buffer, list ); buffer.Position = 0; @@ -619,7 +682,7 @@ public sealed class NewConcreteCollection : NewAbstractCollection { } - private sealed class StringKeyDictionary : Dictionary + private sealed class StringKeyDictionary : Dictionary { } diff --git a/test/MsgPack.UnitTest/Serialization/TimestampSerializationTest.cs b/test/MsgPack.UnitTest/Serialization/TimestampSerializationTest.cs index 2c5314f6a..8e1b6b269 100644 --- a/test/MsgPack.UnitTest/Serialization/TimestampSerializationTest.cs +++ b/test/MsgPack.UnitTest/Serialization/TimestampSerializationTest.cs @@ -151,15 +151,21 @@ private static void TestSerializationCore( SerializationContext context, DateTim } [Test] - public void TestSerialization_DefaultTimestamp() + public void TestSerialization_Default_Timestamp() { TestSerializationCore( new SerializationContext(), DateTimeConversionMethod.Timestamp ); } [Test] - public void TestSerialization_ClassicUnixEpoc() + public void TestSerialization_Classic0_5_UnixEpoc() { - TestSerializationCore( SerializationContext.CreateClassicContext(), DateTimeConversionMethod.UnixEpoc ); + TestSerializationCore( SerializationContext.CreateClassicContext( SerializationCompatibilityLevel.Version0_5 ), DateTimeConversionMethod.UnixEpoc ); + } + + [Test] + public void TestSerialization_Classic0_9_Native() + { + TestSerializationCore( SerializationContext.CreateClassicContext( SerializationCompatibilityLevel.Version0_9 ), DateTimeConversionMethod.Native ); } [Test] From 23dd3624f97f6db970aba4f3e650f4afccfc2e99 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sun, 9 Sep 2018 21:20:40 +0900 Subject: [PATCH 11/36] Fix CI settings to run release build on patching branches for future. --- appveyor-release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/appveyor-release.yml b/appveyor-release.yml index b763baea5..49dca6f53 100644 --- a/appveyor-release.yml +++ b/appveyor-release.yml @@ -3,9 +3,7 @@ image: Visual Studio 2017 branches: only: - master - - 0.7 - - 0.8 - - 0.9 + - /[0-9]+\.[0-9]+(\.[xX])?/ configuration: Release assembly_info: patch: true From b7ff7d2acb8adbeb3d30e5b72d147e267cbd81f9 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sun, 9 Sep 2018 22:47:40 +0900 Subject: [PATCH 12/36] Fix build script to generate symbol package correctly. --- build/Build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Build.ps1 b/build/Build.ps1 index 8f4e35827..c397399b9 100644 --- a/build/Build.ps1 +++ b/build/Build.ps1 @@ -158,7 +158,7 @@ if ( $buildConfig -eq 'Release' ) { Write-Host "Build NuGet packages..." - & $msbuild ../src/MsgPack/MsgPack.csproj /t:pack /v:minimal /p:Configuration=$buildConfig /p:IncludeSource=true /p:NuspecProperties=version=$env:PackageVersion + & $msbuild ../src/MsgPack/MsgPack.csproj /t:pack /v:minimal /p:Configuration=$buildConfig /p:IncludeSource=true /p:IncludeSymbols=true /p:NuspecProperties=version=$env:PackageVersion Move-Item ../bin/*.nupkg ../dist/ Copy-Item ../bin/* ./MsgPack-CLI/ -Recurse -Exclude @("*.vshost.*") From 883db14ca271b7a7af09b69b628a84e7468572f0 Mon Sep 17 00:00:00 2001 From: shimat Date: Tue, 30 Oct 2018 14:09:55 +0900 Subject: [PATCH 13/36] fix serlaization typo? --- ...Sample03_SerializationContextAndOptions.cs | 6 ++--- .../SerializerBuilder`2.Object.cs | 6 ++--- .../DictionaryKeyTransformers.cs | 2 +- ...s.cs => DictionarySerializationOptions.cs} | 6 ++--- .../Serialization/MessagePackSerializer`1.cs | 6 ++--- src/MsgPack/Serialization/PackHelpers.cs | 4 +-- ...ReflectionObjectMessagePackSerializer`1.cs | 14 +++++----- .../Serialization/SerializationContext.cs | 10 +++---- ...deDomBasedAutoMessagePackSerializerTest.cs | 24 ++++++++--------- .../AutoMessagePackSerializerTest.ttinclude | 24 ++++++++--------- ...FieldBasedAutoMessagePackSerializerTest.cs | 24 ++++++++--------- ...ctionBasedAutoMessagePackSerializerTest.cs | 26 +++++++++---------- 12 files changed, 76 insertions(+), 76 deletions(-) rename src/MsgPack/Serialization/{DictionarySerlaizationOptions.cs => DictionarySerializationOptions.cs} (96%) diff --git a/samples/Samples/Sample03_SerializationContextAndOptions.cs b/samples/Samples/Sample03_SerializationContextAndOptions.cs index 4ff2f1198..863b054c4 100644 --- a/samples/Samples/Sample03_SerializationContextAndOptions.cs +++ b/samples/Samples/Sample03_SerializationContextAndOptions.cs @@ -1,4 +1,4 @@ -#region -- License Terms -- +#region -- License Terms -- // // MessagePack for CLI // @@ -57,9 +57,9 @@ public void CustomizeSerializeBehavior() // 2-2-1. You can customize map key handling when you use SerializationMethod.Map to improve interoperability. // You can use preconfigured transformation in DictionaryKeyTransformers class. - context.DictionarySerlaizationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; + context.DictionarySerializationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; // 2-2-2. You can omit entry when map value is null. - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; // 2-3. EnumSerializationMethod: it changes enum serialization as their name or underlying value. // ByName(default): More version torrelant and interoperable, and backward compatible prior to 0.5 of MsgPack for CLI. diff --git a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Object.cs b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Object.cs index 05392bdd4..c58d9e452 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Object.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Object.cs @@ -572,7 +572,7 @@ knownActions[ i ].Value actionCollection.ContextType, "Item", // Set key as transformed. - this.MakeStringLiteral( context, context.SerializationContext.DictionarySerlaizationOptions.SafeKeyTransformer( knownActions[ i ].Key ) ), + this.MakeStringLiteral( context, context.SerializationContext.DictionarySerializationOptions.SafeKeyTransformer( knownActions[ i ].Key ) ), packItemBody ); } @@ -633,7 +633,7 @@ private IEnumerable EmitPackNullCheckerTableInitializationCore( TCon actionCollection.ContextType, "Item", // Set key as transformed. - this.MakeStringLiteral( context, context.SerializationContext.DictionarySerlaizationOptions.SafeKeyTransformer( knownActions[ i ].Key ) ), + this.MakeStringLiteral( context, context.SerializationContext.DictionarySerializationOptions.SafeKeyTransformer( knownActions[ i ].Key ) ), this.EmitNewPrivateMethodDelegateExpression( context, knownActions[ i ].Value @@ -1351,7 +1351,7 @@ knownActions[ i ].Value actionCollection.ContextType, "Item", // Set key as transformed. - this.MakeStringLiteral( context, context.SerializationContext.DictionarySerlaizationOptions.SafeKeyTransformer( knownActions[ i ].Key ) ), + this.MakeStringLiteral( context, context.SerializationContext.DictionarySerializationOptions.SafeKeyTransformer( knownActions[ i ].Key ) ), unpackItemBody ); } diff --git a/src/MsgPack/Serialization/DictionaryKeyTransformers.cs b/src/MsgPack/Serialization/DictionaryKeyTransformers.cs index 7b15970c5..b0f4df332 100644 --- a/src/MsgPack/Serialization/DictionaryKeyTransformers.cs +++ b/src/MsgPack/Serialization/DictionaryKeyTransformers.cs @@ -23,7 +23,7 @@ namespace MsgPack.Serialization { /// - /// Defines built-in, out-of-box handlers for . + /// Defines built-in, out-of-box handlers for . /// public static class DictionaryKeyTransformers { diff --git a/src/MsgPack/Serialization/DictionarySerlaizationOptions.cs b/src/MsgPack/Serialization/DictionarySerializationOptions.cs similarity index 96% rename from src/MsgPack/Serialization/DictionarySerlaizationOptions.cs rename to src/MsgPack/Serialization/DictionarySerializationOptions.cs index eff1977d5..0f5f86c18 100644 --- a/src/MsgPack/Serialization/DictionarySerlaizationOptions.cs +++ b/src/MsgPack/Serialization/DictionarySerializationOptions.cs @@ -35,7 +35,7 @@ namespace MsgPack.Serialization /// and . /// The option only affect dictionary (map) based serialization which can be enabled via . /// - public sealed class DictionarySerlaizationOptions + public sealed class DictionarySerializationOptions { #if !FEATURE_CONCURRENT private volatile bool _omitNullEntry; @@ -121,8 +121,8 @@ internal Func SafeKeyTransformer } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public DictionarySerlaizationOptions() { } + public DictionarySerializationOptions() { } } } diff --git a/src/MsgPack/Serialization/MessagePackSerializer`1.cs b/src/MsgPack/Serialization/MessagePackSerializer`1.cs index 8434bc622..3f19466d1 100644 --- a/src/MsgPack/Serialization/MessagePackSerializer`1.cs +++ b/src/MsgPack/Serialization/MessagePackSerializer`1.cs @@ -1,4 +1,4 @@ -#region -- License Terms -- +#region -- License Terms -- // // MessagePack for CLI // @@ -61,7 +61,7 @@ public abstract class MessagePackSerializer : MessagePackSerializer /// /// This method supports backword compatibility with 0.3. /// - [Obsolete( "Use MessagePackSerializer (SerlaizationContext) instead." )] + [Obsolete( "Use MessagePackSerializer (SerializationContext) instead." )] protected MessagePackSerializer() : this( PackerCompatibilityOptions.Classic ) { } /// @@ -71,7 +71,7 @@ protected MessagePackSerializer() : this( PackerCompatibilityOptions.Classic ) { /// /// This method supports backword compatibility with 0.4. /// - [Obsolete( "Use MessagePackSerializer (SerlaizationContext, PackerCompatibilityOptions) instead." )] + [Obsolete( "Use MessagePackSerializer (SerializationContext, PackerCompatibilityOptions) instead." )] protected MessagePackSerializer( PackerCompatibilityOptions packerCompatibilityOptions ) : this( null, packerCompatibilityOptions ) { } diff --git a/src/MsgPack/Serialization/PackHelpers.cs b/src/MsgPack/Serialization/PackHelpers.cs index 31d3da745..616aa4ab8 100644 --- a/src/MsgPack/Serialization/PackHelpers.cs +++ b/src/MsgPack/Serialization/PackHelpers.cs @@ -339,7 +339,7 @@ ref PackToMapParameters parameter #endif // ASSERT if ( parameter.NullCheckers != null - && parameter.SerializationContext != null && parameter.SerializationContext.DictionarySerlaizationOptions.OmitNullEntry ) + && parameter.SerializationContext != null && parameter.SerializationContext.DictionarySerializationOptions.OmitNullEntry ) { #if ASSERT Contract.Assert( !SerializerDebugging.UseLegacyNullMapEntryHandling ); @@ -487,7 +487,7 @@ CancellationToken cancellationToken #endif // ASSERT if ( nullCheckers != null - && serializationContext != null && serializationContext.DictionarySerlaizationOptions.OmitNullEntry ) + && serializationContext != null && serializationContext.DictionarySerializationOptions.OmitNullEntry ) { #if ASSERT Contract.Assert( !SerializerDebugging.UseLegacyNullMapEntryHandling ); diff --git a/src/MsgPack/Serialization/ReflectionSerializers/ReflectionObjectMessagePackSerializer`1.cs b/src/MsgPack/Serialization/ReflectionSerializers/ReflectionObjectMessagePackSerializer`1.cs index bb9656c32..bb060346c 100644 --- a/src/MsgPack/Serialization/ReflectionSerializers/ReflectionObjectMessagePackSerializer`1.cs +++ b/src/MsgPack/Serialization/ReflectionSerializers/ReflectionObjectMessagePackSerializer`1.cs @@ -66,7 +66,7 @@ public ReflectionObjectMessagePackSerializer( SerializationContext context, Seri .Select( ( contract, index ) => new KeyValuePair( contract.Name, index ) ) .Where( kv => kv.Key != null ) // Set key as transformed. - .ToDictionary( kv => context.DictionarySerlaizationOptions.SafeKeyTransformer( kv.Key ), kv => kv.Value ); + .ToDictionary( kv => context.DictionarySerializationOptions.SafeKeyTransformer( kv.Key ), kv => kv.Value ); this._constructorParameters = ( !typeof( IUnpackable ).IsAssignableFrom( typeof( T ) ) && target.IsConstructorDeserialization ) ? target.DeserializationConstructor.GetParameters() @@ -112,7 +112,7 @@ protected internal override void PackToCore( Packer packer, T objectTree ) } else { - if ( this.OwnerContext.DictionarySerlaizationOptions.OmitNullEntry + if ( this.OwnerContext.DictionarySerializationOptions.OmitNullEntry #if DEBUG && !SerializerDebugging.UseLegacyNullMapEntryHandling #endif // DEBUG @@ -138,7 +138,7 @@ protected internal override void PackToCore( Packer packer, T objectTree ) } // Set key as transformed. - packer.PackString( this.OwnerContext.DictionarySerlaizationOptions.SafeKeyTransformer( this._contracts[ i ].Name ) ); + packer.PackString( this.OwnerContext.DictionarySerializationOptions.SafeKeyTransformer( this._contracts[ i ].Name ) ); this.PackMemberValue( packer, objectTree, i ); } } @@ -148,7 +148,7 @@ protected internal override void PackToCore( Packer packer, T objectTree ) for ( int i = 0; i < this._serializers.Length; i++ ) { // Set key as transformed. - packer.PackString( this.OwnerContext.DictionarySerlaizationOptions.SafeKeyTransformer( this._contracts[ i ].Name ) ); + packer.PackString( this.OwnerContext.DictionarySerializationOptions.SafeKeyTransformer( this._contracts[ i ].Name ) ); this.PackMemberValue( packer, objectTree, i ); } } @@ -214,7 +214,7 @@ protected internal override async Task PackToAsyncCore( Packer packer, T objectT } else { - if ( this.OwnerContext.DictionarySerlaizationOptions.OmitNullEntry + if ( this.OwnerContext.DictionarySerializationOptions.OmitNullEntry #if DEBUG && !SerializerDebugging.UseLegacyNullMapEntryHandling #endif // DEBUG @@ -240,7 +240,7 @@ protected internal override async Task PackToAsyncCore( Packer packer, T objectT } // Set key as transformed. - await packer.PackStringAsync( this.OwnerContext.DictionarySerlaizationOptions.SafeKeyTransformer( this._contracts[ i ].Name ), cancellationToken ).ConfigureAwait( false ); + await packer.PackStringAsync( this.OwnerContext.DictionarySerializationOptions.SafeKeyTransformer( this._contracts[ i ].Name ), cancellationToken ).ConfigureAwait( false ); await this.PackMemberValueAsync( packer, objectTree, i, cancellationToken ).ConfigureAwait( false ); } } @@ -250,7 +250,7 @@ protected internal override async Task PackToAsyncCore( Packer packer, T objectT for ( int i = 0; i < this._serializers.Length; i++ ) { // Set key as transformed. - await packer.PackStringAsync( this.OwnerContext.DictionarySerlaizationOptions.SafeKeyTransformer( this._contracts[ i ].Name ), cancellationToken ).ConfigureAwait( false ); + await packer.PackStringAsync( this.OwnerContext.DictionarySerializationOptions.SafeKeyTransformer( this._contracts[ i ].Name ), cancellationToken ).ConfigureAwait( false ); await this.PackMemberValueAsync( packer, objectTree, i, cancellationToken ).ConfigureAwait( false ); } } diff --git a/src/MsgPack/Serialization/SerializationContext.cs b/src/MsgPack/Serialization/SerializationContext.cs index 1a91f72dd..1cdc1a564 100644 --- a/src/MsgPack/Serialization/SerializationContext.cs +++ b/src/MsgPack/Serialization/SerializationContext.cs @@ -196,20 +196,20 @@ public SerializationCompatibilityOptions CompatibilityOptions } } - private readonly DictionarySerlaizationOptions _dictionarySerializationOptions; + private readonly DictionarySerializationOptions _dictionarySerializationOptions; /// /// Gets the dictionary(map) based serialization options. /// /// - /// The which stores dictionary(map) based serialization options. This value will not be null. + /// The which stores dictionary(map) based serialization options. This value will not be null. /// - public DictionarySerlaizationOptions DictionarySerlaizationOptions + public DictionarySerializationOptions DictionarySerializationOptions { get { #if DEBUG - Contract.Ensures( Contract.Result() != null ); + Contract.Ensures( Contract.Result() != null ); #endif // DEBUG return this._dictionarySerializationOptions; @@ -561,7 +561,7 @@ public SerializationContext( PackerCompatibilityOptions packerCompatibilityOptio this._generationLock = new object(); this._defaultCollectionTypes = new DefaultConcreteTypeRepository(); this._serializerGeneratorOptions = new SerializerOptions(); - this._dictionarySerializationOptions = new DictionarySerlaizationOptions(); + this._dictionarySerializationOptions = new DictionarySerializationOptions(); this._enumSerializationOptions = new EnumSerializationOptions(); this._bindingOptions = new BindingOptions(); } diff --git a/test/MsgPack.UnitTest.CodeDom/Serialization/MapCodeDomBasedAutoMessagePackSerializerTest.cs b/test/MsgPack.UnitTest.CodeDom/Serialization/MapCodeDomBasedAutoMessagePackSerializerTest.cs index f7e10d905..4d83db4bd 100644 --- a/test/MsgPack.UnitTest.CodeDom/Serialization/MapCodeDomBasedAutoMessagePackSerializerTest.cs +++ b/test/MsgPack.UnitTest.CodeDom/Serialization/MapCodeDomBasedAutoMessagePackSerializerTest.cs @@ -9076,9 +9076,9 @@ public void TestImplementsNonGenericIEnumerableWithNoAdd_ProhibitEnumerableNonCo public void TestOmitNullEntryInDictionary() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.OmitNullEntry, Is.False, "default value" ); + Assert.That( context.DictionarySerializationOptions.OmitNullEntry, Is.False, "default value" ); TestOmitNullEntryInDictionaryCore( context, true, false ); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, false, false ); } @@ -9088,9 +9088,9 @@ public void TestOmitNullEntryInDictionary() public void TestOmitNullEntryInDictionary_Async() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.OmitNullEntry, Is.False, "default value" ); + Assert.That( context.DictionarySerializationOptions.OmitNullEntry, Is.False, "default value" ); TestOmitNullEntryInDictionaryCore( context, true, true ); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, false, true ); } @@ -9103,7 +9103,7 @@ public void TestOmitNullEntryInDictionary_BackwordCompatibility() try { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, true, false ); } finally @@ -9121,7 +9121,7 @@ public void TestOmitNullEntryInDictionary_BackwordCompatibility_Async() try { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, true, true ); } finally @@ -9195,7 +9195,7 @@ private static void TestOmitNullEntryInDictionaryCore( SerializationContext cont public void TestDictionaryKeyTransformer_Default_AsIs() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.KeyTransformer, Is.Null, "default value" ); + Assert.That( context.DictionarySerializationOptions.KeyTransformer, Is.Null, "default value" ); TestDictionaryKeyCore( context, "FirstProperty", "SecondProperty", "ThirdProperty", "FourthProperty", asIs: true, isAsync: false ); } @@ -9205,7 +9205,7 @@ public void TestDictionaryKeyTransformer_Default_AsIs() public void TestDictionaryKeyTransformer_Default_AsIs_Async() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.KeyTransformer, Is.Null, "default value" ); + Assert.That( context.DictionarySerializationOptions.KeyTransformer, Is.Null, "default value" ); TestDictionaryKeyCore( context, "FirstProperty", "SecondProperty", "ThirdProperty", "FourthProperty", asIs: true, isAsync: true ); } @@ -9215,7 +9215,7 @@ public void TestDictionaryKeyTransformer_Default_AsIs_Async() public void TestDictionaryKeyTransformer_LowerCamel() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; + context.DictionarySerializationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; TestDictionaryKeyCore( context, "firstProperty", "secondProperty", "thirdProperty", "fourthProperty", asIs: false, isAsync: false ); } @@ -9225,7 +9225,7 @@ public void TestDictionaryKeyTransformer_LowerCamel() public void TestDictionaryKeyTransformer_LowerCamel_Async() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; + context.DictionarySerializationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; TestDictionaryKeyCore( context, "firstProperty", "secondProperty", "thirdProperty", "fourthProperty", asIs: false, isAsync: true ); } @@ -9235,7 +9235,7 @@ public void TestDictionaryKeyTransformer_LowerCamel_Async() public void TestDictionaryKeyTransformer_Custom() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = + context.DictionarySerializationOptions.KeyTransformer = key => Regex.Replace( key, "[A-Z]", match => match.Index == 0 ? match.Value.ToLower() : "-" + match.Value.ToLower() ); TestDictionaryKeyCore( context, "first-property", "second-property", "third-property", "fourth-property", asIs: false, isAsync: false ); } @@ -9246,7 +9246,7 @@ public void TestDictionaryKeyTransformer_Custom() public void TestDictionaryKeyTransformer_Custom_Async() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = + context.DictionarySerializationOptions.KeyTransformer = key => Regex.Replace( key, "[A-Z]", match => match.Index == 0 ? match.Value.ToLower() : "-" + match.Value.ToLower() ); TestDictionaryKeyCore( context, "first-property", "second-property", "third-property", "fourth-property", asIs: false, isAsync: true ); } diff --git a/test/MsgPack.UnitTest/Serialization/AutoMessagePackSerializerTest.ttinclude b/test/MsgPack.UnitTest/Serialization/AutoMessagePackSerializerTest.ttinclude index 6f1d80413..4aa728d34 100644 --- a/test/MsgPack.UnitTest/Serialization/AutoMessagePackSerializerTest.ttinclude +++ b/test/MsgPack.UnitTest/Serialization/AutoMessagePackSerializerTest.ttinclude @@ -3798,9 +3798,9 @@ namespace MsgPack.Serialization public void TestOmitNullEntryInDictionary() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.OmitNullEntry, Is.False, "default value" ); + Assert.That( context.DictionarySerializationOptions.OmitNullEntry, Is.False, "default value" ); TestOmitNullEntryInDictionaryCore( context, true, false ); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, false, false ); } @@ -3810,9 +3810,9 @@ namespace MsgPack.Serialization public void TestOmitNullEntryInDictionary_Async() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.OmitNullEntry, Is.False, "default value" ); + Assert.That( context.DictionarySerializationOptions.OmitNullEntry, Is.False, "default value" ); TestOmitNullEntryInDictionaryCore( context, true, true ); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, false, true ); } @@ -3825,7 +3825,7 @@ namespace MsgPack.Serialization try { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, true, false ); } finally @@ -3843,7 +3843,7 @@ namespace MsgPack.Serialization try { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, true, true ); } finally @@ -3917,7 +3917,7 @@ namespace MsgPack.Serialization public void TestDictionaryKeyTransformer_Default_AsIs() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.KeyTransformer, Is.Null, "default value" ); + Assert.That( context.DictionarySerializationOptions.KeyTransformer, Is.Null, "default value" ); TestDictionaryKeyCore( context, "FirstProperty", "SecondProperty", "ThirdProperty", "FourthProperty", asIs: true, isAsync: false ); } @@ -3927,7 +3927,7 @@ namespace MsgPack.Serialization public void TestDictionaryKeyTransformer_Default_AsIs_Async() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.KeyTransformer, Is.Null, "default value" ); + Assert.That( context.DictionarySerializationOptions.KeyTransformer, Is.Null, "default value" ); TestDictionaryKeyCore( context, "FirstProperty", "SecondProperty", "ThirdProperty", "FourthProperty", asIs: true, isAsync: true ); } @@ -3937,7 +3937,7 @@ namespace MsgPack.Serialization public void TestDictionaryKeyTransformer_LowerCamel() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; + context.DictionarySerializationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; TestDictionaryKeyCore( context, "firstProperty", "secondProperty", "thirdProperty", "fourthProperty", asIs: false, isAsync: false ); } @@ -3947,7 +3947,7 @@ namespace MsgPack.Serialization public void TestDictionaryKeyTransformer_LowerCamel_Async() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; + context.DictionarySerializationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; TestDictionaryKeyCore( context, "firstProperty", "secondProperty", "thirdProperty", "fourthProperty", asIs: false, isAsync: true ); } @@ -3957,7 +3957,7 @@ namespace MsgPack.Serialization public void TestDictionaryKeyTransformer_Custom() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = + context.DictionarySerializationOptions.KeyTransformer = key => Regex.Replace( key, "[A-Z]", match => match.Index == 0 ? match.Value.ToLower() : "-" + match.Value.ToLower() ); TestDictionaryKeyCore( context, "first-property", "second-property", "third-property", "fourth-property", asIs: false, isAsync: false ); } @@ -3968,7 +3968,7 @@ namespace MsgPack.Serialization public void TestDictionaryKeyTransformer_Custom_Async() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = + context.DictionarySerializationOptions.KeyTransformer = key => Regex.Replace( key, "[A-Z]", match => match.Index == 0 ? match.Value.ToLower() : "-" + match.Value.ToLower() ); TestDictionaryKeyCore( context, "first-property", "second-property", "third-property", "fourth-property", asIs: false, isAsync: true ); } diff --git a/test/MsgPack.UnitTest/Serialization/MapFieldBasedAutoMessagePackSerializerTest.cs b/test/MsgPack.UnitTest/Serialization/MapFieldBasedAutoMessagePackSerializerTest.cs index 80af2f0c9..7d73e4d9d 100644 --- a/test/MsgPack.UnitTest/Serialization/MapFieldBasedAutoMessagePackSerializerTest.cs +++ b/test/MsgPack.UnitTest/Serialization/MapFieldBasedAutoMessagePackSerializerTest.cs @@ -9076,9 +9076,9 @@ public void TestImplementsNonGenericIEnumerableWithNoAdd_ProhibitEnumerableNonCo public void TestOmitNullEntryInDictionary() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.OmitNullEntry, Is.False, "default value" ); + Assert.That( context.DictionarySerializationOptions.OmitNullEntry, Is.False, "default value" ); TestOmitNullEntryInDictionaryCore( context, true, false ); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, false, false ); } @@ -9088,9 +9088,9 @@ public void TestOmitNullEntryInDictionary() public void TestOmitNullEntryInDictionary_Async() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.OmitNullEntry, Is.False, "default value" ); + Assert.That( context.DictionarySerializationOptions.OmitNullEntry, Is.False, "default value" ); TestOmitNullEntryInDictionaryCore( context, true, true ); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, false, true ); } @@ -9103,7 +9103,7 @@ public void TestOmitNullEntryInDictionary_BackwordCompatibility() try { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, true, false ); } finally @@ -9121,7 +9121,7 @@ public void TestOmitNullEntryInDictionary_BackwordCompatibility_Async() try { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, true, true ); } finally @@ -9195,7 +9195,7 @@ private static void TestOmitNullEntryInDictionaryCore( SerializationContext cont public void TestDictionaryKeyTransformer_Default_AsIs() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.KeyTransformer, Is.Null, "default value" ); + Assert.That( context.DictionarySerializationOptions.KeyTransformer, Is.Null, "default value" ); TestDictionaryKeyCore( context, "FirstProperty", "SecondProperty", "ThirdProperty", "FourthProperty", asIs: true, isAsync: false ); } @@ -9205,7 +9205,7 @@ public void TestDictionaryKeyTransformer_Default_AsIs() public void TestDictionaryKeyTransformer_Default_AsIs_Async() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.KeyTransformer, Is.Null, "default value" ); + Assert.That( context.DictionarySerializationOptions.KeyTransformer, Is.Null, "default value" ); TestDictionaryKeyCore( context, "FirstProperty", "SecondProperty", "ThirdProperty", "FourthProperty", asIs: true, isAsync: true ); } @@ -9215,7 +9215,7 @@ public void TestDictionaryKeyTransformer_Default_AsIs_Async() public void TestDictionaryKeyTransformer_LowerCamel() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; + context.DictionarySerializationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; TestDictionaryKeyCore( context, "firstProperty", "secondProperty", "thirdProperty", "fourthProperty", asIs: false, isAsync: false ); } @@ -9225,7 +9225,7 @@ public void TestDictionaryKeyTransformer_LowerCamel() public void TestDictionaryKeyTransformer_LowerCamel_Async() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; + context.DictionarySerializationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; TestDictionaryKeyCore( context, "firstProperty", "secondProperty", "thirdProperty", "fourthProperty", asIs: false, isAsync: true ); } @@ -9235,7 +9235,7 @@ public void TestDictionaryKeyTransformer_LowerCamel_Async() public void TestDictionaryKeyTransformer_Custom() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = + context.DictionarySerializationOptions.KeyTransformer = key => Regex.Replace( key, "[A-Z]", match => match.Index == 0 ? match.Value.ToLower() : "-" + match.Value.ToLower() ); TestDictionaryKeyCore( context, "first-property", "second-property", "third-property", "fourth-property", asIs: false, isAsync: false ); } @@ -9246,7 +9246,7 @@ public void TestDictionaryKeyTransformer_Custom() public void TestDictionaryKeyTransformer_Custom_Async() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = + context.DictionarySerializationOptions.KeyTransformer = key => Regex.Replace( key, "[A-Z]", match => match.Index == 0 ? match.Value.ToLower() : "-" + match.Value.ToLower() ); TestDictionaryKeyCore( context, "first-property", "second-property", "third-property", "fourth-property", asIs: false, isAsync: true ); } diff --git a/test/MsgPack.UnitTest/Serialization/MapReflectionBasedAutoMessagePackSerializerTest.cs b/test/MsgPack.UnitTest/Serialization/MapReflectionBasedAutoMessagePackSerializerTest.cs index 2fbeb31fb..c7fbaec1f 100644 --- a/test/MsgPack.UnitTest/Serialization/MapReflectionBasedAutoMessagePackSerializerTest.cs +++ b/test/MsgPack.UnitTest/Serialization/MapReflectionBasedAutoMessagePackSerializerTest.cs @@ -1,4 +1,4 @@ - + #region -- License Terms -- @@ -8977,9 +8977,9 @@ public void TestImplementsNonGenericIEnumerableWithNoAdd_ProhibitEnumerableNonCo public void TestOmitNullEntryInDictionary() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.OmitNullEntry, Is.False, "default value" ); + Assert.That( context.DictionarySerializationOptions.OmitNullEntry, Is.False, "default value" ); TestOmitNullEntryInDictionaryCore( context, true, false ); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, false, false ); } @@ -8989,9 +8989,9 @@ public void TestOmitNullEntryInDictionary() public void TestOmitNullEntryInDictionary_Async() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.OmitNullEntry, Is.False, "default value" ); + Assert.That( context.DictionarySerializationOptions.OmitNullEntry, Is.False, "default value" ); TestOmitNullEntryInDictionaryCore( context, true, true ); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, false, true ); } @@ -9004,7 +9004,7 @@ public void TestOmitNullEntryInDictionary_BackwordCompatibility() try { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, true, false ); } finally @@ -9022,7 +9022,7 @@ public void TestOmitNullEntryInDictionary_BackwordCompatibility_Async() try { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.OmitNullEntry = true; + context.DictionarySerializationOptions.OmitNullEntry = true; TestOmitNullEntryInDictionaryCore( context, true, true ); } finally @@ -9096,7 +9096,7 @@ private static void TestOmitNullEntryInDictionaryCore( SerializationContext cont public void TestDictionaryKeyTransformer_Default_AsIs() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.KeyTransformer, Is.Null, "default value" ); + Assert.That( context.DictionarySerializationOptions.KeyTransformer, Is.Null, "default value" ); TestDictionaryKeyCore( context, "FirstProperty", "SecondProperty", "ThirdProperty", "FourthProperty", asIs: true, isAsync: false ); } @@ -9106,7 +9106,7 @@ public void TestDictionaryKeyTransformer_Default_AsIs() public void TestDictionaryKeyTransformer_Default_AsIs_Async() { var context = GetSerializationContext(); - Assert.That( context.DictionarySerlaizationOptions.KeyTransformer, Is.Null, "default value" ); + Assert.That( context.DictionarySerializationOptions.KeyTransformer, Is.Null, "default value" ); TestDictionaryKeyCore( context, "FirstProperty", "SecondProperty", "ThirdProperty", "FourthProperty", asIs: true, isAsync: true ); } @@ -9116,7 +9116,7 @@ public void TestDictionaryKeyTransformer_Default_AsIs_Async() public void TestDictionaryKeyTransformer_LowerCamel() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; + context.DictionarySerializationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; TestDictionaryKeyCore( context, "firstProperty", "secondProperty", "thirdProperty", "fourthProperty", asIs: false, isAsync: false ); } @@ -9126,7 +9126,7 @@ public void TestDictionaryKeyTransformer_LowerCamel() public void TestDictionaryKeyTransformer_LowerCamel_Async() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; + context.DictionarySerializationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel; TestDictionaryKeyCore( context, "firstProperty", "secondProperty", "thirdProperty", "fourthProperty", asIs: false, isAsync: true ); } @@ -9136,7 +9136,7 @@ public void TestDictionaryKeyTransformer_LowerCamel_Async() public void TestDictionaryKeyTransformer_Custom() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = + context.DictionarySerializationOptions.KeyTransformer = key => Regex.Replace( key, "[A-Z]", match => match.Index == 0 ? match.Value.ToLower() : "-" + match.Value.ToLower() ); TestDictionaryKeyCore( context, "first-property", "second-property", "third-property", "fourth-property", asIs: false, isAsync: false ); } @@ -9147,7 +9147,7 @@ public void TestDictionaryKeyTransformer_Custom() public void TestDictionaryKeyTransformer_Custom_Async() { var context = GetSerializationContext(); - context.DictionarySerlaizationOptions.KeyTransformer = + context.DictionarySerializationOptions.KeyTransformer = key => Regex.Replace( key, "[A-Z]", match => match.Index == 0 ? match.Value.ToLower() : "-" + match.Value.ToLower() ); TestDictionaryKeyCore( context, "first-property", "second-property", "third-property", "fourth-property", asIs: false, isAsync: true ); } From 0e710141eb46badf1ef1a9f93431d3d88d94c402 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Thu, 1 Nov 2018 12:24:43 -0400 Subject: [PATCH 14/36] Add .NETStandard2.0 dependencies to NuGet packages --- MsgPack.nuspec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MsgPack.nuspec b/MsgPack.nuspec index 3a4062a4f..aa088e4d2 100644 --- a/MsgPack.nuspec +++ b/MsgPack.nuspec @@ -76,6 +76,12 @@ This package provides MessagePack serialization/deserialization APIs. This pacak + + + + + + @@ -89,4 +95,4 @@ This package provides MessagePack serialization/deserialization APIs. This pacak - \ No newline at end of file + From 0c609b2c6941e446364ae2d20a4be59b295563ee Mon Sep 17 00:00:00 2001 From: shimat Date: Fri, 9 Nov 2018 17:59:49 +0900 Subject: [PATCH 15/36] remain old name DictionarySerlaizationOptions --- .../Serialization/SerializationContext.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/MsgPack/Serialization/SerializationContext.cs b/src/MsgPack/Serialization/SerializationContext.cs index 1cdc1a564..44e2a375e 100644 --- a/src/MsgPack/Serialization/SerializationContext.cs +++ b/src/MsgPack/Serialization/SerializationContext.cs @@ -23,6 +23,7 @@ #endif using System; +using System.ComponentModel; #if !UNITY || MSGPACK_UNITY_FULL #endif // !UNITY || MSGPACK_UNITY_FULL #if FEATURE_CONCURRENT @@ -216,6 +217,28 @@ public DictionarySerializationOptions DictionarySerializationOptions } } + /// + /// Gets the dictionary(map) based serialization options. + /// + /// + /// The which stores dictionary(map) based serialization options. This value will not be null. + /// + [Obsolete("Use DictionarySerializationOption instead.")] +#if XAMARIN && ( __ANDROID__ || __IOS__ ) + [EditorBrowsable(EditorBrowsableState.Never)] +#endif + public DictionarySerializationOptions DictionarySerlaizationOptions + { + get + { +#if DEBUG + Contract.Ensures( Contract.Result() != null ); +#endif // DEBUG + + return this._dictionarySerializationOptions; + } + } + private int _serializationMethod; /// From 829661e67be807db926be39f702ce6f653d867f1 Mon Sep 17 00:00:00 2001 From: shimat Date: Wed, 14 Nov 2018 10:12:09 +0900 Subject: [PATCH 16/36] Run SyncProject.bat to synchronize added/removed files --- src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj | 10 +++++----- .../MsgPack.Silverlight.WindowsPhone.csproj | 10 +++++----- src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj | 10 +++++----- src/MsgPack.Unity/MsgPack.Unity.csproj | 10 +++++----- src/MsgPack.Uwp/MsgPack.Uwp.csproj | 10 +++++----- .../MsgPack.UnitTest.Silverlight.5.FullTrust.csproj | 3 +++ .../MsgPack.UnitTest.Silverlight.5.csproj | 3 +++ .../MsgPack.UnitTest.Silverlight.WindowsPhone.csproj | 3 +++ .../MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop.csproj | 3 +++ .../MsgPack.UnitTest.Uwp.Aot.csproj | 3 +++ test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj | 3 +++ .../MsgPack.UnitTest.WinRT.WindowsPhone.csproj | 6 ++++-- .../MsgPack.UnitTest.WinRT.csproj | 3 +++ .../MsgPack.UnitTest.Xamarin.Android.csproj | 6 ++++-- .../MsgPack.UnitTest.Xamarin.iOS.csproj | 3 +++ 15 files changed, 57 insertions(+), 29 deletions(-) diff --git a/src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj b/src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj index 45b5284a5..eee754480 100644 --- a/src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj +++ b/src/MsgPack.Silverlight.5/MsgPack.Silverlight.5.csproj @@ -245,6 +245,9 @@ Serialization\ReflectionExtensions.ConstructorDelegate.cs + + Serialization\BindingOptions.cs + Serialization\CollectionDetailedKind.cs @@ -455,8 +458,8 @@ Serialization\DictionaryKeyTransformers.cs - - Serialization\DictionarySerlaizationOptions.cs + + Serialization\DictionarySerializationOptions.cs Serialization\EmitterFlavor.cs @@ -673,9 +676,6 @@ Serialization\SerializationCompatibilityOptions.cs - - - Serialization\BindingOptions.cs Serialization\SerializationContext.cs diff --git a/src/MsgPack.Silverlight.WindowsPhone/MsgPack.Silverlight.WindowsPhone.csproj b/src/MsgPack.Silverlight.WindowsPhone/MsgPack.Silverlight.WindowsPhone.csproj index 399b5796f..da130b1c6 100644 --- a/src/MsgPack.Silverlight.WindowsPhone/MsgPack.Silverlight.WindowsPhone.csproj +++ b/src/MsgPack.Silverlight.WindowsPhone/MsgPack.Silverlight.WindowsPhone.csproj @@ -216,6 +216,9 @@ ReflectionAbstractions.cs + + Serialization\BindingOptions.cs + Serialization\CollectionDetailedKind.cs @@ -462,8 +465,8 @@ Serialization\DictionaryKeyTransformers.cs - - Serialization\DictionarySerlaizationOptions.cs + + Serialization\DictionarySerializationOptions.cs Serialization\EmitterFlavor.cs @@ -680,9 +683,6 @@ Serialization\SerializationCompatibilityOptions.cs - - - Serialization\BindingOptions.cs Serialization\SerializationContext.cs diff --git a/src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj b/src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj index 00a022cb8..67c693925 100644 --- a/src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj +++ b/src/MsgPack.Unity.Full/MsgPack.Unity.Full.csproj @@ -220,6 +220,9 @@ Serialization\Tracer.cs + + Serialization\BindingOptions.cs + Serialization\CollectionDetailedKind.cs @@ -436,8 +439,8 @@ Serialization\DictionaryKeyTransformers.cs - - Serialization\DictionarySerlaizationOptions.cs + + Serialization\DictionarySerializationOptions.cs Serialization\EmitterFlavor.cs @@ -651,9 +654,6 @@ Serialization\SerializationCompatibilityOptions.cs - - - Serialization\BindingOptions.cs Serialization\SerializationContext.cs diff --git a/src/MsgPack.Unity/MsgPack.Unity.csproj b/src/MsgPack.Unity/MsgPack.Unity.csproj index 53ca4e7a3..40927b6fa 100644 --- a/src/MsgPack.Unity/MsgPack.Unity.csproj +++ b/src/MsgPack.Unity/MsgPack.Unity.csproj @@ -234,13 +234,13 @@ ReflectionAbstractions.cs - - - Serialization\BindingOptions.cs Serialization\Tracer.cs + + Serialization\BindingOptions.cs + Serialization\CollectionDetailedKind.cs @@ -445,8 +445,8 @@ Serialization\DictionaryKeyTransformers.cs - - Serialization\DictionarySerlaizationOptions.cs + + Serialization\DictionarySerializationOptions.cs Serialization\EmitterFlavor.cs diff --git a/src/MsgPack.Uwp/MsgPack.Uwp.csproj b/src/MsgPack.Uwp/MsgPack.Uwp.csproj index f32d07373..473792780 100644 --- a/src/MsgPack.Uwp/MsgPack.Uwp.csproj +++ b/src/MsgPack.Uwp/MsgPack.Uwp.csproj @@ -244,6 +244,9 @@ ReflectionAbstractions.cs + + Serialization\BindingOptions.cs + Serialization\CollectionDetailedKind.cs @@ -505,8 +508,8 @@ Serialization\DictionaryKeyTransformers.cs - - Serialization\DictionarySerlaizationOptions.cs + + Serialization\DictionarySerializationOptions.cs Serialization\EmitterFlavor.cs @@ -723,9 +726,6 @@ Serialization\SerializationCompatibilityOptions.cs - - - Serialization\BindingOptions.cs Serialization\SerializationContext.cs diff --git a/test/MsgPack.UnitTest.Silverlight.5.FullTrust/MsgPack.UnitTest.Silverlight.5.FullTrust.csproj b/test/MsgPack.UnitTest.Silverlight.5.FullTrust/MsgPack.UnitTest.Silverlight.5.FullTrust.csproj index ae00ef81f..d1b79c9db 100644 --- a/test/MsgPack.UnitTest.Silverlight.5.FullTrust/MsgPack.UnitTest.Silverlight.5.FullTrust.csproj +++ b/test/MsgPack.UnitTest.Silverlight.5.FullTrust/MsgPack.UnitTest.Silverlight.5.FullTrust.csproj @@ -136,6 +136,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.Silverlight.5/MsgPack.UnitTest.Silverlight.5.csproj b/test/MsgPack.UnitTest.Silverlight.5/MsgPack.UnitTest.Silverlight.5.csproj index 4ec3ed4d8..68a03a547 100644 --- a/test/MsgPack.UnitTest.Silverlight.5/MsgPack.UnitTest.Silverlight.5.csproj +++ b/test/MsgPack.UnitTest.Silverlight.5/MsgPack.UnitTest.Silverlight.5.csproj @@ -121,6 +121,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.Silverlight.WindowsPhone/MsgPack.UnitTest.Silverlight.WindowsPhone.csproj b/test/MsgPack.UnitTest.Silverlight.WindowsPhone/MsgPack.UnitTest.Silverlight.WindowsPhone.csproj index b799f51f8..a9c359ebe 100644 --- a/test/MsgPack.UnitTest.Silverlight.WindowsPhone/MsgPack.UnitTest.Silverlight.WindowsPhone.csproj +++ b/test/MsgPack.UnitTest.Silverlight.WindowsPhone/MsgPack.UnitTest.Silverlight.WindowsPhone.csproj @@ -99,6 +99,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop.csproj b/test/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop.csproj index c32f912e9..253381245 100644 --- a/test/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop.csproj +++ b/test/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop/MsgPack.UnitTest.Unity.Il2cpp.Full.Desktop.csproj @@ -442,6 +442,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.Uwp.Aot/MsgPack.UnitTest.Uwp.Aot.csproj b/test/MsgPack.UnitTest.Uwp.Aot/MsgPack.UnitTest.Uwp.Aot.csproj index ac6872671..bed3a2487 100644 --- a/test/MsgPack.UnitTest.Uwp.Aot/MsgPack.UnitTest.Uwp.Aot.csproj +++ b/test/MsgPack.UnitTest.Uwp.Aot/MsgPack.UnitTest.Uwp.Aot.csproj @@ -1551,6 +1551,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj b/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj index 081f56673..d3ec2abe9 100644 --- a/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj +++ b/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp.csproj @@ -1533,6 +1533,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.WinRT.WindowsPhone/MsgPack.UnitTest.WinRT.WindowsPhone.csproj b/test/MsgPack.UnitTest.WinRT.WindowsPhone/MsgPack.UnitTest.WinRT.WindowsPhone.csproj index 3aca36e1c..07981094b 100644 --- a/test/MsgPack.UnitTest.WinRT.WindowsPhone/MsgPack.UnitTest.WinRT.WindowsPhone.csproj +++ b/test/MsgPack.UnitTest.WinRT.WindowsPhone/MsgPack.UnitTest.WinRT.WindowsPhone.csproj @@ -22,8 +22,7 @@ - - + $(DefineConstants);NETFX_CORE;WINDOWS_PHONE_APP;NETSTANDARD1_1;FEATURE_TAP;MSTEST ;2008 @@ -122,6 +121,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.WinRT/MsgPack.UnitTest.WinRT.csproj b/test/MsgPack.UnitTest.WinRT/MsgPack.UnitTest.WinRT.csproj index e0e54b445..84ed4aab3 100644 --- a/test/MsgPack.UnitTest.WinRT/MsgPack.UnitTest.WinRT.csproj +++ b/test/MsgPack.UnitTest.WinRT/MsgPack.UnitTest.WinRT.csproj @@ -127,6 +127,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs diff --git a/test/MsgPack.UnitTest.Xamarin.Android/MsgPack.UnitTest.Xamarin.Android.csproj b/test/MsgPack.UnitTest.Xamarin.Android/MsgPack.UnitTest.Xamarin.Android.csproj index 286251f05..a7e8ea4cd 100644 --- a/test/MsgPack.UnitTest.Xamarin.Android/MsgPack.UnitTest.Xamarin.Android.csproj +++ b/test/MsgPack.UnitTest.Xamarin.Android/MsgPack.UnitTest.Xamarin.Android.csproj @@ -58,6 +58,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs @@ -259,11 +262,10 @@ TestRandom.cs - - + Designer diff --git a/test/MsgPack.UnitTest.Xamarin.iOS/MsgPack.UnitTest.Xamarin.iOS.csproj b/test/MsgPack.UnitTest.Xamarin.iOS/MsgPack.UnitTest.Xamarin.iOS.csproj index 5fb06be4c..3619a69a6 100644 --- a/test/MsgPack.UnitTest.Xamarin.iOS/MsgPack.UnitTest.Xamarin.iOS.csproj +++ b/test/MsgPack.UnitTest.Xamarin.iOS/MsgPack.UnitTest.Xamarin.iOS.csproj @@ -58,6 +58,9 @@ MessagePackExtendedTypeObjectTest.cs + + MessagePackMemberSkipTest.cs + MessagePackObjectDictionaryTest.cs From 1f0bba94545f1d4e915df3e9fea538d5a100ee05 Mon Sep 17 00:00:00 2001 From: shimat Date: Wed, 14 Nov 2018 10:55:43 +0900 Subject: [PATCH 17/36] fixed #if directive of DictionarySerializationOptions --- src/MsgPack/Serialization/SerializationContext.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/MsgPack/Serialization/SerializationContext.cs b/src/MsgPack/Serialization/SerializationContext.cs index 44e2a375e..c02b375aa 100644 --- a/src/MsgPack/Serialization/SerializationContext.cs +++ b/src/MsgPack/Serialization/SerializationContext.cs @@ -23,7 +23,6 @@ #endif using System; -using System.ComponentModel; #if !UNITY || MSGPACK_UNITY_FULL #endif // !UNITY || MSGPACK_UNITY_FULL #if FEATURE_CONCURRENT @@ -224,8 +223,8 @@ public DictionarySerializationOptions DictionarySerializationOptions /// The which stores dictionary(map) based serialization options. This value will not be null. /// [Obsolete("Use DictionarySerializationOption instead.")] -#if XAMARIN && ( __ANDROID__ || __IOS__ ) - [EditorBrowsable(EditorBrowsableState.Never)] +#if !UNITY && !( XAMARIN && ( __ANDROID__ || __IOS__ ) ) + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] #endif public DictionarySerializationOptions DictionarySerlaizationOptions { From 93bfff8b58553ed6255e5d550c9edfcb99dc9369 Mon Sep 17 00:00:00 2001 From: shimat Date: Mon, 19 Nov 2018 10:19:44 +0900 Subject: [PATCH 18/36] use #if MSGPACK_UNITY_FULL --- src/MsgPack/Serialization/SerializationContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/MsgPack/Serialization/SerializationContext.cs b/src/MsgPack/Serialization/SerializationContext.cs index c02b375aa..db2b2f48e 100644 --- a/src/MsgPack/Serialization/SerializationContext.cs +++ b/src/MsgPack/Serialization/SerializationContext.cs @@ -24,6 +24,7 @@ using System; #if !UNITY || MSGPACK_UNITY_FULL +using System.ComponentModel; #endif // !UNITY || MSGPACK_UNITY_FULL #if FEATURE_CONCURRENT using System.Collections.Concurrent; @@ -223,8 +224,8 @@ public DictionarySerializationOptions DictionarySerializationOptions /// The which stores dictionary(map) based serialization options. This value will not be null. /// [Obsolete("Use DictionarySerializationOption instead.")] -#if !UNITY && !( XAMARIN && ( __ANDROID__ || __IOS__ ) ) - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] +#if !UNITY || MSGPACK_UNITY_FULL + [EditorBrowsable(EditorBrowsableState.Never)] #endif public DictionarySerializationOptions DictionarySerlaizationOptions { From 4ca7dd6d87a77a629e93f235afac77ac996773b2 Mon Sep 17 00:00:00 2001 From: Teddy LE BRAS Date: Wed, 5 Jun 2019 16:21:12 +0200 Subject: [PATCH 19/36] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bbf89204a..f84d6b047 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ serializer.Pack(stream, obj) Dim unpackedObject = serializer.Unpack(stream) ``` -**For production environment, you should instantiate own `SerializationCOntext` and manage its lifetime. It is good idea to treat it as singleton because `SerializationContext` is thread-safe.** +**For production environment, you should instantiate own `SerializationContext` and manage its lifetime. It is good idea to treat it as singleton because `SerializationContext` is thread-safe.** ## Features From a983c2399afc6ed8225b7dc4afe8316acb6eea43 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Mon, 27 May 2019 20:40:24 +0900 Subject: [PATCH 20/36] Fix default buffering strategy for stream deserialization to prevent discarding unpacking data. #321 For detailed information, see #321 comment. --- src/MsgPack/PackerUnpackerStreamOptions.cs | 12 ++++++++- .../Serialization/MessagePackSerializer`1.cs | 4 +-- .../Serialization/RegressionTests.cs | 26 +++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/MsgPack/PackerUnpackerStreamOptions.cs b/src/MsgPack/PackerUnpackerStreamOptions.cs index 71a1bf8f5..9500851db 100644 --- a/src/MsgPack/PackerUnpackerStreamOptions.cs +++ b/src/MsgPack/PackerUnpackerStreamOptions.cs @@ -82,9 +82,19 @@ private static bool ShouldWrapStream( Stream stream ) #else internal #endif - static readonly PackerUnpackerStreamOptions SingletonForAsync = + static readonly PackerUnpackerStreamOptions SingletonForAsyncPacking = + // It is OK for serialize to do buffering because we explicitly call FlushAsync for it. new PackerUnpackerStreamOptions { OwnsStream = true, WithBuffering = true }; + #if UNITY && DEBUG + public +#else + internal +#endif + static readonly PackerUnpackerStreamOptions SingletonForAsyncUnpacking = + // Buffering causes data loss in deserialization because buffered bytes will be gone in a tail of Deserialize(Stream) call. + new PackerUnpackerStreamOptions { OwnsStream = true, WithBuffering = false }; + #if UNITY && DEBUG public #else diff --git a/src/MsgPack/Serialization/MessagePackSerializer`1.cs b/src/MsgPack/Serialization/MessagePackSerializer`1.cs index 3f19466d1..3bebc04a7 100644 --- a/src/MsgPack/Serialization/MessagePackSerializer`1.cs +++ b/src/MsgPack/Serialization/MessagePackSerializer`1.cs @@ -219,7 +219,7 @@ public Task PackAsync( Stream stream, T objectTree ) /// public async Task PackAsync( Stream stream, T objectTree, CancellationToken cancellationToken ) { - var packer = Packer.Create( stream, this.PackerCompatibilityOptions, PackerUnpackerStreamOptions.SingletonForAsync ); + var packer = Packer.Create( stream, this.PackerCompatibilityOptions, PackerUnpackerStreamOptions.SingletonForAsyncPacking ); try { await this.PackToAsync( packer, objectTree, cancellationToken ).ConfigureAwait( false ); @@ -324,7 +324,7 @@ public Task UnpackAsync( Stream stream ) public async Task UnpackAsync( Stream stream, CancellationToken cancellationToken ) { // Unpacker does not have finalizer, so just avoiding unpacker disposing prevents stream closing. - var unpacker = Unpacker.Create( stream, PackerUnpackerStreamOptions.SingletonForAsync, DefaultUnpackerOptions ); + var unpacker = Unpacker.Create( stream, PackerUnpackerStreamOptions.SingletonForAsyncUnpacking, DefaultUnpackerOptions ); if ( !( await unpacker.ReadAsync( cancellationToken ).ConfigureAwait( false ) ) ) { SerializationExceptions.ThrowUnexpectedEndOfStream( unpacker ); diff --git a/test/MsgPack.UnitTest/Serialization/RegressionTests.cs b/test/MsgPack.UnitTest/Serialization/RegressionTests.cs index ed4cad3ac..bd61a93b6 100644 --- a/test/MsgPack.UnitTest/Serialization/RegressionTests.cs +++ b/test/MsgPack.UnitTest/Serialization/RegressionTests.cs @@ -547,5 +547,31 @@ public void TestIssue269() var forString = Assert.Throws( () => target.AsString() ); Assert.That( forString.Message, Is.EqualTo( "Do not convert MsgPack.MessagePackExtendedTypeObject MessagePackObject to System.String." ) ); } + +#if FEATURE_TAP + [Test] + public async Task TestIssue321_AsyncBuffering() + { + var context = new SerializationContext(); + var serializer = context.GetSerializer(); + using ( var stream = new MyMemoryStream() ) // could also be a NetworkStream or PipeStream + { + await serializer.PackAsync( stream, "hello" ); + TestContext.WriteLine( $"1. Stream now in {stream.Position}" ); + await serializer.PackAsync( stream, "world" ); + TestContext.WriteLine( $"2. Stream now in {stream.Position}" ); + TestContext.WriteLine( Binary.ToHexString( stream.ToArray() ) ); + stream.Position = 0; + var result1 = await serializer.UnpackAsync( stream ); + TestContext.WriteLine( $"3. Stream now in {stream.Position} -> {result1}" ); + var result2 = await serializer.UnpackAsync( stream ); // throws MsgPack.InvalidMessagePackStreamException + TestContext.WriteLine( $"4. Stream now in {stream.Position} -> {result2}" ); + } + } +#endif // FEATURE_TAP + + public class MyMemoryStream : MemoryStream + { + } } } From b9b6991d9345850eae2b4921e997ba6049ae77aa Mon Sep 17 00:00:00 2001 From: yfakariya Date: Tue, 16 Jul 2019 23:51:30 +0900 Subject: [PATCH 21/36] Fix unit test build failure in some targets This commit removes verbose console logging via TestContext which is not supported in some platforms. --- test/MsgPack.UnitTest/Serialization/RegressionTests.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test/MsgPack.UnitTest/Serialization/RegressionTests.cs b/test/MsgPack.UnitTest/Serialization/RegressionTests.cs index bd61a93b6..ee6330f33 100644 --- a/test/MsgPack.UnitTest/Serialization/RegressionTests.cs +++ b/test/MsgPack.UnitTest/Serialization/RegressionTests.cs @@ -554,18 +554,14 @@ public async Task TestIssue321_AsyncBuffering() { var context = new SerializationContext(); var serializer = context.GetSerializer(); - using ( var stream = new MyMemoryStream() ) // could also be a NetworkStream or PipeStream + using ( var stream = new MyMemoryStream() ) { await serializer.PackAsync( stream, "hello" ); - TestContext.WriteLine( $"1. Stream now in {stream.Position}" ); await serializer.PackAsync( stream, "world" ); - TestContext.WriteLine( $"2. Stream now in {stream.Position}" ); - TestContext.WriteLine( Binary.ToHexString( stream.ToArray() ) ); stream.Position = 0; var result1 = await serializer.UnpackAsync( stream ); - TestContext.WriteLine( $"3. Stream now in {stream.Position} -> {result1}" ); - var result2 = await serializer.UnpackAsync( stream ); // throws MsgPack.InvalidMessagePackStreamException - TestContext.WriteLine( $"4. Stream now in {stream.Position} -> {result2}" ); + // Ensure no exceptions are thrown. + var result2 = await serializer.UnpackAsync( stream ); } } #endif // FEATURE_TAP From 96aff4d02f196455d45895d2229dd326fa38d63a Mon Sep 17 00:00:00 2001 From: yfakariya Date: Wed, 17 Jul 2019 23:29:39 +0900 Subject: [PATCH 22/36] Add -codedom.yml to avoid CI timeout --- appveyor-debug-codedom.yml | 39 ++++++++++++++++++++++++++++++++++ build/RunUnitTests-CodeDOM.cmd | 8 +++++++ build/RunUnitTests.cmd | 2 -- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 appveyor-debug-codedom.yml create mode 100644 build/RunUnitTests-CodeDOM.cmd diff --git a/appveyor-debug-codedom.yml b/appveyor-debug-codedom.yml new file mode 100644 index 000000000..d4aebb8cc --- /dev/null +++ b/appveyor-debug-codedom.yml @@ -0,0 +1,39 @@ +version: '{branch}-{build}' +image: Visual Studio 2017 +skip_tags: true +configuration: Debug +assembly_info: + patch: true + file: '**\*AssemblyInfo.cs' + assembly_version: $(AssemblyBaseVersion).0 + assembly_file_version: $(AssemblyBaseVersion).{build} + assembly_informational_version: $(PackageVersion) +environment: + XamarinMSBuildExtensionsPath: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild +install: +- cmd: >- + cd .\build +- ps: >- + ./SetBuildEnv.ps1 + + cd .. +build_script: +- ps: >- + Write-Host "Configuration=${env:CONFIGURATION}" + + cd ./build + + ./Build.ps1 + + if ( $LastExitCode -ne 0 ) + { + Write-Error "Failed to build." + exit 1 + } + + cd .. +test_script: +- cmd: >- + cd ./build + + ./RunUnitTests-CodeDOM.cmd diff --git a/build/RunUnitTests-CodeDOM.cmd b/build/RunUnitTests-CodeDOM.cmd new file mode 100644 index 000000000..4274d15f5 --- /dev/null +++ b/build/RunUnitTests-CodeDOM.cmd @@ -0,0 +1,8 @@ +dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.CodeDom/MsgPack.UnitTest.CodeDom.csproj +if not %errorlevel% == 0 exit /b 1 +@rem WinRT related tests require developer license... +@rem vstest.console /logger:Appveyor /InIsolation %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.WinRT/AppPackages/MsgPack.UnitTest.WinRT_1.1.0.0_AnyCPU_Debug_Test/MsgPack.UnitTest.WinRT_1.1.0.0_AnyCPU_Debug.appx +@rem vstest.console /logger:Appveyor /InIsolation %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.BclExtensions.WinRT/AppPackages/MsgPack.UnitTest.BclExtensions.WinRT_1.1.0.0_AnyCPU_Debug_Test/MsgPack.UnitTest.BclExtensions.WinRT_1.1.0.0_AnyCPU_Debug.appx +@rem vstest.console /logger:Appveyor /InIsolation %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.WinRT.WindowsPhone/AppPackages/MsgPack.UnitTest.WinRT.WindowsPhone_1.0.0.0_x86_Debug_Test/MsgPack.UnitTest.WinRT.WindowsPhone_1.0.0.0_x86_Debug.appx +@rem UWP test with NUnit3 is not available in cli +@rem Xamarin tests are not available in cli \ No newline at end of file diff --git a/build/RunUnitTests.cmd b/build/RunUnitTests.cmd index a8f210bdb..2bde04d4f 100644 --- a/build/RunUnitTests.cmd +++ b/build/RunUnitTests.cmd @@ -2,8 +2,6 @@ dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest/MsgPack.UnitTest.cspro if not %errorlevel% == 0 exit /b 1 dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.BclExtensions/MsgPack.UnitTest.BclExtensions.csproj if not %errorlevel% == 0 exit /b 1 -dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.CodeDom/MsgPack.UnitTest.CodeDom.csproj -if not %errorlevel% == 0 exit /b 1 @rem WinRT related tests require developer license... @rem vstest.console /logger:Appveyor /InIsolation %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.WinRT/AppPackages/MsgPack.UnitTest.WinRT_1.1.0.0_AnyCPU_Debug_Test/MsgPack.UnitTest.WinRT_1.1.0.0_AnyCPU_Debug.appx @rem vstest.console /logger:Appveyor /InIsolation %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.BclExtensions.WinRT/AppPackages/MsgPack.UnitTest.BclExtensions.WinRT_1.1.0.0_AnyCPU_Debug_Test/MsgPack.UnitTest.BclExtensions.WinRT_1.1.0.0_AnyCPU_Debug.appx From 0761db33e5e80d3d2306ea099e6580bee3909461 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sat, 20 Jul 2019 01:09:37 +0900 Subject: [PATCH 23/36] Add more appveyor-x.yml files to improve CI stability --- appveyor-debug-netcore10.yml | 39 ++++++++++++++++++++++++++++++++ appveyor-debug4x.yml | 39 ++++++++++++++++++++++++++++++++ build/RunUnitTests-NetCore10.cmd | 10 ++++++++ build/RunUnitTests.cmd | 4 ++-- build/RunUnitTests4x.cmd | 10 ++++++++ 5 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 appveyor-debug-netcore10.yml create mode 100644 appveyor-debug4x.yml create mode 100644 build/RunUnitTests-NetCore10.cmd create mode 100644 build/RunUnitTests4x.cmd diff --git a/appveyor-debug-netcore10.yml b/appveyor-debug-netcore10.yml new file mode 100644 index 000000000..5389a70c0 --- /dev/null +++ b/appveyor-debug-netcore10.yml @@ -0,0 +1,39 @@ +version: '{branch}-{build}' +image: Visual Studio 2017 +skip_tags: true +configuration: Debug +assembly_info: + patch: true + file: '**\*AssemblyInfo.cs' + assembly_version: $(AssemblyBaseVersion).0 + assembly_file_version: $(AssemblyBaseVersion).{build} + assembly_informational_version: $(PackageVersion) +environment: + XamarinMSBuildExtensionsPath: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild +install: +- cmd: >- + cd .\build +- ps: >- + ./SetBuildEnv.ps1 + + cd .. +build_script: +- ps: >- + Write-Host "Configuration=${env:CONFIGURATION}" + + cd ./build + + ./Build.ps1 + + if ( $LastExitCode -ne 0 ) + { + Write-Error "Failed to build." + exit 1 + } + + cd .. +test_script: +- cmd: >- + cd ./build + + ./RunUnitTests-NetCore10.cmd diff --git a/appveyor-debug4x.yml b/appveyor-debug4x.yml new file mode 100644 index 000000000..66fff7217 --- /dev/null +++ b/appveyor-debug4x.yml @@ -0,0 +1,39 @@ +version: '{branch}-{build}' +image: Visual Studio 2017 +skip_tags: true +configuration: Debug +assembly_info: + patch: true + file: '**\*AssemblyInfo.cs' + assembly_version: $(AssemblyBaseVersion).0 + assembly_file_version: $(AssemblyBaseVersion).{build} + assembly_informational_version: $(PackageVersion) +environment: + XamarinMSBuildExtensionsPath: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild +install: +- cmd: >- + cd .\build +- ps: >- + ./SetBuildEnv.ps1 + + cd .. +build_script: +- ps: >- + Write-Host "Configuration=${env:CONFIGURATION}" + + cd ./build + + ./Build.ps1 + + if ( $LastExitCode -ne 0 ) + { + Write-Error "Failed to build." + exit 1 + } + + cd .. +test_script: +- cmd: >- + cd ./build + + ./RunUnitTests4x.cmd diff --git a/build/RunUnitTests-NetCore10.cmd b/build/RunUnitTests-NetCore10.cmd new file mode 100644 index 000000000..b1ec28612 --- /dev/null +++ b/build/RunUnitTests-NetCore10.cmd @@ -0,0 +1,10 @@ +dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest/MsgPack.UnitTest.csproj --framework netcoreapp1.0 +if not %errorlevel% == 0 exit /b 1 +dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.BclExtensions/MsgPack.UnitTest.BclExtensions.csproj --framework netcoreapp1.0 +if not %errorlevel% == 0 exit /b 1 +@rem WinRT related tests require developer license... +@rem vstest.console /logger:Appveyor /InIsolation %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.WinRT/AppPackages/MsgPack.UnitTest.WinRT_1.1.0.0_AnyCPU_Debug_Test/MsgPack.UnitTest.WinRT_1.1.0.0_AnyCPU_Debug.appx +@rem vstest.console /logger:Appveyor /InIsolation %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.BclExtensions.WinRT/AppPackages/MsgPack.UnitTest.BclExtensions.WinRT_1.1.0.0_AnyCPU_Debug_Test/MsgPack.UnitTest.BclExtensions.WinRT_1.1.0.0_AnyCPU_Debug.appx +@rem vstest.console /logger:Appveyor /InIsolation %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.WinRT.WindowsPhone/AppPackages/MsgPack.UnitTest.WinRT.WindowsPhone_1.0.0.0_x86_Debug_Test/MsgPack.UnitTest.WinRT.WindowsPhone_1.0.0.0_x86_Debug.appx +@rem UWP test with NUnit3 is not available in cli +@rem Xamarin tests are not available in cli \ No newline at end of file diff --git a/build/RunUnitTests.cmd b/build/RunUnitTests.cmd index 2bde04d4f..ed3e8884c 100644 --- a/build/RunUnitTests.cmd +++ b/build/RunUnitTests.cmd @@ -1,6 +1,6 @@ -dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest/MsgPack.UnitTest.csproj +dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest/MsgPack.UnitTest.csproj --framework netcoreapp2.0 if not %errorlevel% == 0 exit /b 1 -dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.BclExtensions/MsgPack.UnitTest.BclExtensions.csproj +dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.BclExtensions/MsgPack.UnitTest.BclExtensions.csproj --framework netcoreapp2.0 if not %errorlevel% == 0 exit /b 1 @rem WinRT related tests require developer license... @rem vstest.console /logger:Appveyor /InIsolation %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.WinRT/AppPackages/MsgPack.UnitTest.WinRT_1.1.0.0_AnyCPU_Debug_Test/MsgPack.UnitTest.WinRT_1.1.0.0_AnyCPU_Debug.appx diff --git a/build/RunUnitTests4x.cmd b/build/RunUnitTests4x.cmd new file mode 100644 index 000000000..4b1b79408 --- /dev/null +++ b/build/RunUnitTests4x.cmd @@ -0,0 +1,10 @@ +dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest/MsgPack.UnitTest.csproj --framework net47 +if not %errorlevel% == 0 exit /b 1 +dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.BclExtensions/MsgPack.UnitTest.BclExtensions.csproj --framework net47 +if not %errorlevel% == 0 exit /b 1 +@rem WinRT related tests require developer license... +@rem vstest.console /logger:Appveyor /InIsolation %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.WinRT/AppPackages/MsgPack.UnitTest.WinRT_1.1.0.0_AnyCPU_Debug_Test/MsgPack.UnitTest.WinRT_1.1.0.0_AnyCPU_Debug.appx +@rem vstest.console /logger:Appveyor /InIsolation %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.BclExtensions.WinRT/AppPackages/MsgPack.UnitTest.BclExtensions.WinRT_1.1.0.0_AnyCPU_Debug_Test/MsgPack.UnitTest.BclExtensions.WinRT_1.1.0.0_AnyCPU_Debug.appx +@rem vstest.console /logger:Appveyor /InIsolation %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.WinRT.WindowsPhone/AppPackages/MsgPack.UnitTest.WinRT.WindowsPhone_1.0.0.0_x86_Debug_Test/MsgPack.UnitTest.WinRT.WindowsPhone_1.0.0.0_x86_Debug.appx +@rem UWP test with NUnit3 is not available in cli +@rem Xamarin tests are not available in cli \ No newline at end of file From e47b39c853875a89c3afdeeb4fda96db65b509f6 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sat, 20 Jul 2019 01:09:58 +0900 Subject: [PATCH 24/36] Update readme to add badges for new CI builds --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f84d6b047..086e0a668 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,13 @@ # MessagePack for CLI [![Build status release](https://ci.appveyor.com/api/projects/status/5ln7u7efwjepj6o8?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-x2p85) -[![Build status debug](https://ci.appveyor.com/api/projects/status/dlc0v4rrolwj0t2t?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli) -[![Build status debug net35](https://ci.appveyor.com/api/projects/status/cjp8phlnbwj7gkj9?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-3jme9) -[![Build status debug net35 CodeDOM](https://ci.appveyor.com/api/projects/status/1mw78wkxx50jvab1?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-rhnh0) +[![Build status debug (.NET Core 2.0)](https://ci.appveyor.com/api/projects/status/dlc0v4rrolwj0t2t?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli) +[![Build status debug (.NET Core 1.0)](https://ci.appveyor.com/api/projects/status/avurf519all92v5u?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-g3guk) +[![Build status debug (.NET Framework 4.x)](https://ci.appveyor.com/api/projects/status/np6723q2uiqofr1a?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-nuf62) +[![Build status debug (Code DOM)](https://ci.appveyor.com/api/projects/status/1mw78wkxx50jvab1?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-rhnh0) +[![Build status debug (miscs)](https://ci.appveyor.com/api/projects/status/avufc51yu2cm6idw?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-bo856) +[![Build status debug (.NET Framework 3.5)](https://ci.appveyor.com/api/projects/status/cjp8phlnbwj7gkj9?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-3jme9) +[![Build status debug (.NET Framework 3.5 Code DOM)](https://ci.appveyor.com/api/projects/status/1mw78wkxx50jvab1?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-rhnh0) ## What is it? From 45e7c47bc0b4e7f52d55fcce162f2ef86d6db965 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sun, 21 Jul 2019 16:41:05 +0900 Subject: [PATCH 25/36] Clarify Q&A of readme --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 086e0a668..104136f50 100644 --- a/README.md +++ b/README.md @@ -122,8 +122,8 @@ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor #### Xamarin Android Trouble shooting tips -* Javac shows compilation error. - * Rebuild the test project and try it run again. +* **Q:** Javac shows compilation error. + * **A:** Rebuild the test project and try it run again. ### Xamarin iOS testing @@ -145,10 +145,10 @@ There are bundle IDs of current iOS tests: See [Xamarin's official trouble shooting docs first.](https://developer.xamarin.com/guides/ios/getting_started/installation/windows/connecting-to-mac/troubleshooting/) -* An error occurred while running unit test project. - * Rebuild the project and rerun it. Or, login your Mac again, ant retry it. -* It is hard to read English. - * You can read localized Xamarin docs with putting `{region}-{lang}` as the first component of URL path such as `https://developer.xamarin.com/ja-jp/guides/...`. +* **Q:** An error occurred while running unit test project. + * **A:** Rebuild the project and rerun it. Or, login your Mac again, ant retry it. +* **Q:** It is hard to read English. + * **A:** You can read localized Xamarin docs with putting `{region}-{lang}` as the first component of URL path such as `https://developer.xamarin.com/ja-jp/guides/...`. ## See also From 66734ae4ab29e43e87458147e46442da15bf8ec6 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sun, 21 Jul 2019 18:52:29 +0900 Subject: [PATCH 26/36] Add AOT related note --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 104136f50..829197721 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Dim unpackedObject = serializer.Unpack(stream) * Flexible MessagePackObject which represents MessagePack type system naturally. **Note: AOT support is limited yet. Use [serializer pre-generation](https://github.com/msgpack/msgpack-cli/wiki/Xamarin-and-Unity) with `mpu -s` utility or API.** -If you do not pre-generated serializers, MsgPack for CLI uses reflection in AOT environments, it is slower and it sometimes causes AOT related error (`ExecutionEngineException` for runtime JIT compilation). +If you do not pre-generated serializers, MsgPack for CLI uses reflection in AOT environments, it is slower and it sometimes causes AOT related error (`ExecutionEngineException` for runtime JIT compilation). **You also have to call `MessagePackSerializer.PrepareType` and companions in advance to avoid AOT related error.** See [wiki](https://github.com/msgpack/msgpack-cli/wiki/Xamarin-and-Unity) for details. ## Documentation From 76b8b4ba4bec9bd44492c693dde2b4821a877006 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Sun, 21 Jul 2019 18:52:42 +0900 Subject: [PATCH 27/36] Cosmetic changes --- README.md | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 829197721..15bbe6c6b 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,11 @@ This library can be used from ALL CLS compliant languages such as C#, F#, Visual ## Usage You can serialize/deserialize objects as following: + 1. Create serializer via `MessagePackSerializer.Get` generic method. This method creates dependent types serializers as well. -1. Invoke serializer as following: -** `Pack` method with destination `Stream` and target object for serialization. -** `Unpack` method with source `Stream`. +2. Invoke serializer as following: + * `Pack` method with destination `Stream` and target object for serialization. + * `Unpack` method with source `Stream`. ```c# // Creates serializer. @@ -111,11 +112,13 @@ If you want to use ".NET 2.0 Subset" settings, you must use just only described If you run on Windows, it is recommended to use HXM instead of Hyper-V based emulator. You can disable Hyper-V from priviledged (administrator) powershell as follows: + ```powershell Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor ``` If you want to use Hyper-V again (such as for Docker for Windows etc.), you can do it by following in priviledged (administrator) powershell: + ```powershell Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor ``` @@ -123,7 +126,7 @@ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor #### Xamarin Android Trouble shooting tips * **Q:** Javac shows compilation error. - * **A:** Rebuild the test project and try it run again. + * **A:** Rebuild the test project and try it run again. ### Xamarin iOS testing @@ -131,6 +134,7 @@ You must create provisoning profiles in your MacOS devices. See [Xamarin documents about provisining](https://developer.xamarin.com/guides/ios/getting_started/installation/device_provisioning/free-provisioning/) for details. There are bundle IDs of current iOS tests: + * `org.msgpack.msgpack-cli-xamarin-ios-test` * `org.msgpack.msgpack-cli-xamarin-ios-test-packer` * `org.msgpack.msgpack-cli-xamarin-ios-test-unpacker` @@ -146,15 +150,15 @@ There are bundle IDs of current iOS tests: See [Xamarin's official trouble shooting docs first.](https://developer.xamarin.com/guides/ios/getting_started/installation/windows/connecting-to-mac/troubleshooting/) * **Q:** An error occurred while running unit test project. - * **A:** Rebuild the project and rerun it. Or, login your Mac again, ant retry it. + * **A:** Rebuild the project and rerun it. Or, login your Mac again, ant retry it. * **Q:** It is hard to read English. - * **A:** You can read localized Xamarin docs with putting `{region}-{lang}` as the first component of URL path such as `https://developer.xamarin.com/ja-jp/guides/...`. + * **A:** You can read localized Xamarin docs with putting `{region}-{lang}` as the first component of URL path such as `https://developer.xamarin.com/ja-jp/guides/...`. ## See also -* GitHub Page : http://cli.msgpack.org/ -* Wiki (documentation) : https://github.com/msgpack/msgpack-cli/wiki -* API Reference : http://cli.msgpack.org/doc/top.html -* Issue tracker : https://github.com/msgpack/msgpack-cli/issues -* MSBuild reference : http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx -* Mono xbuild reference : http://www.mono-project.com/Microsoft.Build +* GitHub Page : http://cli.msgpack.org/ +* Wiki (documentation) : https://github.com/msgpack/msgpack-cli/wiki +* API Reference : http://cli.msgpack.org/doc/top.html +* Issue tracker : https://github.com/msgpack/msgpack-cli/issues +* MSBuild reference : http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx +* Mono xbuild reference : http://www.mono-project.com/Microsoft.Build From 4c72b665c9c324167f4717b5c761faef5176b59c Mon Sep 17 00:00:00 2001 From: yfakariya Date: Mon, 22 Jul 2019 20:47:01 +0900 Subject: [PATCH 28/36] Fix badges to clarify configuration --- README.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 15bbe6c6b..eeb265850 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,17 @@ # MessagePack for CLI -[![Build status release](https://ci.appveyor.com/api/projects/status/5ln7u7efwjepj6o8?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-x2p85) -[![Build status debug (.NET Core 2.0)](https://ci.appveyor.com/api/projects/status/dlc0v4rrolwj0t2t?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli) -[![Build status debug (.NET Core 1.0)](https://ci.appveyor.com/api/projects/status/avurf519all92v5u?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-g3guk) -[![Build status debug (.NET Framework 4.x)](https://ci.appveyor.com/api/projects/status/np6723q2uiqofr1a?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-nuf62) -[![Build status debug (Code DOM)](https://ci.appveyor.com/api/projects/status/1mw78wkxx50jvab1?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-rhnh0) -[![Build status debug (miscs)](https://ci.appveyor.com/api/projects/status/avufc51yu2cm6idw?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-bo856) -[![Build status debug (.NET Framework 3.5)](https://ci.appveyor.com/api/projects/status/cjp8phlnbwj7gkj9?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-3jme9) -[![Build status debug (.NET Framework 3.5 Code DOM)](https://ci.appveyor.com/api/projects/status/1mw78wkxx50jvab1?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-rhnh0) +## CI Status + +|**Configuration**|**Status**| +|:--|:--| +|Release |[![Build status release](https://ci.appveyor.com/api/projects/status/5ln7u7efwjepj6o8?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-x2p85)| +|Debug (.NET Core 2.0) |[![Build status debug (.NET Core 2.0)](https://ci.appveyor.com/api/projects/status/dlc0v4rrolwj0t2t?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli)| +|Debug (.NET Core 2.0) |[![Build status debug (.NET Core 1.0)](https://ci.appveyor.com/api/projects/status/avurf519all92v5u?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-g3guk)| +|Debug (.NET Framework 4.x) |[![Build status debug (.NET Framework 4.x)](https://ci.appveyor.com/api/projects/status/np6723q2uiqofr1a?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-nuf62)| +|Debug (Code DOM)] |[![Build status debug (Code DOM)](https://ci.appveyor.com/api/projects/status/1mw78wkxx50jvab1?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-rhnh0)| +|Debug (miscs)] |[![Build status debug (miscs)](https://ci.appveyor.com/api/projects/status/avufc51yu2cm6idw?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-bo856)| +|Debug (.NET Framework 3.5) |[![Build status debug (.NET Framework 3.5)](https://ci.appveyor.com/api/projects/status/cjp8phlnbwj7gkj9?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-3jme9)| +|Debug (.NET Framework 3.5 Code DOM) |[![Build status debug (.NET Framework 3.5 Code DOM)](https://ci.appveyor.com/api/projects/status/1mw78wkxx50jvab1?svg=true)](https://ci.appveyor.com/project/yfakariya/msgpack-cli-rhnh0)| ## What is it? From a084174df9ea21f9ebdba456534c613920658d47 Mon Sep 17 00:00:00 2001 From: yfakariya Date: Mon, 14 Oct 2019 22:19:39 +0900 Subject: [PATCH 29/36] Update readme about silverlight/winrt/uwp projects. --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index eeb265850..d6253d7ee 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,15 @@ See [Xamarin's official trouble shooting docs first.](https://developer.xamarin. * **Q:** It is hard to read English. * **A:** You can read localized Xamarin docs with putting `{region}-{lang}` as the first component of URL path such as `https://developer.xamarin.com/ja-jp/guides/...`. +## Maintenance + +### MsgPack.Windows.sln + +This solution contains Silverlight5 and (old) UWP project for backward compability. They are required Visual Studio 2015 to build and test. +You can download Visual Studio 2015 community edition from [here](https://visualstudio.microsoft.com/vs/older-downloads/). + +**You do not have to install Visual Studio 2015 as long as you don't edit/test/build Silverlight and/or old UWP project.** + ## See also * GitHub Page : http://cli.msgpack.org/ From e7514259edd2f38378d3ea1b3de57587dfa7d75b Mon Sep 17 00:00:00 2001 From: yfakariya Date: Mon, 14 Oct 2019 22:21:25 +0900 Subject: [PATCH 30/36] Add test cert tool This tool solves a problem that Visual Studio only generates 1-year expiry certs. By this commit, dev-certs will have expiry until 2038. In that time, UWP apps should be replaced completely. --- tools/MakeCert/New-TestCerft.ps1 | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tools/MakeCert/New-TestCerft.ps1 diff --git a/tools/MakeCert/New-TestCerft.ps1 b/tools/MakeCert/New-TestCerft.ps1 new file mode 100644 index 000000000..abb42dcef --- /dev/null +++ b/tools/MakeCert/New-TestCerft.ps1 @@ -0,0 +1,49 @@ +<# +.SYNOPSIS +Make test certificate for UWP unit test programs. +.PARAMETER FilePath +Specify output file path. Default is "./testcert.pfx" +.DESCRIPTION +This script makes self-signed certificates for code signing with CN=MsgPack.Cli.UnitTest, RSA256, SHA256 with maximum expiry date. +Note that the pfx file has empty password. +#> +#requires -Version 5.1 + +using namespace System.IO +using namespace System.Security.Cryptography +using namespace System.Security.Cryptography.X509Certificates + +[CmdletBinding(PositionalBinding = $false)] +param( + [ValidateNotNullOrEmpty()][string]$FilePath = "./testcert.pfx" +) + +Set-StrictMode -Version 5.1 + +[string]$subject = "CN=MsgPack.Cli.UnitTest" +[RSA]$password = [RSA]::Create(2048) +[HashAlgorithmName]$hashAlgorithm = [HashAlgorithmName]::SHA256 +[RSASignaturePadding]$padding = [RSASignaturePadding]::Pkcs1 +[DateTimeOffset]$notBefore = [System.DateTimeOffset]::new(2019, 10, 1, 0, 0, 0, 0) +# Some implementation has year 2037 problem, they cannot accept date after 2038/01/19. +[DateTimeOffset]$notAfter = [System.DateTimeOffset]::FromUnixTimeSeconds([Int32]::MaxValue) + +# Try load CertificateRequest type dinamically to support multiple platforms... +$certReqType = [System.Linq.Enumerable].Assembly.GetType("System.Security.Cryptography.X509Certificates.CertificateRequest") +if ($null -eq $certReqType) { + # This should be pwsh + $certReqType = [X509Certificate].Assembly.GetType("System.Security.Cryptography.X509Certificates.CertificateRequest") + if ($null -eq $certReqType) { + throw [PlatformNotSupportedException]::new("pwsh, or PowerShell with .NET Framework 4.7.2 or later is required."); + } +} + +# Create CertificateRequest instance +$certReq = $certReqType::new($subject, $password, $hashAlgorithm, $padding) +# This cert is for code signing: +$certReq.CertificateExtensions.Add([X509EnhancedKeyUsageExtension]::new([X509Extension]::new([Oid]::FromOidValue("2.5.29.37", [OidGroup]::All ), @(48, 10, 6, 8, 43, 6, 1, 5, 5, 7, 3, 3), $true), $true)) +# This cert is end entity: 2.5.29.19, {48,0}, critical. +$certReq.CertificateExtensions.Add([X509BasicConstraintsExtension]::new([X509Extension]::new([Oid]::FromOidValue("2.5.29.19", [OidGroup]::All ), @(48, 0), $true), $true)) + +[X509Certificate2]$cert = $certReq.CreateSelfSigned($notBefore, $notAfter) +[File]::WriteAllBytes($FilePath, $cert.Export([X509ContentType]::Pfx, [String]::Empty)) From 0be7d578826f5784dee5181562279dec0b4bc23b Mon Sep 17 00:00:00 2001 From: yfakariya Date: Mon, 14 Oct 2019 22:22:06 +0900 Subject: [PATCH 31/36] Update development certificates to year 2038 expiry. --- ...tTest.BclExtensions.WinRT_TemporaryKey.pfx | Bin 2536 -> 2422 bytes .../MsgPack.UnitTest.Uwp.Aot_TemporaryKey.pfx | Bin 2536 -> 2422 bytes .../MsgPack.UnitTest.Uwp_TemporaryKey.pfx | Bin 2536 -> 2422 bytes .../MsgPack.UnitTest.WinRT_TemporaryKey.pfx | Bin 2536 -> 2422 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/test/MsgPack.UnitTest.BclExtensions.WinRT/MsgPack.UnitTest.BclExtensions.WinRT_TemporaryKey.pfx b/test/MsgPack.UnitTest.BclExtensions.WinRT/MsgPack.UnitTest.BclExtensions.WinRT_TemporaryKey.pfx index 9c3c1d01314c6908e274dbc71ada95c708e87f6a..d2def697cc44b6e03d179dd068c447c95898b2a5 100644 GIT binary patch literal 2422 zcmZXUc{Cg78i%uMw5A5Jw)VA1gQzWISFw)L5=v<8Th%_cDG9o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Y!7zhfY;CMhPL@{%~4De>kf`96*E;tutBD?QupRhj3r@r!BOq&x` z%B905@k^-!vHG z`K=^jS%HhG`!9q`d@kp+pN`2D^``BL+n5(BsL4r7p36s-h`gSfRGkcdF_dc)IWT_z z_9mV`{kYR;V}wE*vMvTp-mBn1JkLpNspVK_?+g&EnHGiDtXwz^+u0vcF(XE-ABkLV zt1lZM*TnsJLeXuvvSQQnVALj%wfMqc$=4nqF`$Bh>F^)#wmc!XHQd^> zSrllwwJE3^a)T}W7&-FWwxV9eR&tmV!Zav|^1h@gE>z`%(cX^AlIha}JC)OrJL%)I zk4%W&eKSvvC->NmbMDlhu=Bs?dUyKqPd2)(rh)1lFN=g#aQLa4w0jo1*(bY3!1W=C z&HFM+45<>O6z@P&ALV5KY~hAh5S1=W6qTh;F&3X+5^cZh-QT$IJX|EZYiZG-=<$#n zP;`G#hJMcSw%(x}eI8kp+WRr$iTg5`~lp^#j)Ya{*I+ql5l zG0CE;nC*Gr6+Weh;n!^x59esftV_2zdFU1x8y!*g!h|El^*d6w|lfV&h-n-QoO;d zJziDV{#hV8ootJsoiR=A3jZ8nai7$beq({f&_HhgaeBG>nvf1!!l{%Fwb8Yzu_S3I zL!`-^BkWY8Y0hnl-9~=Lu&Sx5yPU9f?uRqk=G;}LBzKBoR&{0>eZwU^(OFQY8{m+a zaaQuQ5WLwvS$O%ALAFRogm!44yyp<^n$gb_zoO`EFR(|k;#gJ~ixLt77KZXEQwvO- wxZs$@lRxn|Z`8ZZhmUrke4&B0;xh8qYc`mwoB})VG_vVB;r9n*TF{^MH!uWUwg3PC diff --git a/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp_TemporaryKey.pfx b/test/MsgPack.UnitTest.Uwp/MsgPack.UnitTest.Uwp_TemporaryKey.pfx index 604dac0b06b2be4477b423f66665c174ef9a9e0e..d2def697cc44b6e03d179dd068c447c95898b2a5 100644 GIT binary patch delta 2385 zcmV-X39k0&6ZR5+FoFqk0s#Xsf(b4L2`Y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TH(n|p zbkwe>bLPcU9>P*)b?s03+!&?ld*NGNwJ~G7s}DOh-4qkeTNYeA8k}8|9hq_}| zN7RVi`<}Lapjoxo1=-ATEmjTr)-afnCt7$d;6+;JH?S{7!bU5&sLfh#OT6c$uiM=$ zt`d`y#b<6hC{Mx2(VB8^Rzaugnf7z~W|u>e-;0Kkz-rH#sEE8%Q8_J))*y%+68HFg z&pctFUgC;bk>{l4U2M~3v5#@eD%j&pw`*xthVL^h$5Vwhg2R8meNeh;=th5cB}wQP zW9TEgMEP~dfySrxZrZM3CQE|q+xKU&+l^b z{Qcm`MxQMf_H~_pmEH4Bkyd@7UxA{1h>wZWXJ{r`*S}Bh%9nIlB*?8(4Hiz`oqP45 zWWIkgohQCof+>o93(q-xruW(M$(Q|9gQw^3jr^j}k4i*orekZ!D_>mq+EksU#O|X} zaH9{@p?yh91A>uA?eC1?UJYY6*QzhX(Cp$Q4=)nZfpZ@d;DR28iKusT vvE{?Ad$wP5`gPE(7+5!b4u^?|Z4y5uDL{&=-4}@=;UCw!62{Vhe87JLUtM4@ From e2dd99f34d7f8c7322b6959391b5ecfed90e4ed3 Mon Sep 17 00:00:00 2001 From: Hodaifa98 <40869908+Hodaifa98@users.noreply.github.com> Date: Tue, 20 Oct 2020 14:51:36 +0100 Subject: [PATCH 32/36] Changed "pacakge" to "package". Fixed a simple typo I saw when browsing .net packages. --- MsgPack.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MsgPack.nuspec b/MsgPack.nuspec index aa088e4d2..1030c7002 100644 --- a/MsgPack.nuspec +++ b/MsgPack.nuspec @@ -11,7 +11,7 @@ http://cli.msgpack.org/images/msgpack.ico false MessagePack is fast, compact, and interoperable binary serialization format. -This package provides MessagePack serialization/deserialization APIs. This pacakge also supports Mono, Xamarin, .NET Core and Unity. +This package provides MessagePack serialization/deserialization APIs. This package also supports Mono, Xamarin, .NET Core and Unity. This release includes .NET Core and Unity IL2CPP support, Xamarin iOS linker support, asynchronous serialization support, and various improvements and bug fixes reported in github issues. Copyright 2010-2016 FUJIWARA, Yusuke, all rights reserved. MsgPack MessagePack Serialization Formatter Serializer From bec12b0f7ac9eb2c06c29d73ec71bb1259802f46 Mon Sep 17 00:00:00 2001 From: southernsun Date: Tue, 6 Apr 2021 10:57:40 +0200 Subject: [PATCH 33/36] Update Sample08_Polymorphism.cs --- samples/Samples/Sample08_Polymorphism.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/samples/Samples/Sample08_Polymorphism.cs b/samples/Samples/Sample08_Polymorphism.cs index c3179cfc9..587216001 100644 --- a/samples/Samples/Sample08_Polymorphism.cs +++ b/samples/Samples/Sample08_Polymorphism.cs @@ -56,11 +56,7 @@ public void Polymorphism() using ( var buffer = new MemoryStream() ) { serializer.Pack( - buffer, new PolymorphicHolder - { - WithRuntimeType = new FileObject { Path = "/path/to/file" }, - WithKnownType = new DirectoryObject { Path = "/path/to/dir/" } - } + buffer, rootObject ); buffer.Position = 0; @@ -200,4 +196,4 @@ public static bool Verify( PolymorphicTypeVerificationContext context ) return true; } } -} \ No newline at end of file +} From 392d92038b1036e65b4177a1276a29f6faf5ad33 Mon Sep 17 00:00:00 2001 From: Akira Takahashi Date: Fri, 7 Apr 2023 13:50:16 +0900 Subject: [PATCH 34/36] fix bad DateTime sample --- samples/Samples/Sample01_BasicUsage.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/Samples/Sample01_BasicUsage.cs b/samples/Samples/Sample01_BasicUsage.cs index 84c37be96..559da1ef1 100644 --- a/samples/Samples/Sample01_BasicUsage.cs +++ b/samples/Samples/Sample01_BasicUsage.cs @@ -1,4 +1,4 @@ -#region -- License Terms -- +#region -- License Terms -- // // MessagePack for CLI // @@ -69,7 +69,7 @@ public void SerializeThenDeserialize() Debug.WriteLine( "Same Id? {0}", targetObject.Id == deserializedObject.Id ); Debug.WriteLine( "Same Title? {0}", targetObject.Title == deserializedObject.Title ); // Note that MsgPack defacto-standard is Unix epoc in milliseconds precision, so micro- and nano- seconds will be lost. See sample 04 for workaround. - Debug.WriteLine( "Same Date? {0}", targetObject.Date.ToString( "YYYY-MM-DD HH:mm:ss.fff" ) == deserializedObject.Date.ToString( "YYYY-MM-DD HH:mm:ss.fff" ) ); + Debug.WriteLine( "Same Date? {0}", targetObject.Date.ToString( "yyyy-MM-dd HH:mm:ss.fff" ) == deserializedObject.Date.ToLocalTime().ToString( "yyyy-MM-dd HH:mm:ss.fff" ) ); // Image and Comment tests are ommitted here. // Collection elements are deserialzed. Debug.WriteLine( "Items count: {0}", deserializedObject.Tags.Count ); From fe47c7df4e31460f3ea2e24d0f822062717357a3 Mon Sep 17 00:00:00 2001 From: Akira Takahashi Date: Fri, 7 Apr 2023 23:48:30 +0900 Subject: [PATCH 35/36] use DateTime.UtcNow --- samples/Samples/Sample01_BasicUsage.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/Samples/Sample01_BasicUsage.cs b/samples/Samples/Sample01_BasicUsage.cs index 559da1ef1..37c660a08 100644 --- a/samples/Samples/Sample01_BasicUsage.cs +++ b/samples/Samples/Sample01_BasicUsage.cs @@ -44,7 +44,7 @@ public void SerializeThenDeserialize() { Id = 123, Title = "My photo", - Date = DateTime.Now, + Date = DateTime.UtcNow, Image = new byte[] { 1, 2, 3, 4 }, Comment = "This is test object to be serialize/deserialize using MsgPack." }; @@ -69,7 +69,7 @@ public void SerializeThenDeserialize() Debug.WriteLine( "Same Id? {0}", targetObject.Id == deserializedObject.Id ); Debug.WriteLine( "Same Title? {0}", targetObject.Title == deserializedObject.Title ); // Note that MsgPack defacto-standard is Unix epoc in milliseconds precision, so micro- and nano- seconds will be lost. See sample 04 for workaround. - Debug.WriteLine( "Same Date? {0}", targetObject.Date.ToString( "yyyy-MM-dd HH:mm:ss.fff" ) == deserializedObject.Date.ToLocalTime().ToString( "yyyy-MM-dd HH:mm:ss.fff" ) ); + Debug.WriteLine( "Same Date? {0}", targetObject.Date.ToString( "yyyy-MM-dd HH:mm:ss.fff" ) == deserializedObject.Date.ToString( "yyyy-MM-dd HH:mm:ss.fff" ) ); // Image and Comment tests are ommitted here. // Collection elements are deserialzed. Debug.WriteLine( "Items count: {0}", deserializedObject.Tags.Count ); From a6d86ad4a433ff0d6deb592b315feb4ea9149e6b Mon Sep 17 00:00:00 2001 From: James Thompson Date: Wed, 17 Apr 2024 08:28:01 +1000 Subject: [PATCH 36/36] #359 add net core 3.1 & net 6 --- src/MsgPack/MsgPack.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MsgPack/MsgPack.csproj b/src/MsgPack/MsgPack.csproj index 783b86a89..d503aedb1 100644 --- a/src/MsgPack/MsgPack.csproj +++ b/src/MsgPack/MsgPack.csproj @@ -4,7 +4,7 @@ {5BCEC32E-990E-4DE5-945F-BD27326A7418} Library MsgPack - net46;net35;net45;netstandard1.1;netstandard1.3;netstandard2.0;MonoAndroid10;Xamarin.iOS10; + net46;net35;net45;netstandard1.1;netstandard1.3;netstandard2.0;MonoAndroid10;Xamarin.iOS10;netcoreapp3.1;net6.0 True AllRules.ruleset $(SolutionDir)/msgpack.nuspec @@ -16,7 +16,7 @@ bin\$(Configuration)\ - +