4 writes to _ilg
System.Private.DataContractSerialization (4)
System\Runtime\Serialization\Json\JsonFormatReaderGenerator.cs (4)
66
_ilg
= new CodeGenerator();
129
_ilg
= GenerateCollectionReaderHelper(collectionContract, false /*isGetOnlyCollection*/);
140
_ilg
= GenerateCollectionReaderHelper(collectionContract, true /*isGetOnlyCollection*/);
148
_ilg
= new CodeGenerator();
300 references to _ilg
System.Private.DataContractSerialization (300)
System\Runtime\Serialization\Json\JsonFormatReaderGenerator.cs (300)
70
BeginMethod(
_ilg
, "Read" + DataContract.SanitizeTypeName(classContract.XmlName!.Name) + "FromJson", typeof(JsonFormatClassReaderDelegate), memberAccessFlag);
85
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.AddNewObjectMethod, _objectLocal);
94
_ilg
.Call(_objectLocal, JsonFormatGeneratorStatics.OnDeserializationMethod, null);
100
_ilg
.Load(_objectLocal);
107
_ilg
.ConvertValue(_objectLocal.LocalType, Globals.TypeOfDateTimeOffsetAdapter);
108
_ilg
.Call(XmlFormatGeneratorStatics.GetDateTimeOffsetMethod);
109
_ilg
.ConvertValue(Globals.TypeOfDateTimeOffset,
_ilg
.CurrentMethod.ReturnType);
113
_ilg
.ConvertValue(_objectLocal.LocalType, Globals.TypeOfMemoryStreamAdapter);
114
_ilg
.Call(XmlFormatGeneratorStatics.GetMemoryStreamMethod);
115
_ilg
.ConvertValue(Globals.TypeOfMemoryStream,
_ilg
.CurrentMethod.ReturnType);
119
_ilg
.ConvertValue(_objectLocal.LocalType,
_ilg
.CurrentMethod.ReturnType);
122
return (JsonFormatClassReaderDelegate)
_ilg
.EndMethod();
131
_ilg
.Load(_objectLocal);
132
_ilg
.ConvertValue(_objectLocal.LocalType,
_ilg
.CurrentMethod.ReturnType);
133
return (JsonFormatCollectionReaderDelegate)
_ilg
.EndMethod();
142
return (JsonFormatGetOnlyCollectionReaderDelegate)
_ilg
.EndMethod();
154
BeginMethod(
_ilg
, "Read" + DataContract.SanitizeTypeName(collectionContract.XmlName.Name) + "FromJson" + "IsGetOnly", typeof(JsonFormatGetOnlyCollectionReaderDelegate), memberAccessFlag);
158
BeginMethod(
_ilg
, "Read" + DataContract.SanitizeTypeName(collectionContract.XmlName.Name) + "FromJson", typeof(JsonFormatCollectionReaderDelegate), memberAccessFlag);
173
_collectionContractArg =
_ilg
.GetArg(4);
174
return
_ilg
;
192
_xmlReaderArg =
_ilg
.GetArg(0);
193
_contextArg =
_ilg
.GetArg(1);
194
_emptyDictionaryStringArg =
_ilg
.GetArg(2);
195
_memberNamesArg =
_ilg
.GetArg(3);
204
_objectLocal =
_ilg
.DeclareLocal(type);
208
_ilg
.LoadMember(Globals.TypeOfDBNull.GetField("Value")!);
209
_ilg
.Stloc(_objectLocal);
215
_ilg
.Ldloca(_objectLocal);
216
_ilg
.InitObj(type);
220
_ilg
.New(classContract.GetNonAttributedTypeConstructor()!);
221
_ilg
.Stloc(_objectLocal);
226
_ilg
.Call(null, JsonFormatGeneratorStatics.GetUninitializedObjectMethod, classContract.TypeForInitialization);
227
_ilg
.ConvertValue(Globals.TypeOfObject, type);
228
_ilg
.Stloc(_objectLocal);
238
_ilg
.LoadAddress(_objectLocal);
239
_ilg
.ConvertAddress(_objectLocal.LocalType, _objectType!);
240
_ilg
.Load(_contextArg);
241
_ilg
.LoadMember(XmlFormatGeneratorStatics.GetStreamingContextMethod);
242
_ilg
.Call(classContract.OnDeserializing);
252
_ilg
.LoadAddress(_objectLocal);
253
_ilg
.ConvertAddress(_objectLocal.LocalType, _objectType!);
254
_ilg
.Load(_contextArg);
255
_ilg
.LoadMember(XmlFormatGeneratorStatics.GetStreamingContextMethod);
256
_ilg
.Call(classContract.OnDeserialized);
269
_ilg
.Load(_contextArg);
270
_ilg
.LoadAddress(_objectLocal);
271
_ilg
.ConvertAddress(_objectLocal.LocalType, Globals.TypeOfIObjectReference);
272
_ilg
.Load(Globals.NewObjectId);
273
_ilg
.Call(XmlFormatGeneratorStatics.GetRealObjectMethod);
274
_ilg
.ConvertValue(Globals.TypeOfObject,
_ilg
.CurrentMethod.ReturnType);
287
LocalBuilder extensionDataLocal =
_ilg
.DeclareLocal(Globals.TypeOfExtensionDataObject);
288
_ilg
.New(JsonFormatGeneratorStatics.ExtensionDataObjectCtor);
289
_ilg
.Store(extensionDataLocal);
297
_ilg
.Call(_objectLocal, extensionDataSetMethod, extensionDataLocal);
312
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, memberCount);
314
BitFlagsGenerator expectedElements = new BitFlagsGenerator(memberCount,
_ilg
);
319
LocalBuilder memberIndexLocal =
_ilg
.DeclareLocal(Globals.TypeOfInt, -1);
320
Label throwDuplicateMemberLabel =
_ilg
.DefineLabel();
321
Label throwMissingRequiredMembersLabel =
_ilg
.DefineLabel();
323
object forReadElements =
_ilg
.For(null, null, null);
324
_ilg
.Call(null, XmlFormatGeneratorStatics.MoveToNextElementMethod, _xmlReaderArg);
325
_ilg
.IfFalseBreak(forReadElements);
326
_ilg
.Call(_contextArg, JsonFormatGeneratorStatics.GetJsonMemberIndexMethod, _xmlReaderArg, _memberNamesArg, memberIndexLocal, extensionDataLocal);
329
Label[] memberLabels =
_ilg
.Switch(memberCount);
331
_ilg
.EndSwitch();
335
_ilg
.Pop();
337
_ilg
.EndFor();
339
Label endOfTypeLabel =
_ilg
.DefineLabel();
340
_ilg
.Br(endOfTypeLabel);
342
_ilg
.MarkLabel(throwDuplicateMemberLabel);
343
_ilg
.Call(null, JsonFormatGeneratorStatics.ThrowDuplicateMemberExceptionMethod, _objectLocal, _memberNamesArg, memberIndexLocal);
345
_ilg
.MarkLabel(throwMissingRequiredMembersLabel);
346
_ilg
.Load(_objectLocal);
347
_ilg
.ConvertValue(_objectLocal.LocalType, Globals.TypeOfObject);
348
_ilg
.Load(_memberNamesArg);
351
_ilg
.Call(JsonFormatGeneratorStatics.ThrowMissingRequiredMembersMethod);
353
_ilg
.MarkLabel(endOfTypeLabel);
368
_ilg
.Case(memberLabels[memberCount]);
369
_ilg
.Set(memberIndexLocal, memberCount);
371
_ilg
.Brfalse(throwDuplicateMemberLabel);
375
_ilg
.LoadAddress(_objectLocal);
376
_ilg
.LoadMember(dataMember.MemberInfo);
377
value =
_ilg
.DeclareLocal(memberType);
378
_ilg
.Stloc(value);
379
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.StoreCollectionMemberInfoMethod, value);
384
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.ResetCollectionMemberInfoMethod);
386
_ilg
.LoadAddress(_objectLocal);
387
_ilg
.ConvertAddress(_objectLocal.LocalType, _objectType!);
388
_ilg
.Ldloc(value);
389
_ilg
.StoreMember(dataMember.MemberInfo);
392
_ilg
.EndCase();
401
_ilg
.Load(expectedElements.GetLocal(i));
402
_ilg
.Load(requiredElements[i]);
403
_ilg
.And();
404
_ilg
.Load(0);
405
_ilg
.Ceq();
406
_ilg
.Brfalse(throwMissingRequiredMembersLabel);
412
LocalBuilder localArray =
_ilg
.DeclareLocal(Globals.TypeOfByteArray);
413
_ilg
.NewArray(typeof(byte), array.Length);
414
_ilg
.Store(localArray);
417
_ilg
.StoreArrayElement(localArray, i, array[i]);
419
_ilg
.Load(localArray);
457
_ilg
.LoadAddress(_objectLocal);
458
_ilg
.ConvertAddress(_objectLocal.LocalType, _objectType!);
459
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.ReadSerializationInfoMethod, _xmlReaderArg, classContract.UnderlyingType);
460
_ilg
.Load(_contextArg);
461
_ilg
.LoadMember(XmlFormatGeneratorStatics.GetStreamingContextMethod);
462
_ilg
.Call(ctor);
469
LocalBuilder value =
_ilg
.DeclareLocal(type);
481
LocalBuilder objectId =
_ilg
.DeclareLocal(Globals.TypeOfString);
482
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.ReadAttributesMethod, _xmlReaderArg);
483
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.ReadIfNullOrRefMethod, _xmlReaderArg, type, DataContract.IsTypeSerializable(type));
484
_ilg
.Stloc(objectId);
486
_ilg
.If(objectId, Cmp.EqualTo, Globals.NullObjectId);
489
_ilg
.LoadAddress(value);
490
_ilg
.InitObj(value.LocalType);
496
_ilg
.Load(null);
497
_ilg
.Stloc(value);
503
_ilg
.ElseIfIsEmptyString(objectId);
504
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.GetObjectIdMethod);
505
_ilg
.Stloc(objectId);
508
_ilg
.IfNotIsEmptyString(objectId);
510
_ilg
.EndIf();
515
value =
_ilg
.DeclareLocal(type);
520
_ilg
.Call(_xmlReaderArg, primitiveContract.XmlFormatReaderMethod);
521
_ilg
.Stloc(value);
523
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.AddNewObjectMethod, value);
530
_ilg
.Else();
535
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.GetExistingObjectMethod, objectId, type, name, string.Empty);
536
_ilg
.ConvertValue(Globals.TypeOfObject, type);
537
_ilg
.Stloc(value);
539
_ilg
.EndIf();
543
_ilg
.If(objectId, Cmp.NotEqualTo, Globals.NullObjectId);
545
_ilg
.EndIf();
560
_ilg
.Load(_contextArg);
561
_ilg
.Load(_xmlReaderArg);
563
_ilg
.Load(DataContract.GetId(declaredType.TypeHandle));
564
_ilg
.Ldtoken(declaredType);
565
_ilg
.Load(name);
567
_ilg
.Load(string.Empty);
568
_ilg
.Call(XmlFormatGeneratorStatics.InternalDeserializeMethod);
572
_ilg
.Call(JsonFormatGeneratorStatics.UnboxPointer);
576
_ilg
.ConvertValue(Globals.TypeOfObject, type);
578
_ilg
.Stloc(value);
586
_ilg
.LoadAddress(outerValue);
587
_ilg
.Load(innerValue);
591
_ilg
.New(type.GetConstructor(new Type[] { innerType })!);
594
_ilg
.Call(outerType.GetConstructor(new Type[] { innerType })!);
629
_objectLocal =
_ilg
.DeclareLocal(type);
634
_ilg
.Ldloca(_objectLocal);
635
_ilg
.InitObj(type);
639
_ilg
.New(constructor);
640
_ilg
.Stloc(_objectLocal);
641
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.AddNewObjectMethod, _objectLocal);
649
_ilg
.Load(_contextArg);
650
_ilg
.LoadMember(JsonFormatGeneratorStatics.UseSimpleDictionaryFormatReadProperty);
651
_ilg
.If();
655
_ilg
.Else();
658
LocalBuilder objectId =
_ilg
.DeclareLocal(Globals.TypeOfString);
659
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.GetObjectIdMethod);
660
_ilg
.Stloc(objectId);
666
_ilg
.IfNot();
672
growingCollection =
_ilg
.DeclareLocal(type);
673
_ilg
.NewArray(itemType, 32);
674
_ilg
.Stloc(growingCollection);
676
LocalBuilder i =
_ilg
.DeclareLocal(Globals.TypeOfInt);
677
object forLoop =
_ilg
.For(i, 0, int.MaxValue);
680
_ilg
.If();
681
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, 1);
687
_ilg
.Call(null, ensureArraySizeMethod, growingCollection, i);
688
_ilg
.Stloc(growingCollection);
689
_ilg
.StoreArrayElement(growingCollection, i, value);
693
_ilg
.Else();
695
_ilg
.If();
696
_ilg
.Break(forLoop);
697
_ilg
.Else();
699
_ilg
.EndIf();
700
_ilg
.EndIf();
702
_ilg
.EndFor();
706
_ilg
.Call(null, trimArraySizeMethod, growingCollection, i);
707
_ilg
.Stloc(_objectLocal);
708
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.AddNewObjectWithIdMethod, objectId, _objectLocal);
713
_ilg
.Else();
714
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.AddNewObjectWithIdMethod, objectId, _objectLocal);
715
_ilg
.EndIf();
720
_ilg
.EndIf();
768
LocalBuilder nodeType =
_ilg
.DeclareLocal(typeof(XmlNodeType));
770
_ilg
.BeginWhileCondition();
771
_ilg
.Call(_xmlReaderArg, JsonFormatGeneratorStatics.MoveToContentMethod);
772
_ilg
.Stloc(nodeType);
773
_ilg
.Load(nodeType);
774
_ilg
.Load(XmlNodeType.EndElement);
775
_ilg
.BeginWhileBody(Cmp.NotEqualTo);
777
_ilg
.Load(nodeType);
778
_ilg
.Load(XmlNodeType.Element);
779
_ilg
.If(Cmp.NotEqualTo);
781
_ilg
.EndIf();
783
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, 1);
787
_ilg
.Load(keyType);
790
_ilg
.Load(_xmlReaderArg);
791
_ilg
.Call(JsonFormatGeneratorStatics.GetJsonMemberNameMethod);
795
_ilg
.Call(JsonFormatGeneratorStatics.ParseEnumMethod);
796
_ilg
.ConvertValue(Globals.TypeOfObject, keyType);
800
_ilg
.Call(keyDataContract.ParseMethod!);
802
LocalBuilder pairKey =
_ilg
.DeclareLocal(keyType);
803
_ilg
.Stloc(pairKey);
806
LocalBuilder pairKeyNullable =
_ilg
.DeclareLocal(keyTypeOriginal);
814
_ilg
.EndWhile();
825
LocalBuilder size =
_ilg
.DeclareLocal(Globals.TypeOfInt);
827
_objectLocal =
_ilg
.DeclareLocal(type);
828
_ilg
.Load(_contextArg);
829
_ilg
.LoadMember(XmlFormatGeneratorStatics.GetCollectionMemberMethod);
830
_ilg
.ConvertValue(Globals.TypeOfObject, type);
831
_ilg
.Stloc(_objectLocal);
837
_ilg
.Load(_contextArg);
838
_ilg
.LoadMember(JsonFormatGeneratorStatics.UseSimpleDictionaryFormatReadProperty);
839
_ilg
.If();
843
_ilg
.If(_objectLocal, Cmp.EqualTo, null);
844
_ilg
.Call(null, XmlFormatGeneratorStatics.ThrowNullValueReturnedForGetOnlyCollectionExceptionMethod, type);
845
_ilg
.EndIf();
850
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.CheckEndOfArrayMethod, _xmlReaderArg, size, _memberNamesArg, _emptyDictionaryStringArg);
852
_ilg
.Else();
857
_ilg
.If();
861
_ilg
.If(_objectLocal, Cmp.EqualTo, null);
862
_ilg
.Call(null, XmlFormatGeneratorStatics.ThrowNullValueReturnedForGetOnlyCollectionExceptionMethod, type);
863
_ilg
.EndIf();
868
_ilg
.Load(_objectLocal);
869
_ilg
.Call(XmlFormatGeneratorStatics.GetArrayLengthMethod);
870
_ilg
.Stloc(size);
873
LocalBuilder i =
_ilg
.DeclareLocal(Globals.TypeOfInt);
874
object forLoop =
_ilg
.For(i, 0, int.MaxValue);
876
_ilg
.If();
877
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, 1);
881
_ilg
.If(size, Cmp.EqualTo, i);
882
_ilg
.Call(null, XmlFormatGeneratorStatics.ThrowArrayExceededSizeExceptionMethod, size, type);
883
_ilg
.Else();
884
_ilg
.StoreArrayElement(_objectLocal, i, value);
885
_ilg
.EndIf();
889
_ilg
.Else();
891
_ilg
.If();
892
_ilg
.Break(forLoop);
893
_ilg
.Else();
895
_ilg
.EndIf();
896
_ilg
.EndIf();
897
_ilg
.EndFor();
898
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.CheckEndOfArrayMethod, _xmlReaderArg, size, _memberNamesArg, _emptyDictionaryStringArg);
900
_ilg
.EndIf();
904
_ilg
.EndIf();
945
_ilg
.Load(_xmlReaderArg);
946
_ilg
.ConvertValue(typeof(XmlReaderDelegator), typeof(JsonReaderDelegator));
947
_ilg
.Load(_contextArg);
948
_ilg
.Load(_memberNamesArg);
950
_ilg
.Load(_emptyDictionaryStringArg);
952
_ilg
.Load(-1);
953
_ilg
.Ldloca(_objectLocal);
954
_ilg
.Call(typeof(JsonReaderDelegator).GetMethod(readArrayMethod, Globals.ScanAllMembers)!);
966
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.ResetAttributesMethod);
967
LocalBuilder value =
_ilg
.DeclareLocal(itemType);
968
_ilg
.Load(_collectionContractArg);
969
_ilg
.Call(JsonFormatGeneratorStatics.GetItemContractMethod);
970
_ilg
.Call(JsonFormatGeneratorStatics.GetRevisedItemContractMethod);
971
_ilg
.Load(_xmlReaderArg);
972
_ilg
.Load(_contextArg);
973
_ilg
.Call(JsonFormatGeneratorStatics.ReadJsonValueMethod);
974
_ilg
.ConvertValue(Globals.TypeOfObject, itemType);
975
_ilg
.Stloc(value);
997
LocalBuilder pairKey =
_ilg
.DeclareLocal(keyMember.MemberType);
998
LocalBuilder pairValue =
_ilg
.DeclareLocal(valueMember.MemberType);
999
_ilg
.LoadAddress(value);
1000
_ilg
.LoadMember(keyMember.MemberInfo);
1001
_ilg
.Stloc(pairKey);
1002
_ilg
.LoadAddress(value);
1003
_ilg
.LoadMember(valueMember.MemberInfo);
1004
_ilg
.Stloc(pairValue);
1012
_ilg
.Call(collection, collectionContract.AddMethod, value);
1014
_ilg
.Pop();
1022
_ilg
.Call(collection, collectionContract.AddMethod, pairKey, pairValue);
1024
_ilg
.Pop();
1030
_ilg
.If();
1031
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.SkipUnknownElementMethod, _xmlReaderArg);
1032
_ilg
.Dec(iterator);
1033
_ilg
.Else();
1035
_ilg
.EndIf();
1040
_ilg
.Call(_xmlReaderArg, JsonFormatGeneratorStatics.IsStartElementMethod2, nameArg, nsArg);
1045
_ilg
.Call(_xmlReaderArg, JsonFormatGeneratorStatics.IsStartElementMethod0);
1050
_ilg
.Load(_xmlReaderArg);
1051
_ilg
.LoadMember(JsonFormatGeneratorStatics.NodeTypeProperty);
1052
_ilg
.Load(XmlNodeType.EndElement);
1053
_ilg
.Ceq();
1058
_ilg
.Call(null, XmlFormatGeneratorStatics.CreateUnexpectedStateExceptionMethod, expectedState, _xmlReaderArg);
1059
_ilg
.Throw();
1065
_ilg
.CallStringFormat(msg, values);
1067
_ilg
.Load(msg);
1073
_ilg
.New(JsonFormatGeneratorStatics.SerializationExceptionCtor);
1074
_ilg
.Throw();