Skip to content

Commit b627c2b

Browse files
committed
Remove unused DynamicUnpackingContext
1 parent cbd4add commit b627c2b

File tree

4 files changed

+22
-223
lines changed

4 files changed

+22
-223
lines changed

src/MsgPack/Serialization/AbstractSerializers/DynamicUnpackingContext.cs

Lines changed: 0 additions & 70 deletions
This file was deleted.

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

Lines changed: 11 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -880,24 +880,7 @@ private TConstruct EmitObjectUnpackFromCore( TContext context, SerializationTarg
880880
var unpackedItem =
881881
context.DefineUnpackedItemParameterInSetValueMethods( targetInfo.Members[ count ].Member.GetMemberValueType() );
882882
Func<TConstruct> storeValueStatementEmitter;
883-
if ( unpackingContext.VariableType.TryGetRuntimeType() == typeof( DynamicUnpackingContext ) )
884-
{
885-
storeValueStatementEmitter =
886-
() =>
887-
this.EmitInvokeVoidMethod(
888-
context,
889-
context.UnpackingContextInSetValueMethods,
890-
Metadata._DynamicUnpackingContext.Set,
891-
this.MakeStringLiteral( context, name ),
892-
targetInfo.Members[ count ].Member.GetMemberValueType().GetIsValueType()
893-
? this.EmitBoxExpression(
894-
context,
895-
unpackedItem.ContextType,
896-
unpackedItem
897-
) : unpackedItem
898-
);
899-
}
900-
else if ( targetInfo.IsConstructorDeserialization || this.TargetType.GetIsValueType() )
883+
if ( targetInfo.IsConstructorDeserialization || this.TargetType.GetIsValueType() )
901884
{
902885
storeValueStatementEmitter =
903886
() =>
@@ -1142,39 +1125,7 @@ IEnumerable<TConstruct> argumentInitializers
11421125
unpackingContext.Statements.AddRange( argumentInitializers );
11431126

11441127
unpackingContext.Statements.Add(
1145-
unpackingContext.VariableType.TryGetRuntimeType() == typeof( DynamicUnpackingContext )
1146-
? this.EmitSequentialStatements(
1147-
context,
1148-
TypeDefinition.VoidType,
1149-
new[]
1150-
{
1151-
this.EmitStoreVariableStatement(
1152-
context,
1153-
unpackingContext.Variable,
1154-
this.EmitCreateNewObjectExpression(
1155-
context,
1156-
unpackingContext.Variable,
1157-
unpackingContext.Constructor,
1158-
this.MakeInt32Literal( context, constructorArguments.Count )
1159-
)
1160-
)
1161-
}.Concat(
1162-
constructorArguments.Select( ( a, i ) =>
1163-
this.EmitInvokeVoidMethod(
1164-
context,
1165-
unpackingContext.Variable,
1166-
Metadata._DynamicUnpackingContext.Set,
1167-
this.MakeStringLiteral( context, contextFields[ i ].Key ),
1168-
a.ContextType.ResolveRuntimeType().GetIsValueType()
1169-
? this.EmitBoxExpression(
1170-
context,
1171-
a.ContextType,
1172-
a
1173-
) : a
1174-
)
1175-
)
1176-
)
1177-
) : this.EmitStoreVariableStatement(
1128+
this.EmitStoreVariableStatement(
11781129
context,
11791130
unpackingContext.Variable,
11801131
this.EmitCreateNewObjectExpression(
@@ -1218,26 +1169,15 @@ private IEnumerable<TConstruct> EmitCreateObjectFromContextCore(
12181169
context,
12191170
result,
12201171
member,
1221-
unpackingContext.VariableType.TryGetRuntimeType() == typeof( DynamicUnpackingContext )
1222-
? this.EmitUnboxAnyExpression(
1223-
context,
1224-
field.Value,
1225-
this.EmitInvokeMethodExpression(
1226-
context,
1227-
context.UnpackingContextInCreateObjectFromContext,
1228-
Metadata._DynamicUnpackingContext.Get,
1229-
this.MakeStringLiteral( context, field.Key )
1230-
)
1231-
)
1232-
: this.EmitGetFieldExpression(
1233-
context,
1234-
context.UnpackingContextInCreateObjectFromContext,
1235-
new FieldDefinition(
1236-
unpackingContext.Type,
1237-
field.Key,
1238-
field.Value
1239-
)
1172+
this.EmitGetFieldExpression(
1173+
context,
1174+
context.UnpackingContextInCreateObjectFromContext,
1175+
new FieldDefinition(
1176+
unpackingContext.Type,
1177+
field.Key,
1178+
field.Value
12401179
)
1180+
)
12411181
);
12421182
}
12431183

@@ -1517,18 +1457,7 @@ private IEnumerable<TConstruct> EmitInvokeDeserializationConstructorStatementsCo
15171457
constructor,
15181458
fields.Select(
15191459
f =>
1520-
unpackingContext.ContextType.TryGetRuntimeType() == typeof( DynamicUnpackingContext )
1521-
? this.EmitUnboxAnyExpression(
1522-
context,
1523-
f.Value,
1524-
this.EmitInvokeMethodExpression(
1525-
context,
1526-
unpackingContext,
1527-
Metadata._DynamicUnpackingContext.Get,
1528-
this.MakeStringLiteral( context, f.Key )
1529-
)
1530-
)
1531-
: this.EmitGetFieldExpression( context, unpackingContext, new FieldDefinition( unpackingContext.ContextType, f.Key, f.Value ) )
1460+
this.EmitGetFieldExpression( context, unpackingContext, new FieldDefinition( unpackingContext.ContextType, f.Key, f.Value ) )
15321461
).ToArray()
15331462
)
15341463
);

src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Tuple.cs

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,8 @@ private IEnumerable<TConstruct> BuildTupleUnpackFromCore( TContext context, ILis
350350
setUnpackValueOfMethodName,
351351
false, // isStatic
352352
TypeDefinition.VoidType,
353-
() => unpackingContext.VariableType.TryGetRuntimeType() == typeof( DynamicUnpackingContext )
354-
? this.EmitInvokeVoidMethod(
355-
context,
356-
context.UnpackingContextInSetValueMethods,
357-
Metadata._DynamicUnpackingContext.Set,
358-
this.MakeStringLiteral( context, propertyName ),
359-
this.EmitBoxExpression(
360-
context,
361-
itemTypes[ index ],
362-
unpackedItem
363-
)
364-
) : this.EmitSetField(
353+
() =>
354+
this.EmitSetField(
365355
context,
366356
context.UnpackingContextInSetValueMethods,
367357
unpackingContext.VariableType,
@@ -383,25 +373,15 @@ private IEnumerable<TConstruct> BuildTupleUnpackFromCore( TContext context, ILis
383373
var gets =
384374
Enumerable.Range( nest * 7, Math.Min( itemTypes.Count - nest * 7, 7 ) )
385375
.Select( i =>
386-
unpackingContext.VariableType.TryGetRuntimeType() == typeof( DynamicUnpackingContext )
387-
? this.EmitUnboxAnyExpression(
388-
context,
389-
itemTypes[ i ],
390-
this.EmitInvokeMethodExpression(
391-
context,
392-
context.UnpackingContextInCreateObjectFromContext,
393-
Metadata._DynamicUnpackingContext.Get,
394-
this.MakeStringLiteral( context, SerializationTarget.GetTupleItemNameFromIndex( i ) )
395-
)
396-
) : this.EmitGetFieldExpression(
397-
context,
398-
context.UnpackingContextInCreateObjectFromContext,
399-
new FieldDefinition(
400-
unpackingContext.VariableType,
401-
SerializationTarget.GetTupleItemNameFromIndex( i ),
402-
itemTypes[ i ]
403-
)
376+
this.EmitGetFieldExpression(
377+
context,
378+
context.UnpackingContextInCreateObjectFromContext,
379+
new FieldDefinition(
380+
unpackingContext.VariableType,
381+
SerializationTarget.GetTupleItemNameFromIndex( i ),
382+
itemTypes[ i ]
404383
)
384+
)
405385
);
406386
if ( currentTuple != null )
407387
{
@@ -499,9 +479,7 @@ out constructor
499479
context,
500480
unpackingContext.Variable,
501481
unpackingContext.Constructor,
502-
unpackingContext.VariableType.TryGetRuntimeType() == typeof( DynamicUnpackingContext )
503-
? new[] { this.MakeInt32Literal( context, itemTypes.Count ) }
504-
: itemTypes.Select( t => this.MakeDefaultLiteral( context, t ) ).ToArray()
482+
itemTypes.Select( t => this.MakeDefaultLiteral( context, t ) ).ToArray()
505483
)
506484
)
507485
);

src/MsgPack/Serialization/Metadata/_DynamicUnpackingContext.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)