Skip to content

Commit f4cd436

Browse files
committed
Reorder 'switch cases' constructs to more natural order. Merging PR #50 is done.
1 parent d7469e6 commit f4cd436

File tree

6 files changed

+12
-16
lines changed

6 files changed

+12
-16
lines changed

src/MsgPack/Serialization/AbstractSerializers/SerializerBuilderContract`3.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ protected override TConstruct EmitAndConditionalExpression( TContext context, IL
451451
return default( TConstruct );
452452
}
453453

454-
protected override TConstruct EmitStringSwitchStatement (TContext context, TConstruct target, TConstruct defaultCase, IDictionary<string, TConstruct> cases) {
454+
protected override TConstruct EmitStringSwitchStatement ( TContext context, TConstruct target, IDictionary<string, TConstruct> cases, TConstruct defaultCase ) {
455455
Contract.Requires(context != null);
456456
Contract.Requires(target != null);
457457
Contract.Requires(defaultCase != null);

src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`3.CommonConstructs.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,9 +1295,7 @@ TConstruct elseExpression
12951295
/// <param name="cases">The case statements. The keys are case condition, and values are actual statement.</param>
12961296
/// <param name="defaultCase">Default case expression.</param>
12971297
/// <returns>The switch statement.</returns>
1298-
protected abstract TConstruct EmitStringSwitchStatement (
1299-
TContext context, TConstruct target, TConstruct defaultCase, IDictionary<string, TConstruct> cases
1300-
);
1298+
protected abstract TConstruct EmitStringSwitchStatement ( TContext context, TConstruct target, IDictionary<string, TConstruct> cases, TConstruct defaultCase );
13011299

13021300
/// <summary>
13031301
/// Emits the return statement

src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`3.Object.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,6 @@ private IEnumerable<TConstruct> EmitObjectUnpackFromMapCore( TContext context, T
440440
this.EmitStringSwitchStatement(
441441
context,
442442
key,
443-
this.EmitInvokeVoidMethod(
444-
context,
445-
context.Unpacker,
446-
typeof( Unpacker ).GetMethod( "Skip" )
447-
),
448443
entries.Where( e => e.Member != null ).ToDictionary(
449444
entry => entry.Contract.Name,
450445
entry =>
@@ -461,8 +456,13 @@ private IEnumerable<TConstruct> EmitObjectUnpackFromMapCore( TContext context, T
461456
unpackedValue =>
462457
this.EmitSetMemberValueStatement( context, result, entry.Member, unpackedValue )
463458
)
464-
)
465-
);
459+
),
460+
this.EmitInvokeVoidMethod(
461+
context,
462+
context.Unpacker,
463+
typeof( Unpacker ).GetMethod( "Skip" )
464+
)
465+
);
466466

467467
return this.EmitSequentialStatements( context, typeof( void ), key, unpackKey, assigns );
468468
}

src/MsgPack/Serialization/CodeDomSerializers/CodeDomSerializerBuilder`1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ protected override CodeDomConstruct EmitAndConditionalExpression( CodeDomContext
646646
);
647647
}
648648

649-
protected override CodeDomConstruct EmitStringSwitchStatement (CodeDomContext context, CodeDomConstruct target, CodeDomConstruct defaultCase, IDictionary<string, CodeDomConstruct> cases) {
649+
protected override CodeDomConstruct EmitStringSwitchStatement ( CodeDomContext context, CodeDomConstruct target, IDictionary<string, CodeDomConstruct> cases, CodeDomConstruct defaultCase ) {
650650
#if DEBUG
651651
Contract.Assert(target.IsExpression);
652652
Contract.Assert(defaultCase.IsStatement);

src/MsgPack/Serialization/EmittingSerializers/ILEmittingSerializerBuilder`2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ protected override ILConstruct EmitAndConditionalExpression( TContext context, I
677677
}
678678

679679
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "2", Justification = "Asserted internally")]
680-
protected override ILConstruct EmitStringSwitchStatement (TContext context, ILConstruct target, ILConstruct defaultCase, IDictionary<string, ILConstruct> cases) {
680+
protected override ILConstruct EmitStringSwitchStatement ( TContext context, ILConstruct target, IDictionary<string, ILConstruct> cases, ILConstruct defaultCase ) {
681681
// Simple if statements
682682
ILConstruct @else = defaultCase;
683683
foreach (var @case in cases) {

src/MsgPack/Serialization/ExpressionSerializers/ExpressionTreeSerializerBuilder`1.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,7 @@ ExpressionConstruct elseExpression
467467
);
468468
}
469469

470-
protected override ExpressionConstruct EmitStringSwitchStatement (
471-
ExpressionTreeContext context, ExpressionConstruct target, ExpressionConstruct defaultCase, IDictionary<string, ExpressionConstruct> cases
472-
) {
470+
protected override ExpressionConstruct EmitStringSwitchStatement ( ExpressionTreeContext context, ExpressionConstruct target, IDictionary<string, ExpressionConstruct> cases, ExpressionConstruct defaultCase ) {
473471
return
474472
Expression.Switch(
475473
typeof( void ),

0 commit comments

Comments
 (0)