Skip to content

Commit ef57f2e

Browse files
authored
Merge pull request #271 from msgpack/fix/issue-270
Fix/issue 270
2 parents ca751bb + 13b2da7 commit ef57f2e

19 files changed

+126
-34
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,3 +736,9 @@ Relase 1.0.0-beta2 2017-10-29
736736
* System.Tuple<T> detection now ignores their declaring assemblies.
737737
* Improve exception message in AOT error of Unity.
738738
* .NET Standard 1.1/1.3 projects now do not depend on System.Linq.Expressions package.
739+
740+
Release 1.0.0-rc1 T.B.D.
741+
742+
BUG FIXES
743+
* Fix NRE in .NET Standard 1.1/1.3 build (this issue got mixed in beta2).
744+
* Fix built-in Guid/BigInteger always output raw type even if PackerCompatibilityOptions.PackBinaryAsRaw is not specified. #270

build/RunUnitTests.cmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest/MsgPack.UnitTest.csproj
2+
if not %errorlevel% == 0 exit /b 1
23
dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.BclExtensions/MsgPack.UnitTest.BclExtensions.csproj
4+
if not %errorlevel% == 0 exit /b 1
35
dotnet test %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.CodeDom/MsgPack.UnitTest.CodeDom.csproj
6+
if not %errorlevel% == 0 exit /b 1
47
nunit3-console %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.Net35/bin/Debug/net35/MsgPack.UnitTest.Net35.dll --framework:net-3.5 --result=test-result-net35.xml;format=AppVeyor
8+
if not %errorlevel% == 0 exit /b 1
59
nunit3-console %APPVEYOR_BUILD_FOLDER%/test/MsgPack.UnitTest.CodeDom.Net35/bin/Debug/net35/MsgPack.UnitTest.CodeDom.Net35.dll --framework:net-3.5 --result=test-result-net35-codedom.xml;format=AppVeyor
10+
if not %errorlevel% == 0 exit /b 1
611
@rem WinRT related tests require developer license...
712
@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
813
@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

build/Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0-beta2
1+
1.0.0-rc

src/MsgPack/ReflectionAbstractions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public static MethodInfo GetRuntimeMethod( this Type source, string name, Type[]
212212
);
213213
}
214214

215-
#else
215+
#else // NETSTANDARD1_1 || NETSTANDARD1_3
216216
public static MethodInfo GetRuntimeMethod( this Type source, string name, Type[] parameters )
217217
{
218218
return
@@ -242,6 +242,13 @@ public static PropertyInfo GetRuntimeProperty( this Type source, string name )
242242
);
243243
}
244244

245+
#if NET35 || SILVERLIGHT
246+
public static IEnumerable<PropertyInfo> GetRuntimeProperties( this Type source )
247+
{
248+
return source.GetProperties( BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic );
249+
}
250+
#endif // NET35 || SILVERLIGHT
251+
245252
#if DEBUG
246253
public static FieldInfo GetRuntimeField( this Type source, string name )
247254
{

src/MsgPack/Serialization/DefaultSerializers/DefaultSerializers.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public System_GuidMessagePackSerializer( SerializationContext ownerContext )
320320
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )]
321321
protected internal override void PackToCore( Packer packer, System.Guid value )
322322
{
323-
packer.PackRaw( value.ToByteArray() );
323+
packer.PackBinary( value.ToByteArray() );
324324
}
325325

326326
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )]
@@ -345,7 +345,7 @@ protected internal override System.Guid UnpackFromCore( Unpacker unpacker )
345345
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )]
346346
protected internal override async Task PackToAsyncCore( Packer packer, System.Guid value, CancellationToken cancellationToken )
347347
{
348-
await packer.PackRawAsync( value.ToByteArray(), cancellationToken ).ConfigureAwait( false );
348+
await packer.PackBinaryAsync( value.ToByteArray(), cancellationToken ).ConfigureAwait( false );
349349
}
350350

351351
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )]
@@ -922,7 +922,7 @@ public System_Numerics_BigIntegerMessagePackSerializer( SerializationContext own
922922
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )]
923923
protected internal override void PackToCore( Packer packer, System.Numerics.BigInteger value )
924924
{
925-
packer.PackRaw( value.ToByteArray() );
925+
packer.PackBinary( value.ToByteArray() );
926926
}
927927

928928
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )]
@@ -947,7 +947,7 @@ protected internal override System.Numerics.BigInteger UnpackFromCore( Unpacker
947947
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )]
948948
protected internal override async Task PackToAsyncCore( Packer packer, System.Numerics.BigInteger value, CancellationToken cancellationToken )
949949
{
950-
await packer.PackRawAsync( value.ToByteArray(), cancellationToken ).ConfigureAwait( false );
950+
await packer.PackBinaryAsync( value.ToByteArray(), cancellationToken ).ConfigureAwait( false );
951951
}
952952

953953
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )]

src/MsgPack/Serialization/DefaultSerializers/DefaultSerializers.tt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,17 @@ var workArounds =
166166
{
167167
{ typeof( char ), new WorkAround(){ PackCode = "packer.Pack( ( System.UInt16 )value );", UnpackCode = "return ( System.Char ) unpacker.LastReadData.AsUInt16(); " } },
168168
{ typeof( decimal ), new WorkAround(){ PackCode = "packer.PackString( value.ToString( \"G\", CultureInfo.InvariantCulture ) );", UnpackCode = "return System.Decimal.Parse( unpacker.LastReadData.AsString(), CultureInfo.InvariantCulture ); " } },
169-
{ typeof( Guid ), new WorkAround(){ PackCode = "packer.PackRaw( value.ToByteArray() );", UnpackCode = "return new System.Guid( unpacker.LastReadData.AsBinary() ); " } },
170-
{ typeof( BigInteger ), new WorkAround(){ PackCode = "packer.PackRaw( value.ToByteArray() );", UnpackCode = "return new System.Numerics.BigInteger( unpacker.LastReadData.AsBinary() ); " } },
169+
{ typeof( Guid ), new WorkAround(){ PackCode = "packer.PackBinary( value.ToByteArray() );", UnpackCode = "return new System.Guid( unpacker.LastReadData.AsBinary() ); " } },
170+
{ typeof( BigInteger ), new WorkAround(){ PackCode = "packer.PackBinary( value.ToByteArray() );", UnpackCode = "return new System.Numerics.BigInteger( unpacker.LastReadData.AsBinary() ); " } },
171171
};
172172

173173
var asyncWorkArounds =
174174
new Dictionary<Type, string>()
175175
{
176176
{ typeof( char ), "packer.PackAsync( ( System.UInt16 )value, cancellationToken ).ConfigureAwait( false );" },
177177
{ typeof( decimal ), "packer.PackStringAsync( value.ToString( \"G\", CultureInfo.InvariantCulture ), cancellationToken ).ConfigureAwait( false );" },
178-
{ typeof( Guid ), "packer.PackRawAsync( value.ToByteArray(), cancellationToken ).ConfigureAwait( false );" },
179-
{ typeof( BigInteger ), "packer.PackRawAsync( value.ToByteArray(), cancellationToken ).ConfigureAwait( false );" },
178+
{ typeof( Guid ), "packer.PackBinaryAsync( value.ToByteArray(), cancellationToken ).ConfigureAwait( false );" },
179+
{ typeof( BigInteger ), "packer.PackBinaryAsync( value.ToByteArray(), cancellationToken ).ConfigureAwait( false );" },
180180
};
181181

182182
var notInSLs =

src/MsgPack/Serialization/Metadata/_MessagePackSerializer.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#endregion -- License Terms --
2020

2121
using System;
22+
using System.Linq;
2223
using System.Reflection;
2324

2425
namespace MsgPack.Serialization.Metadata
@@ -27,8 +28,12 @@ namespace MsgPack.Serialization.Metadata
2728
internal static class _MessagePackSerializer
2829
{
2930
// ReSharper disable InconsistentNaming
30-
public static readonly MethodInfo Create1_Method = typeof( MessagePackSerializer ).GetRuntimeMethod( nameof( MessagePackSerializer.Create ), new[] { typeof( SerializationContext ) } );
31+
public static readonly MethodInfo Create1_Method = typeof( MessagePackSerializer ).GetMethod( nameof( MessagePackSerializer.Create ), new[] { typeof( SerializationContext ) } );
3132
// ReSharper restore InconsistentNaming
32-
public static readonly PropertyInfo OwnerContext = typeof( MessagePackSerializer ).GetRuntimeProperty( nameof( MessagePackSerializer.OwnerContext ) );
33+
public static readonly PropertyInfo OwnerContext =
34+
typeof( MessagePackSerializer )
35+
// Use LINQ to get non public property in netstandard 1.x
36+
.GetRuntimeProperties()
37+
.Single( p => p.Name == nameof( MessagePackSerializer.OwnerContext ) );
3338
}
3439
}

test/MsgPack.UnitTest.BclExtensions/MsgPack.UnitTest.BclExtensions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<PackageReference Include="Mono.Cecil" Version="0.10.0-beta6" />
3030
</ItemGroup>
3131
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0'">
32-
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.7" />
32+
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.5" />
3333
</ItemGroup>
3434
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
3535
<PackageReference Include="Microsoft.NETCore.App" Version="2.0.0" />

test/MsgPack.UnitTest.CodeDom/Serialization/ArrayCodeDomBasedAutoMessagePackSerializerTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9285,7 +9285,7 @@ public void TestReadOnlyAndConstructor()
92859285
Assert.That(
92869286
serializedItem,
92879287
Is.EqualTo(
9288-
new byte[] { 0x92, 0xB0 }.Concat( item.Id.ToByteArray() )
9288+
new byte[] { 0x92, MessagePackCode.Bin8, 0x10 }.Concat( item.Id.ToByteArray() )
92899289
.Concat( new byte[] { 0x92, 5, 11 } ).ToArray()
92909290
)
92919291
);
@@ -9304,7 +9304,7 @@ public void TestGetOnlyAndConstructor()
93049304
Assert.That(
93059305
serializedItem,
93069306
Is.EqualTo(
9307-
new byte[] { 0x92, 0xB0 }.Concat( item.Id.ToByteArray() )
9307+
new byte[] { 0x92, MessagePackCode.Bin8, 0x10 }.Concat( item.Id.ToByteArray() )
93089308
.Concat( new byte[] { 0x92, 5, 11 } ).ToArray()
93099309
)
93109310
);

test/MsgPack.UnitTest.CodeDom/Serialization/MapCodeDomBasedAutoMessagePackSerializerTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9597,7 +9597,7 @@ public void TestReadOnlyAndConstructor()
95979597
Assert.That(
95989598
serializedItem,
95999599
Is.EqualTo( new byte[] { 0x82, 0xA2 }.Concat( Encoding.UTF8.GetBytes( "Id" ) )
9600-
.Concat( new byte[] { 0xB0 } ).Concat( item.Id.ToByteArray() )
9600+
.Concat( new byte[] { MessagePackCode.Bin8, 0x10 } ).Concat( item.Id.ToByteArray() )
96019601
.Concat( new byte[] { 0xA4 } ).Concat( Encoding.UTF8.GetBytes( "Ints" ) )
96029602
.Concat( new byte[] { 0x92, 5, 11 } ).ToArray()
96039603
)
@@ -9617,7 +9617,7 @@ public void TestGetOnlyAndConstructor()
96179617
Assert.That(
96189618
serializedItem,
96199619
Is.EqualTo( new byte[] { 0x82, 0xA2 }.Concat( Encoding.UTF8.GetBytes( "Id" ) )
9620-
.Concat( new byte[] { 0xB0 } ).Concat( item.Id.ToByteArray() )
9620+
.Concat( new byte[] { MessagePackCode.Bin8, 0x10 } ).Concat( item.Id.ToByteArray() )
96219621
.Concat( new byte[] { 0xA4 } ).Concat( Encoding.UTF8.GetBytes( "Ints" ) )
96229622
.Concat( new byte[] { 0x92, 5, 11 } ).ToArray()
96239623
)

0 commit comments

Comments
 (0)