Skip to content

Commit 04fa086

Browse files
committed
Code cleanup.
1 parent 1d40840 commit 04fa086

6 files changed

Lines changed: 38 additions & 21 deletions

File tree

src/MsgPack.Net35/Tuple`n.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace System
2626
// This file generated from Tuple.tt T4Template.
2727
// Do not modify this file. Edit Tuple.tt instead.
2828

29-
#if !NETFX_35
29+
#if DEBUG
3030
internal static class Tuple
3131
{
3232

@@ -45,9 +45,7 @@ public static Tuple<T1, T2, T3, T4, T5> Create<T1, T2, T3, T4, T5>( T1 item1, T2
4545
return new Tuple<T1, T2, T3, T4, T5>( item1, item2, item3, item4, item5 );
4646
}
4747
}
48-
#if !WINDOWS_PHONE
4948
[Serializable]
50-
#endif
5149
internal class Tuple<T1, T2>
5250
{
5351
private readonly T1 _item1;
@@ -81,9 +79,7 @@ public override string ToString()
8179
return buffer.ToString();
8280
}
8381
}
84-
#if !WINDOWS_PHONE
8582
[Serializable]
86-
#endif
8783
internal class Tuple<T1, T2, T3, T4>
8884
{
8985
private readonly T1 _item1;
@@ -137,9 +133,7 @@ public override string ToString()
137133
return buffer.ToString();
138134
}
139135
}
140-
#if !WINDOWS_PHONE
141136
[Serializable]
142-
#endif
143137
internal class Tuple<T1, T2, T3, T4, T5>
144138
{
145139
private readonly T1 _item1;
@@ -203,5 +197,5 @@ public override string ToString()
203197
return buffer.ToString();
204198
}
205199
}
206-
#endif // !NETFX_35
200+
#endif // DEBUG
207201
}

src/MsgPack.Net35/Tuple`n.tt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace System
6060
// This file generated from <#= __typeName #>.tt T4Template.
6161
// Do not modify this file. Edit <#= __typeName #>.tt instead.
6262

63-
#if !NETFX_35
63+
#if DEBUG
6464
internal static class Tuple
6565
{
6666
<#
@@ -82,9 +82,7 @@ foreach( int __arity in __arities )
8282
{
8383
var __tupleTypeName = __typeName + "<" + String.Join( ", ", Enumerable.Range( 1, __arity ).Select( num => "T" + num ) ) + ">";
8484
#>
85-
#if !WINDOWS_PHONE
8685
[Serializable]
87-
#endif
8886
internal class <#= __tupleTypeName #>
8987
{
9088
<#
@@ -145,5 +143,5 @@ foreach( int __arity in __arities )
145143
<#
146144
}
147145
#>
148-
#endif // !NETFX_35
146+
#endif // DEBUG
149147
}

src/MsgPack/MessagePackObjectDictionary.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ public int Count
8888
{
8989
get
9090
{
91+
#if !UNITY
9192
this.AssertInvariant();
93+
#endif // !UNITY
9294
return this._dictionary == null ? this._keys.Count : this._dictionary.Count;
9395
}
9496
}
@@ -151,10 +153,9 @@ public MessagePackObject this[ MessagePackObject key ]
151153

152154
#if !UNITY
153155
Contract.EndContractBlock();
154-
#endif // !UNITY
155-
156156

157157
this.AssertInvariant();
158+
#endif // !UNITY
158159
this.AddCore( key, value, true );
159160
}
160161
}
@@ -193,7 +194,9 @@ public KeyCollection Keys
193194
{
194195
get
195196
{
197+
#if !UNITY
196198
this.AssertInvariant();
199+
#endif // !UNITY
197200
return new KeyCollection( this );
198201
}
199202
}
@@ -213,7 +216,9 @@ public ValueCollection Values
213216
{
214217
get
215218
{
219+
#if !UNITY
216220
this.AssertInvariant();
221+
#endif // !UNITY
217222
return new ValueCollection( this );
218223
}
219224
}
@@ -437,10 +442,10 @@ private void VerifyIsNotFrozen()
437442
}
438443
}
439444

445+
#if !UNITY
440446
[Conditional( "DEBUG" )]
441447
private void AssertInvariant()
442448
{
443-
#if !UNITY
444449
if ( this._dictionary == null )
445450
{
446451
Contract.Assert( this._keys != null );
@@ -453,8 +458,8 @@ private void AssertInvariant()
453458
Contract.Assert( this._keys == null );
454459
Contract.Assert( this._values == null );
455460
}
456-
#endif // !UNITY
457461
}
462+
#endif // !UNITY
458463

459464
private static MessagePackObject ValidateObjectArgument( object obj, string parameterName )
460465
{
@@ -597,7 +602,9 @@ public bool ContainsKey( MessagePackObject key )
597602
#endif // !UNITY
598603

599604

600-
this.AssertInvariant();
605+
#if !UNITY
606+
this.AssertInvariant();
607+
#endif // !UNITY
601608
return
602609
this._dictionary == null
603610
? this._keys.Contains( key, MessagePackObjectEqualityComparer.Instance )
@@ -616,7 +623,9 @@ public bool ContainsKey( MessagePackObject key )
616623
/// </remarks>
617624
public bool ContainsValue( MessagePackObject value )
618625
{
619-
this.AssertInvariant();
626+
#if !UNITY
627+
this.AssertInvariant();
628+
#endif // !UNITY
620629
return
621630
this._dictionary == null
622631
? this._values.Contains( value, MessagePackObjectEqualityComparer.Instance )
@@ -692,10 +701,9 @@ public bool TryGetValue( MessagePackObject key, out MessagePackObject value )
692701

693702
#if !UNITY
694703
Contract.EndContractBlock();
695-
#endif // !UNITY
696-
697704

698705
this.AssertInvariant();
706+
#endif // !UNITY
699707

700708
if ( this._dictionary == null )
701709
{
@@ -918,8 +926,9 @@ private bool RemoveCore( MessagePackObject key, MessagePackObject value, bool ch
918926
{
919927
#if !UNITY
920928
Contract.Assert( !key.IsNil );
921-
#endif // !UNITY
922929
this.AssertInvariant();
930+
#endif // !UNITY
931+
923932
if ( this._dictionary == null )
924933
{
925934
int index = this._keys.FindIndex( item => item == key );
@@ -1013,7 +1022,9 @@ public void Clear()
10131022
{
10141023
this.VerifyIsNotFrozen();
10151024

1025+
#if !UNITY
10161026
this.AssertInvariant();
1027+
#endif // !UNITY
10171028

10181029
if ( this._dictionary == null )
10191030
{

src/MsgPack/Serialization/CollectionTraits.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ internal sealed class CollectionTraits
3232
public static readonly CollectionTraits NotCollection = new CollectionTraits( CollectionDetailedKind.NotCollection, null, null, null, null );
3333
public static readonly CollectionTraits Unserializable = new CollectionTraits( CollectionDetailedKind.Unserializable, null, null, null, null );
3434

35+
#if UNITY
36+
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
37+
#endif // UNITY
3538
public readonly MethodInfo GetEnumeratorMethod;
3639
public readonly MethodInfo AddMethod;
40+
#if UNITY
41+
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
42+
#endif // UNITY
3743
public readonly PropertyInfo CountProperty;
3844
public readonly Type ElementType;
3945

src/MsgPack/Serialization/IdentifierUtility.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
//
1919
#endregion -- License Terms --
2020

21+
#if UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_WII || UNITY_IPHONE || UNITY_ANDROID || UNITY_PS3 || UNITY_XBOX360 || UNITY_FLASH || UNITY_BKACKBERRY || UNITY_WINRT
22+
#define UNITY
23+
#endif
24+
2125
using System;
2226
using System.Text;
2327
using MsgPack.Serialization.Reflection;
2428

2529
namespace MsgPack.Serialization
2630
{
31+
#if !UNITY
2732
/// <summary>
2833
/// Utilities related to member/type ID.
2934
/// </summary>
@@ -118,4 +123,5 @@ public static string EscapeTypeName( string fullName )
118123
return result.ToString();
119124
}
120125
}
126+
#endif // !UNITY
121127
}

src/MsgPack/Serialization/SerializationExceptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public static Exception NewMissingItem( int index )
155155
return new InvalidMessagePackStreamException( String.Format( CultureInfo.CurrentCulture, "Items at index '{0}' is missing.", index ) );
156156
}
157157

158+
#if !UNITY
158159
/// <summary>
159160
/// <strong>This is intended to MsgPack for CLI internal use. Do not use this type from application directly.</strong>
160161
/// Returns new exception to notify that target type is not serializable because it does not have public default constructor.
@@ -170,6 +171,7 @@ internal static Exception NewTargetDoesNotHavePublicDefaultConstructor( Type typ
170171

171172
return new SerializationException( String.Format( CultureInfo.CurrentCulture, "Type '{0}' does not have default (parameterless) public constructor.", type ) );
172173
}
174+
#endif // !UNITY
173175

174176
/// <summary>
175177
/// <strong>This is intended to MsgPack for CLI internal use. Do not use this type from application directly.</strong>

0 commit comments

Comments
 (0)