Skip to content

Commit

Permalink
Fix built-in serializer helpers failed in non-privileged Silverlight …
Browse files Browse the repository at this point in the history
…environment. Fix #205
  • Loading branch information
yfakariya committed Jan 29, 2017
1 parent 0e30f86 commit e9ff9af
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 20 deletions.
84 changes: 72 additions & 12 deletions src/MsgPack/Serialization/DefaultSerializers/GenericSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,23 @@ internal static bool IsSupported( Type type, CollectionTraits traits, bool prefe
/// <summary>
/// Defines non-generic factory method for built-in serializers which require generic type argument.
/// </summary>
private interface IGenericBuiltInSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
interface IGenericBuiltInSerializerFactory
{
MessagePackSerializer Create( SerializationContext context, PolymorphismSchema schema );
}

[Preserve( AllMembers = true )]
private sealed class NullableInstanceFactory<T> : IGenericBuiltInSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class NullableInstanceFactory<T> : IGenericBuiltInSerializerFactory
where T : struct
{
public NullableInstanceFactory() { }
Expand All @@ -556,7 +566,12 @@ public MessagePackSerializer Create( SerializationContext context, PolymorphismS
}

[Preserve( AllMembers = true )]
private sealed class ListInstanceFactory<T> : IGenericBuiltInSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class ListInstanceFactory<T> : IGenericBuiltInSerializerFactory
{
public ListInstanceFactory() { }

Expand All @@ -568,7 +583,12 @@ public MessagePackSerializer Create( SerializationContext context, PolymorphismS
}

[Preserve( AllMembers = true )]
private sealed class DictionaryInstanceFactory<TKey, TValue> : IGenericBuiltInSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class DictionaryInstanceFactory<TKey, TValue> : IGenericBuiltInSerializerFactory
{
public DictionaryInstanceFactory() { }

Expand Down Expand Up @@ -656,14 +676,24 @@ public MessagePackSerializer Create( SerializationContext context, PolymorphismS
/// <summary>
/// Defines non-generic factory method for 'universal' serializers which use general collection features.
/// </summary>
private interface IVariantSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
interface IVariantSerializerFactory
{
MessagePackSerializer Create( SerializationContext context, Type targetType, PolymorphismSchema schema );
}

// ReSharper disable MemberHidesStaticFromOuterClass
[Preserve( AllMembers = true )]
private sealed class NonGenericEnumerableSerializerFactory<T> : IVariantSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class NonGenericEnumerableSerializerFactory<T> : IVariantSerializerFactory
where T : IEnumerable
{
public NonGenericEnumerableSerializerFactory() { }
Expand All @@ -675,7 +705,12 @@ public MessagePackSerializer Create( SerializationContext context, Type targetTy
}

[Preserve( AllMembers = true )]
private sealed class NonGenericCollectionSerializerFactory<T> : IVariantSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class NonGenericCollectionSerializerFactory<T> : IVariantSerializerFactory
where T : ICollection
{
public NonGenericCollectionSerializerFactory() { }
Expand All @@ -687,7 +722,12 @@ public MessagePackSerializer Create( SerializationContext context, Type targetTy
}

[Preserve( AllMembers = true )]
private sealed class NonGenericListSerializerFactory<T> : IVariantSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class NonGenericListSerializerFactory<T> : IVariantSerializerFactory
where T : IList
{
public NonGenericListSerializerFactory() { }
Expand All @@ -699,7 +739,12 @@ public MessagePackSerializer Create( SerializationContext context, Type targetTy
}

[Preserve( AllMembers = true )]
private sealed class NonGenericDictionarySerializerFactory<T> : IVariantSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class NonGenericDictionarySerializerFactory<T> : IVariantSerializerFactory
where T : IDictionary
{
public NonGenericDictionarySerializerFactory() { }
Expand All @@ -711,7 +756,12 @@ public MessagePackSerializer Create( SerializationContext context, Type targetTy
}

[Preserve( AllMembers = true )]
private sealed class EnumerableSerializerFactory<TCollection, TItem> : IVariantSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class EnumerableSerializerFactory<TCollection, TItem> : IVariantSerializerFactory
where TCollection : IEnumerable<TItem>
{
public EnumerableSerializerFactory() { }
Expand All @@ -723,7 +773,12 @@ public MessagePackSerializer Create( SerializationContext context, Type targetTy
}

[Preserve( AllMembers = true )]
private sealed class CollectionSerializerFactory<TCollection, TItem> : IVariantSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class CollectionSerializerFactory<TCollection, TItem> : IVariantSerializerFactory
where TCollection : ICollection<TItem>
{
public CollectionSerializerFactory() { }
Expand All @@ -749,7 +804,12 @@ public MessagePackSerializer Create( SerializationContext context, Type targetTy
#endif // !NETFX_35 && !UNITY && !NETFX_40 && !( SILVERLIGHT && !WINDOWS_PHONE )

[Preserve( AllMembers = true )]
private sealed class DictionarySerializerFactory<TDictionary, TKey, TValue> : IVariantSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class DictionarySerializerFactory<TDictionary, TKey, TValue> : IVariantSerializerFactory
where TDictionary : IDictionary<TKey, TValue>
{
public DictionarySerializerFactory() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,25 @@ public static Func<int, object> CreateCollectionInstanceFactory( Type abstractTy
/// <summary>
/// Defines non-generic factory method for 'universal' serializers which use general collection features.
/// </summary>
private interface IVariantReflectionSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
interface IVariantReflectionSerializerFactory
{
MessagePackSerializer Create( SerializationContext context, Type targetType, CollectionTraits collectionTraits, PolymorphismSchema schema, SerializationTarget targetInfo );
}

// ReSharper disable MemberHidesStaticFromOuterClass

[Preserve( AllMembers = true )]
private sealed class NonGenericEnumerableSerializerFactory<T> : IVariantReflectionSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class NonGenericEnumerableSerializerFactory<T> : IVariantReflectionSerializerFactory
where T : IEnumerable
{
public NonGenericEnumerableSerializerFactory() { }
Expand All @@ -447,7 +457,12 @@ public MessagePackSerializer Create( SerializationContext context, Type targetTy
}

[Preserve( AllMembers = true )]
private sealed class NonGenericCollectionSerializerFactory<T> : IVariantReflectionSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class NonGenericCollectionSerializerFactory<T> : IVariantReflectionSerializerFactory
where T : ICollection
{
public NonGenericCollectionSerializerFactory() { }
Expand All @@ -459,7 +474,12 @@ public MessagePackSerializer Create( SerializationContext context, Type targetTy
}

[Preserve( AllMembers = true )]
private sealed class NonGenericListSerializerFactory<T> : IVariantReflectionSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class NonGenericListSerializerFactory<T> : IVariantReflectionSerializerFactory
where T : IList
{
public NonGenericListSerializerFactory() { }
Expand All @@ -471,7 +491,12 @@ public MessagePackSerializer Create( SerializationContext context, Type targetTy
}

[Preserve( AllMembers = true )]
private sealed class NonGenericDictionarySerializerFactory<T> : IVariantReflectionSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class NonGenericDictionarySerializerFactory<T> : IVariantReflectionSerializerFactory
where T : IDictionary
{
public NonGenericDictionarySerializerFactory() { }
Expand All @@ -483,7 +508,12 @@ public MessagePackSerializer Create( SerializationContext context, Type targetTy
}

[Preserve( AllMembers = true )]
private sealed class EnumerableSerializerFactory<TCollection, TItem> : IVariantReflectionSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class EnumerableSerializerFactory<TCollection, TItem> : IVariantReflectionSerializerFactory
where TCollection : IEnumerable<TItem>
{
public EnumerableSerializerFactory() { }
Expand All @@ -496,7 +526,12 @@ public MessagePackSerializer Create( SerializationContext context, Type targetTy
}

[Preserve( AllMembers = true )]
private sealed class CollectionSerializerFactory<TCollection, TItem> : IVariantReflectionSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class CollectionSerializerFactory<TCollection, TItem> : IVariantReflectionSerializerFactory
where TCollection : ICollection<TItem>
{
public CollectionSerializerFactory() { }
Expand All @@ -509,7 +544,12 @@ public MessagePackSerializer Create( SerializationContext context, Type targetTy
}

[Preserve( AllMembers = true )]
private sealed class DictionarySerializerFactory<TDictionary, TKey, TValue> : IVariantReflectionSerializerFactory
#if SILVERLIGHT
internal
#else
private
#endif // SILVERLIGHT
sealed class DictionarySerializerFactory<TDictionary, TKey, TValue> : IVariantReflectionSerializerFactory
where TDictionary : IDictionary<TKey, TValue>
{
public DictionarySerializerFactory() { }
Expand Down

0 comments on commit e9ff9af

Please sign in to comment.