2424
2525using System ;
2626#if ! UNITY || MSGPACK_UNITY_FULL
27+ using System . ComponentModel ;
2728#endif // !UNITY || MSGPACK_UNITY_FULL
2829#if FEATURE_CONCURRENT
2930using System . Collections . Concurrent ;
3637using System . Diagnostics . Contracts ;
3738#endif // FEATURE_MPCONTRACT
3839#if UNITY || NETSTANDARD1_1 || NETSTANDARD1_3
39- using System . Linq ;
4040#endif // UNITY || NETSTANDARD1_1 || NETSTANDARD1_3
4141#if UNITY || WINDOWS_PHONE || WINDOWS_UWP
4242using System . Reflection ;
4343#endif // UNITY || WINDOWS_PHONE || WINDOWS_UWP
44- using System . Threading ;
4544
4645using MsgPack . Serialization . DefaultSerializers ;
4746using MsgPack . Serialization . Polymorphic ;
@@ -83,7 +82,7 @@ public static SerializationContext Default
8382#if ! UNITY
8483 return Interlocked . CompareExchange ( ref _default , null , null ) ;
8584#else
86- lock ( DefaultContextSyncRoot )
85+ lock ( DefaultContextSyncRoot )
8786 {
8887 return _default ;
8988 }
@@ -99,7 +98,7 @@ public static SerializationContext Default
9998#if ! UNITY
10099 Interlocked . Exchange ( ref _default , value ) ;
101100#else
102- lock ( DefaultContextSyncRoot )
101+ lock ( DefaultContextSyncRoot )
103102 {
104103 _default = value ;
105104 }
@@ -116,27 +115,6 @@ public static SerializationContext Default
116115
117116 private readonly object _generationLock ;
118117
119- private readonly BindingOptions _bindingOptions ;
120-
121- /// <summary>
122- /// Gets the option settings for binding of type with serializer for field/property.
123- /// </summary>
124- /// <value>
125- /// The option settings for binding of type's property/field in serializer generation.
126- /// This value will not be <c>null</c>.
127- /// </value>
128- public BindingOptions BindingOptions
129- {
130- get
131- {
132- #if DEBUG
133- Contract . Ensures ( Contract . Result < BindingOptions > ( ) != null ) ;
134- #endif // DEBUG
135-
136- return this . _bindingOptions ;
137- }
138- }
139-
140118 /// <summary>
141119 /// Gets the current <see cref="SerializerRepository"/>.
142120 /// </summary>
@@ -155,7 +133,20 @@ public SerializerRepository Serializers
155133 }
156134 }
157135
158- private readonly SerializerOptions _serializerGeneratorOptions ;
136+ private readonly BindingOptions _bindingOptions ;
137+
138+ public BindingOptions BindingOptions
139+ {
140+ get
141+ {
142+ #if DEBUG
143+ Contract . Ensures ( Contract . Result < BindingOptions > ( ) != null ) ;
144+ #endif // DEBUG
145+ return this . _bindingOptions ;
146+ }
147+ }
148+
149+ private readonly SerializerOptions _serializerGeneratorOptions ;
159150
160151 /// <summary>
161152 /// Gets the option settings for serializer generation.
@@ -415,7 +406,7 @@ public event EventHandler<ResolveSerializerEventArgs> ResolveSerializer
415406 add
416407 {
417408#if UNITY
418- lock ( this . _resolveSerializerSyncRoot )
409+ lock ( this . _resolveSerializerSyncRoot )
419410 {
420411 this . _resolveSerializer += value ;
421412 }
@@ -435,7 +426,7 @@ public event EventHandler<ResolveSerializerEventArgs> ResolveSerializer
435426 remove
436427 {
437428#if UNITY
438- lock ( this . _resolveSerializerSyncRoot )
429+ lock ( this . _resolveSerializerSyncRoot )
439430 {
440431 // ReSharper disable once DelegateSubtraction
441432 this . _resolveSerializer -= value ;
@@ -457,21 +448,21 @@ public event EventHandler<ResolveSerializerEventArgs> ResolveSerializer
457448 private MessagePackSerializer < T > OnResolveSerializer < T > ( PolymorphismSchema schema )
458449 {
459450#if UNITY
460- lock ( this . _resolveSerializerSyncRoot )
451+ lock ( this . _resolveSerializerSyncRoot )
461452 {
462- var handler = this . _resolveSerializer ;
453+ var handler = this . _resolveSerializer ;
463454#else
464455 var handler = Interlocked . CompareExchange ( ref this . _resolveSerializer , null , null ) ;
465456#endif
466- if ( handler == null )
467- {
468- return null ;
469- }
457+ if ( handler == null )
458+ {
459+ return null ;
460+ }
470461
471- // Lazily allocate event args memory.
472- var e = new ResolveSerializerEventArgs ( this , typeof ( T ) , schema ) ;
473- handler ( this , e ) ;
474- return e . GetFoundSerializer < T > ( ) ;
462+ // Lazily allocate event args memory.
463+ var e = new ResolveSerializerEventArgs ( this , typeof ( T ) , schema ) ;
464+ handler ( this , e ) ;
465+ return e . GetFoundSerializer < T > ( ) ;
475466#if UNITY
476467 }
477468#endif
@@ -563,7 +554,7 @@ public SerializationContext( PackerCompatibilityOptions packerCompatibilityOptio
563554 this . _serializerGeneratorOptions = new SerializerOptions ( ) ;
564555 this . _dictionarySerializationOptions = new DictionarySerlaizationOptions ( ) ;
565556 this . _enumSerializationOptions = new EnumSerializationOptions ( ) ;
566- this . _bindingOptions = new BindingOptions ( ) ;
557+ this . _bindingOptions = new BindingOptions ( ) ;
567558 }
568559
569560 internal bool ContainsSerializer ( Type rootType )
@@ -679,11 +670,11 @@ public MessagePackSerializer<T> GetSerializer<T>( object providerParameter )
679670 if ( ! this . _serializerGeneratorOptions . CanRuntimeCodeGeneration )
680671 {
681672#endif // !UNITY
682- // On debugging, or AOT only envs, use reflection based aproach.
683- serializer =
684- this . GetSerializerWithoutGeneration < T > ( schema )
685- ?? this . OnResolveSerializer < T > ( schema )
686- ?? MessagePackSerializer . CreateReflectionInternal < T > ( this , this . EnsureConcreteTypeRegistered ( typeof ( T ) ) , schema ) ;
673+ // On debugging, or AOT only envs, use reflection based aproach.
674+ serializer =
675+ this . GetSerializerWithoutGeneration < T > ( schema )
676+ ?? this . OnResolveSerializer < T > ( schema )
677+ ?? MessagePackSerializer . CreateReflectionInternal < T > ( this , this . EnsureConcreteTypeRegistered ( typeof ( T ) ) , schema ) ;
687678#if ! UNITY
688679 }
689680 else
@@ -764,10 +755,10 @@ out nullableSerializerProvider
764755 if ( lockTaken )
765756 {
766757#if ! FEATURE_CONCURRENT
767- lock ( this . _typeLock )
768- {
769- this . _typeLock . Remove ( typeof ( T ) ) ;
770- }
758+ lock ( this . _typeLock )
759+ {
760+ this . _typeLock . Remove ( typeof ( T ) ) ;
761+ }
771762#else
772763 object dummy ;
773764 this . _typeLock . TryRemove ( typeof ( T ) , out dummy ) ;
@@ -903,7 +894,7 @@ public MessagePackSerializer GetSerializer( Type targetType, object providerPara
903894 try
904895 {
905896#endif // UNITY
906- return SerializerGetter . Instance . Get ( this , targetType , providerParameter ) ;
897+ return SerializerGetter . Instance . Get ( this , targetType , providerParameter ) ;
907898#if UNITY
908899 }
909900 catch ( Exception ex )
0 commit comments