Skip to content

Commit b99ac9d

Browse files
committed
Add silverlight/wp unit tests.
1 parent 0e21f7c commit b99ac9d

78 files changed

Lines changed: 2152 additions & 429 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGES.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,23 @@ Release 0.5 - 2014/7/21
136136
* This release unifies .NET build and Mono build for main source codes (testing codes have not been unified yet.)
137137
* This release contains reimplementation of serializer generation stack. It might change implementation detail dependant behavior (it usually potential issue).
138138

139-
Release 0.5.1 2014/8/9
139+
Release 0.5.1 - 2014/8/9
140140

141141
FEATURES
142142
* Reflection serializer. It enables on-the-fly serializer generation in Xamarin and Unity3D.
143143

144144
BUG FIXES
145-
* Fixes concurrency bug in WinRT.
146-
* Fixes built-in NamedValueCollection serializer generates invalid stream when the values of a key are empty.
145+
* Fix concurrency bug in WinRT.
146+
* Fix built-in NamedValueCollection serializer generates invalid stream when the values of a key are empty.
147147

148148
NOTE
149-
* This release changes drop for Unity3D from source assets to dll assets.
149+
* This release changes drop for Unity3D from source assets to dll assets (source assets are still available).
150+
151+
Release 0.5.2 - 2014/9/?
152+
153+
FEATURES
154+
* Support Windows Phone 8.1 (Both of WinRT & Silverlight) issue #36
155+
* Add MessagePackSerializer.Get() for usability.
156+
157+
BUG FIXES
158+
* Fix FILETIME is not available in WinRT

MsgPack.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<metadata>
44
<id>MsgPack.Cli</id>
55
<title>MessagePack for CLI</title>
6-
<version>0.5.1</version>
6+
<version>0.5.2</version>
77
<authors>FUJIWARA, Yusuke</authors>
88
<owners>FUJIWARA, Yusuke</owners>
99
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>

MsgPack.sln

Lines changed: 409 additions & 6 deletions
Large diffs are not rendered by default.

Sync.Test.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@
108108
<Exclude Path="Serialization\MapGenerationBasedEnumSerializationTest.cs" />
109109
<Exclude Path="Serialization\SerializerGeneratorTest.cs" />
110110
</Project>
111+
<Project Name="MsgPack.UnitTest.Silverlight.WindowsPhone" Base="MsgPack.UnitTest.WinRT">
112+
<Preserve Path="Properties\AssemblyInfo.cs" />
113+
<Preserve File="*.config" />
114+
<Preserve File="*.json" />
115+
<Preserve File="*.mpac" />
116+
<Preserve File="*.pfx" />
117+
<Preserve File="*.png" />
118+
<Preserve File="*.xaml" />
119+
<Preserve File="*Manifest.xml" />
120+
<Preserve Path="LocalizedStrings.cs" />
121+
</Project>
111122
<Project Name="MsgPack.UnitTest.BclExtensions.WinRT" Base="MsgPack.UnitTest.BclExtensions">
112123
<Preserve Path="Properties\AssemblyInfo.cs" />
113124
<Exclude File="*.ps1" />

src/MsgPack.Silverlight.WindowsPhone/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
[assembly: AllowPartiallyTrustedCallers]
3333

3434
#if DEBUG || PERFORMANCE_TEST
35-
[assembly: InternalsVisibleTo( "MsgPack.Silverlight.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )]
35+
[assembly: InternalsVisibleTo( "MsgPack.UnitTest.Silverlight.WindowsPhone" )]
3636
#endif
3737

3838

src/MsgPack/MessagePackObjectDictionary.KeySet.Enumerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ namespace MsgPack
3333
{
3434
partial class MessagePackObjectDictionary
3535
{
36-
#if !WINDOWS_PHONE && !UNITY
36+
#if !UNITY
3737
partial class KeySet
3838
#else
3939
partial class KeyCollection
40-
#endif // !WINDOWS_PHONE && !UNITY
40+
#endif // UNITY
4141
{
42-
#if !WINDOWS_PHONE && !UNITY
42+
#if !UNITY
4343
/// <summary>
4444
/// Enumerates the elements of a <see cref="MessagePackObjectDictionary.KeySet"/>.
4545
/// </summary>
@@ -50,7 +50,7 @@ public struct Enumerator : IEnumerator<MessagePackObject>
5050
/// Enumerates the elements of a <see cref="MessagePackObjectDictionary.KeyCollection"/>.
5151
/// </summary>
5252
public struct Enumerator : IEnumerator<MessagePackObject>
53-
#endif // !WINDOWS_PHONE && !UNITY
53+
#endif // !UNITY
5454
{
5555
// This field must not be readonly because it will cause infinite loop to the user of this type
5656
// due to C# compiler emit ldfld instead of ldflda and state of this field will never change.

src/MsgPack/MessagePackObjectDictionary.KeySet.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ partial class MessagePackObjectDictionary
4444
[DebuggerDisplay( "Count={Count}" )]
4545
[DebuggerTypeProxy( typeof( CollectionDebuggerProxy<> ) )]
4646
[SuppressMessage( "Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "ICollection implementing dictionary should return ICollection implementing values." )]
47-
#if !WINDOWS_PHONE && !UNITY
47+
#if !UNITY
4848
public sealed partial class KeySet :
4949
#if !NETFX_35
5050
ISet<MessagePackObject>,
51-
#endif // !NETFX_35 && !UNITY
51+
#endif // !NETFX_35
5252
#else
5353
public sealed partial class KeyCollection :
54-
#endif
54+
#endif // !UNITY
5555
// ReSharper disable once RedundantExtendsListEntry
5656
ICollection<MessagePackObject>, ICollection
5757
{
@@ -83,11 +83,11 @@ object ICollection.SyncRoot
8383
get { return this; }
8484
}
8585

86-
#if !WINDOWS_PHONE && !UNITY
86+
#if !UNITY
8787
internal KeySet( MessagePackObjectDictionary dictionary )
8888
#else
8989
internal KeyCollection( MessagePackObjectDictionary dictionary )
90-
#endif
90+
#endif // !UNITY
9191
{
9292
#if !UNITY
9393
Contract.Assert( dictionary != null );
@@ -222,7 +222,7 @@ bool ICollection<MessagePackObject>.Remove( MessagePackObject item )
222222
throw new NotSupportedException();
223223
}
224224

225-
#if !WINDOWS_PHONE && !UNITY
225+
#if !UNITY
226226
#if !NETFX_35
227227
bool ISet<MessagePackObject>.Add( MessagePackObject item )
228228
{
@@ -353,7 +353,7 @@ void ISet<MessagePackObject>.UnionWith( IEnumerable<MessagePackObject> other )
353353
throw new NotSupportedException();
354354
}
355355
#endif // !NETFX_35
356-
#endif // !WINDOWS_PHONE && !UNITY
356+
#endif // !UNITY
357357

358358
/// <summary>
359359
/// Returns an enumerator that iterates through this collction.

src/MsgPack/MessagePackObjectDictionary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public MessagePackObject this[ MessagePackObject key ]
159159
}
160160
}
161161

162-
#if !WINDOWS_PHONE && !UNITY
162+
#if !UNITY
163163
/// <summary>
164164
/// Gets an <see cref="KeySet"/> containing the keys of the <see cref="MessagePackObjectDictionary"/>.
165165
/// </summary>
@@ -197,7 +197,7 @@ public KeyCollection Keys
197197
return new KeyCollection( this );
198198
}
199199
}
200-
#endif // !WINDOWS_PHONE && !UNITY
200+
#endif // !UNITY
201201

202202
/// <summary>
203203
/// Gets an <see cref="ValueCollection"/> containing the values of the <see cref="MessagePackObjectDictionary"/>.

src/MsgPack/MessagePackString.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ private static bool EqualsEncoded( MessagePackString left, MessagePackString rig
257257
return false;
258258
}
259259

260-
#if !WINDOWS_PHONE && !UNITY
260+
#if !UNITY
261261
if ( _isFastEqualsDisabled == 0 )
262262
{
263263
try
@@ -273,7 +273,7 @@ private static bool EqualsEncoded( MessagePackString left, MessagePackString rig
273273
Interlocked.Exchange( ref _isFastEqualsDisabled, 1 );
274274
}
275275
}
276-
#endif // if !WINDOWS_PHONE && !UNITY
276+
#endif // if !UNITY
277277

278278
return SlowEquals( left._encoded, right._encoded );
279279
}
@@ -291,13 +291,13 @@ private static bool SlowEquals( byte[] x, byte[] y )
291291
return true;
292292
}
293293

294-
#if !WINDOWS_PHONE && !UNITY
295-
#if SILVERLIGHT
294+
#if !UNITY
295+
#if SILVERLIGHT && !WINDOWS_PHONE
296296
private static int _isFastEqualsDisabled =
297297
System.Windows.Application.Current.HasElevatedPermissions ? 0 : 1;
298298
#else
299299
private static int _isFastEqualsDisabled;
300-
#endif // if SILVERLIGHT
300+
#endif // if SILVERLIGHT && !WINDOWS_PHONE
301301

302302
#if DEBUG
303303
// for testing
@@ -327,7 +327,7 @@ private static bool UnsafeFastEquals( byte[] x, byte[] y )
327327

328328
return result == 0;
329329
}
330-
#endif // if !WINDOWS_PHONE && !UNITY
330+
#endif // if !UNITY
331331

332332
#if !SILVERLIGHT && !NETFX_CORE
333333
[Serializable]

src/MsgPack/Serialization/SerializationContext.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ namespace MsgPack.Serialization
4949
/// </summary>
5050
public sealed class SerializationContext
5151
{
52+
#if UNITY
53+
private static readonly object DefaultContextSyncRoot = new object();
54+
#endif // UNITY
5255
// Set SerializerRepository null because it requires SerializationContext, so re-init in constructor.
5356
private static SerializationContext _default = new SerializationContext( default( SerializerRepository ) );
5457

@@ -61,15 +64,32 @@ public sealed class SerializationContext
6164
/// <exception cref="ArgumentNullException">The setting value is <c>null</c>.</exception>
6265
public static SerializationContext Default
6366
{
64-
get { return Interlocked.CompareExchange( ref _default, null, null ); }
67+
get
68+
{
69+
#if !UNITY
70+
return Interlocked.CompareExchange( ref _default, null, null );
71+
#else
72+
lock( DefaultContextSyncRoot )
73+
{
74+
return _default;
75+
}
76+
#endif // !UNITY
77+
}
6578
set
6679
{
6780
if ( value == null )
6881
{
6982
throw new ArgumentNullException( "value" );
7083
}
7184

85+
#if !UNITY
7286
Interlocked.Exchange( ref _default, value );
87+
#else
88+
lock( DefaultContextSyncRoot )
89+
{
90+
_default = value;
91+
}
92+
#endif // !UNITY
7393
}
7494
}
7595

0 commit comments

Comments
 (0)