4 writes to ilg
System.Runtime.Serialization (4)
System\Runtime\Serialization\Json\JsonFormatReaderGenerator.cs (4)
121
ilg
= new CodeGenerator();
174
ilg
= GenerateCollectionReaderHelper(collectionContract, false /*isGetOnlyCollection*/);
183
ilg
= GenerateCollectionReaderHelper(collectionContract, true /*isGetOnlyCollection*/);
190
ilg
= new CodeGenerator();
299 references to ilg
System.Runtime.Serialization (299)
System\Runtime\Serialization\Json\JsonFormatReaderGenerator.cs (299)
125
BeginMethod(
ilg
, "Read" + classContract.StableName.Name + "FromJson", typeof(JsonFormatClassReaderDelegate), memberAccessFlag);
142
ilg
.Call(contextArg, XmlFormatGeneratorStatics.AddNewObjectMethod, objectLocal);
149
ilg
.Call(objectLocal, JsonFormatGeneratorStatics.OnDeserializationMethod, null);
153
ilg
.Load(objectLocal);
160
ilg
.ConvertValue(objectLocal.LocalType, Globals.TypeOfDateTimeOffsetAdapter);
161
ilg
.Call(XmlFormatGeneratorStatics.GetDateTimeOffsetMethod);
162
ilg
.ConvertValue(Globals.TypeOfDateTimeOffset,
ilg
.CurrentMethod.ReturnType);
166
ilg
.ConvertValue(objectLocal.LocalType,
ilg
.CurrentMethod.ReturnType);
169
return (JsonFormatClassReaderDelegate)
ilg
.EndMethod();
176
ilg
.Load(objectLocal);
177
ilg
.ConvertValue(objectLocal.LocalType,
ilg
.CurrentMethod.ReturnType);
178
return (JsonFormatCollectionReaderDelegate)
ilg
.EndMethod();
185
return (JsonFormatGetOnlyCollectionReaderDelegate)
ilg
.EndMethod();
196
BeginMethod(
ilg
, "Read" + collectionContract.StableName.Name + "FromJson" + "IsGetOnly", typeof(JsonFormatGetOnlyCollectionReaderDelegate), memberAccessFlag);
200
BeginMethod(
ilg
, "Read" + collectionContract.StableName.Name + "FromJson", typeof(JsonFormatCollectionReaderDelegate), memberAccessFlag);
216
collectionContractArg =
ilg
.GetArg(4);
217
return
ilg
;
239
xmlReaderArg =
ilg
.GetArg(0);
240
contextArg =
ilg
.GetArg(1);
241
emptyDictionaryStringArg =
ilg
.GetArg(2);
242
memberNamesArg =
ilg
.GetArg(3);
249
ilg
.Call(contextArg, XmlFormatGeneratorStatics.DemandMemberAccessPermissionMethod);
257
ilg
.Call(contextArg, XmlFormatGeneratorStatics.DemandSerializationFormatterPermissionMethod);
268
objectLocal =
ilg
.DeclareLocal(type, "objectDeserialized");
272
ilg
.LoadMember(Globals.TypeOfDBNull.GetField("Value"));
273
ilg
.Stloc(objectLocal);
279
ilg
.Ldloca(objectLocal);
280
ilg
.InitObj(type);
284
ilg
.New(classContract.GetNonAttributedTypeConstructor());
285
ilg
.Stloc(objectLocal);
290
ilg
.Call(null, JsonFormatGeneratorStatics.GetUninitializedObjectMethod, DataContract.GetIdForInitialization(classContract));
291
ilg
.ConvertValue(Globals.TypeOfObject, type);
292
ilg
.Stloc(objectLocal);
302
ilg
.LoadAddress(objectLocal);
303
ilg
.ConvertAddress(objectLocal.LocalType, objectType);
304
ilg
.Load(contextArg);
305
ilg
.LoadMember(XmlFormatGeneratorStatics.GetStreamingContextMethod);
306
ilg
.Call(classContract.OnDeserializing);
316
ilg
.LoadAddress(objectLocal);
317
ilg
.ConvertAddress(objectLocal.LocalType, objectType);
318
ilg
.Load(contextArg);
319
ilg
.LoadMember(XmlFormatGeneratorStatics.GetStreamingContextMethod);
320
ilg
.Call(classContract.OnDeserialized);
333
ilg
.Load(contextArg);
334
ilg
.LoadAddress(objectLocal);
335
ilg
.ConvertAddress(objectLocal.LocalType, Globals.TypeOfIObjectReference);
336
ilg
.Load(Globals.NewObjectId);
337
ilg
.Call(XmlFormatGeneratorStatics.GetRealObjectMethod);
338
ilg
.ConvertValue(Globals.TypeOfObject,
ilg
.CurrentMethod.ReturnType);
348
LocalBuilder extensionDataLocal =
ilg
.DeclareLocal(Globals.TypeOfExtensionDataObject, "extensionData");
349
ilg
.New(JsonFormatGeneratorStatics.ExtensionDataObjectCtor);
350
ilg
.Store(extensionDataLocal);
358
ilg
.Call(objectLocal, extensionDataSetMethod, extensionDataLocal);
369
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, memberCount);
371
BitFlagsGenerator expectedElements = new BitFlagsGenerator(memberCount,
ilg
, classContract.UnderlyingType.Name + "_ExpectedElements");
376
LocalBuilder memberIndexLocal =
ilg
.DeclareLocal(Globals.TypeOfInt, "memberIndex", -1);
377
Label throwDuplicateMemberLabel =
ilg
.DefineLabel();
378
Label throwMissingRequiredMembersLabel =
ilg
.DefineLabel();
380
object forReadElements =
ilg
.For(null, null, null);
381
ilg
.Call(null, XmlFormatGeneratorStatics.MoveToNextElementMethod, xmlReaderArg);
382
ilg
.IfFalseBreak(forReadElements);
383
ilg
.Call(contextArg, JsonFormatGeneratorStatics.GetJsonMemberIndexMethod, xmlReaderArg, memberNamesArg, memberIndexLocal, extensionDataLocal);
386
Label[] memberLabels =
ilg
.Switch(memberCount);
388
ilg
.EndSwitch();
392
ilg
.Pop();
394
ilg
.EndFor();
396
Label endOfTypeLabel =
ilg
.DefineLabel();
397
ilg
.Br(endOfTypeLabel);
399
ilg
.MarkLabel(throwDuplicateMemberLabel);
400
ilg
.Call(null, JsonFormatGeneratorStatics.ThrowDuplicateMemberExceptionMethod, objectLocal, memberNamesArg, memberIndexLocal);
402
ilg
.MarkLabel(throwMissingRequiredMembersLabel);
403
ilg
.Load(objectLocal);
404
ilg
.ConvertValue(objectLocal.LocalType, Globals.TypeOfObject);
405
ilg
.Load(memberNamesArg);
408
ilg
.Call(JsonFormatGeneratorStatics.ThrowMissingRequiredMembersMethod);
410
ilg
.MarkLabel(endOfTypeLabel);
423
ilg
.Case(memberLabels[memberCount], dataMember.Name);
424
ilg
.Set(memberIndexLocal, memberCount);
426
ilg
.Brfalse(throwDuplicateMemberLabel);
430
ilg
.LoadAddress(objectLocal);
431
ilg
.LoadMember(dataMember.MemberInfo);
432
value =
ilg
.DeclareLocal(memberType, dataMember.Name + "Value");
433
ilg
.Stloc(value);
434
ilg
.Call(contextArg, XmlFormatGeneratorStatics.StoreCollectionMemberInfoMethod, value);
440
ilg
.LoadAddress(objectLocal);
441
ilg
.ConvertAddress(objectLocal.LocalType, objectType);
442
ilg
.Ldloc(value);
443
ilg
.StoreMember(dataMember.MemberInfo);
446
ilg
.EndCase();
455
ilg
.Load(expectedElements.GetLocal(i));
456
ilg
.Load(requiredElements[i]);
457
ilg
.And();
458
ilg
.Load(0);
459
ilg
.Ceq();
460
ilg
.Brfalse(throwMissingRequiredMembersLabel);
466
LocalBuilder localArray =
ilg
.DeclareLocal(Globals.TypeOfByteArray, name);
467
ilg
.NewArray(typeof(byte), array.Length);
468
ilg
.Store(localArray);
471
ilg
.StoreArrayElement(localArray, i, array[i]);
473
ilg
.Load(localArray);
510
ilg
.LoadAddress(objectLocal);
511
ilg
.ConvertAddress(objectLocal.LocalType, objectType);
512
ilg
.Call(contextArg, XmlFormatGeneratorStatics.ReadSerializationInfoMethod, xmlReaderArg, classContract.UnderlyingType);
513
ilg
.Load(contextArg);
514
ilg
.LoadMember(XmlFormatGeneratorStatics.GetStreamingContextMethod);
515
ilg
.Call(ctor);
520
LocalBuilder value =
ilg
.DeclareLocal(type, "valueRead");
532
LocalBuilder objectId =
ilg
.DeclareLocal(Globals.TypeOfString, "objectIdRead");
533
ilg
.Call(contextArg, XmlFormatGeneratorStatics.ReadAttributesMethod, xmlReaderArg);
534
ilg
.Call(contextArg, XmlFormatGeneratorStatics.ReadIfNullOrRefMethod, xmlReaderArg, type, DataContract.IsTypeSerializable(type));
535
ilg
.Stloc(objectId);
537
ilg
.If(objectId, Cmp.EqualTo, Globals.NullObjectId);
540
ilg
.LoadAddress(value);
541
ilg
.InitObj(value.LocalType);
547
ilg
.Load(null);
548
ilg
.Stloc(value);
554
ilg
.ElseIfIsEmptyString(objectId);
555
ilg
.Call(contextArg, XmlFormatGeneratorStatics.GetObjectIdMethod);
556
ilg
.Stloc(objectId);
559
ilg
.IfNotIsEmptyString(objectId);
561
ilg
.EndIf();
566
value =
ilg
.DeclareLocal(type, "innerValueRead");
571
ilg
.Call(xmlReaderArg, primitiveContract.XmlFormatReaderMethod);
572
ilg
.Stloc(value);
574
ilg
.Call(contextArg, XmlFormatGeneratorStatics.AddNewObjectMethod, value);
581
ilg
.Else();
586
ilg
.Call(contextArg, XmlFormatGeneratorStatics.GetExistingObjectMethod, objectId, type, name, string.Empty);
587
ilg
.ConvertValue(Globals.TypeOfObject, type);
588
ilg
.Stloc(value);
590
ilg
.EndIf();
594
ilg
.If(objectId, Cmp.NotEqualTo, Globals.NullObjectId);
596
ilg
.EndIf();
610
ilg
.Load(contextArg);
611
ilg
.Load(xmlReaderArg);
613
ilg
.Load(DataContract.GetId(declaredType.TypeHandle));
614
ilg
.Ldtoken(declaredType);
615
ilg
.Load(name);
617
ilg
.Load(string.Empty);
618
ilg
.Call(XmlFormatGeneratorStatics.InternalDeserializeMethod);
621
ilg
.Call(JsonFormatGeneratorStatics.UnboxPointer);
623
ilg
.ConvertValue(Globals.TypeOfObject, type);
624
ilg
.Stloc(value);
630
ilg
.LoadAddress(outerValue);
631
ilg
.Load(innerValue);
635
ilg
.New(type.GetConstructor(new Type[] { innerType }));
638
ilg
.Call(outerType.GetConstructor(new Type[] { innerType }));
671
objectLocal =
ilg
.DeclareLocal(type, "objectDeserialized");
676
ilg
.Ldloca(objectLocal);
677
ilg
.InitObj(type);
681
ilg
.New(constructor);
682
ilg
.Stloc(objectLocal);
683
ilg
.Call(contextArg, XmlFormatGeneratorStatics.AddNewObjectMethod, objectLocal);
691
ilg
.Load(contextArg);
692
ilg
.LoadMember(JsonFormatGeneratorStatics.UseSimpleDictionaryFormatReadProperty);
693
ilg
.If();
697
ilg
.Else();
700
LocalBuilder objectId =
ilg
.DeclareLocal(Globals.TypeOfString, "objectIdRead");
701
ilg
.Call(contextArg, XmlFormatGeneratorStatics.GetObjectIdMethod);
702
ilg
.Stloc(objectId);
708
ilg
.IfNot();
714
growingCollection =
ilg
.DeclareLocal(type, "growingCollection");
715
ilg
.NewArray(itemType, 32);
716
ilg
.Stloc(growingCollection);
718
LocalBuilder i =
ilg
.DeclareLocal(Globals.TypeOfInt, "i");
719
object forLoop =
ilg
.For(i, 0, Int32.MaxValue);
722
ilg
.If();
723
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, 1);
728
ilg
.Call(null, ensureArraySizeMethod, growingCollection, i);
729
ilg
.Stloc(growingCollection);
730
ilg
.StoreArrayElement(growingCollection, i, value);
734
ilg
.Else();
736
ilg
.If();
737
ilg
.Break(forLoop);
738
ilg
.Else();
740
ilg
.EndIf();
741
ilg
.EndIf();
743
ilg
.EndFor();
747
ilg
.Call(null, trimArraySizeMethod, growingCollection, i);
748
ilg
.Stloc(objectLocal);
749
ilg
.Call(contextArg, XmlFormatGeneratorStatics.AddNewObjectWithIdMethod, objectId, objectLocal);
754
ilg
.Else();
755
ilg
.Call(contextArg, XmlFormatGeneratorStatics.AddNewObjectWithIdMethod, objectId, objectLocal);
756
ilg
.EndIf();
761
ilg
.EndIf();
807
LocalBuilder nodeType =
ilg
.DeclareLocal(typeof(XmlNodeType), "nodeType");
809
ilg
.BeginWhileCondition();
810
ilg
.Call(xmlReaderArg, JsonFormatGeneratorStatics.MoveToContentMethod);
811
ilg
.Stloc(nodeType);
812
ilg
.Load(nodeType);
813
ilg
.Load(XmlNodeType.EndElement);
814
ilg
.BeginWhileBody(Cmp.NotEqualTo);
816
ilg
.Load(nodeType);
817
ilg
.Load(XmlNodeType.Element);
818
ilg
.If(Cmp.NotEqualTo);
820
ilg
.EndIf();
822
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, 1);
826
ilg
.Load(keyType);
829
ilg
.Load(xmlReaderArg);
830
ilg
.Call(JsonFormatGeneratorStatics.GetJsonMemberNameMethod);
834
ilg
.Call(JsonFormatGeneratorStatics.ParseEnumMethod);
835
ilg
.ConvertValue(Globals.TypeOfObject, keyType);
839
ilg
.Call(keyDataContract.ParseMethod);
841
LocalBuilder pairKey =
ilg
.DeclareLocal(keyType, "key");
842
ilg
.Stloc(pairKey);
845
LocalBuilder pairKeyNullable =
ilg
.DeclareLocal(keyTypeOriginal, "keyOriginal");
853
ilg
.EndWhile();
862
LocalBuilder size =
ilg
.DeclareLocal(Globals.TypeOfInt, "arraySize");
864
objectLocal =
ilg
.DeclareLocal(type, "objectDeserialized");
865
ilg
.Load(contextArg);
866
ilg
.LoadMember(XmlFormatGeneratorStatics.GetCollectionMemberMethod);
867
ilg
.ConvertValue(Globals.TypeOfObject, type);
868
ilg
.Stloc(objectLocal);
874
ilg
.Load(contextArg);
875
ilg
.LoadMember(JsonFormatGeneratorStatics.UseSimpleDictionaryFormatReadProperty);
876
ilg
.If();
878
ilg
.If(objectLocal, Cmp.EqualTo, null);
879
ilg
.Call(null, XmlFormatGeneratorStatics.ThrowNullValueReturnedForGetOnlyCollectionExceptionMethod, type);
880
ilg
.Else();
884
ilg
.Call(contextArg, XmlFormatGeneratorStatics.CheckEndOfArrayMethod, xmlReaderArg, size, memberNamesArg, emptyDictionaryStringArg);
886
ilg
.EndIf();
888
ilg
.Else();
893
ilg
.If();
894
ilg
.If(objectLocal, Cmp.EqualTo, null);
895
ilg
.Call(null, XmlFormatGeneratorStatics.ThrowNullValueReturnedForGetOnlyCollectionExceptionMethod, type);
897
ilg
.Else();
901
ilg
.Load(objectLocal);
902
ilg
.Call(XmlFormatGeneratorStatics.GetArrayLengthMethod);
903
ilg
.Stloc(size);
906
LocalBuilder i =
ilg
.DeclareLocal(Globals.TypeOfInt, "i");
907
object forLoop =
ilg
.For(i, 0, Int32.MaxValue);
909
ilg
.If();
910
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, 1);
914
ilg
.If(size, Cmp.EqualTo, i);
915
ilg
.Call(null, XmlFormatGeneratorStatics.ThrowArrayExceededSizeExceptionMethod, size, type);
916
ilg
.Else();
917
ilg
.StoreArrayElement(objectLocal, i, value);
918
ilg
.EndIf();
922
ilg
.Else();
924
ilg
.If();
925
ilg
.Break(forLoop);
926
ilg
.Else();
928
ilg
.EndIf();
929
ilg
.EndIf();
930
ilg
.EndFor();
931
ilg
.Call(contextArg, XmlFormatGeneratorStatics.CheckEndOfArrayMethod, xmlReaderArg, size, memberNamesArg, emptyDictionaryStringArg);
933
ilg
.EndIf();
934
ilg
.EndIf();
938
ilg
.EndIf();
977
ilg
.Load(xmlReaderArg);
978
ilg
.ConvertValue(typeof(XmlReaderDelegator), typeof(JsonReaderDelegator));
979
ilg
.Load(contextArg);
980
ilg
.Load(memberNamesArg);
982
ilg
.Load(emptyDictionaryStringArg);
984
ilg
.Load(-1);
985
ilg
.Ldloca(objectLocal);
986
ilg
.Call(typeof(JsonReaderDelegator).GetMethod(readArrayMethod, Globals.ScanAllMembers));
996
ilg
.Call(contextArg, XmlFormatGeneratorStatics.ResetAttributesMethod);
997
LocalBuilder value =
ilg
.DeclareLocal(itemType, "valueRead");
998
ilg
.Load(collectionContractArg);
999
ilg
.Call(JsonFormatGeneratorStatics.GetItemContractMethod);
1000
ilg
.Call(JsonFormatGeneratorStatics.GetRevisedItemContractMethod);
1001
ilg
.Load(xmlReaderArg);
1002
ilg
.Load(contextArg);
1003
ilg
.Call(JsonFormatGeneratorStatics.ReadJsonValueMethod);
1004
ilg
.ConvertValue(Globals.TypeOfObject, itemType);
1005
ilg
.Stloc(value);
1025
LocalBuilder pairKey =
ilg
.DeclareLocal(keyMember.MemberType, keyMember.Name);
1026
LocalBuilder pairValue =
ilg
.DeclareLocal(valueMember.MemberType, valueMember.Name);
1027
ilg
.LoadAddress(value);
1028
ilg
.LoadMember(keyMember.MemberInfo);
1029
ilg
.Stloc(pairKey);
1030
ilg
.LoadAddress(value);
1031
ilg
.LoadMember(valueMember.MemberInfo);
1032
ilg
.Stloc(pairValue);
1038
ilg
.Call(collection, collectionContract.AddMethod, value);
1040
ilg
.Pop();
1046
ilg
.Call(collection, collectionContract.AddMethod, pairKey, pairValue);
1048
ilg
.Pop();
1054
ilg
.If();
1055
ilg
.Call(contextArg, XmlFormatGeneratorStatics.SkipUnknownElementMethod, xmlReaderArg);
1056
ilg
.Dec(iterator);
1057
ilg
.Else();
1059
ilg
.EndIf();
1064
ilg
.Call(xmlReaderArg, JsonFormatGeneratorStatics.IsStartElementMethod2, nameArg, nsArg);
1069
ilg
.Call(xmlReaderArg, JsonFormatGeneratorStatics.IsStartElementMethod0);
1074
ilg
.Load(xmlReaderArg);
1075
ilg
.LoadMember(JsonFormatGeneratorStatics.NodeTypeProperty);
1076
ilg
.Load(XmlNodeType.EndElement);
1077
ilg
.Ceq();
1082
ilg
.Call(null, XmlFormatGeneratorStatics.CreateUnexpectedStateExceptionMethod, expectedState, xmlReaderArg);
1083
ilg
.Throw();
1089
ilg
.CallStringFormat(msg, values);
1091
ilg
.Load(msg);
1097
ilg
.New(JsonFormatGeneratorStatics.SerializationExceptionCtor);
1098
ilg
.Throw();