2 writes to _ilg
System.Private.DataContractSerialization (2)
System\Runtime\Serialization\Json\JsonFormatWriterGenerator.cs (2)
59
_ilg
= new CodeGenerator();
86
_ilg
= new CodeGenerator();
177 references to _ilg
System.Private.DataContractSerialization (177)
System\Runtime\Serialization\Json\JsonFormatWriterGenerator.cs (177)
63
BeginMethod(
_ilg
, "Write" + DataContract.SanitizeTypeName(classContract.XmlName.Name) + "ToJson", typeof(JsonFormatClassWriterDelegate), memberAccessFlag);
77
_memberNamesArg =
_ilg
.GetArg(4);
79
return (JsonFormatClassWriterDelegate)
_ilg
.EndMethod();
90
BeginMethod(
_ilg
, "Write" + DataContract.SanitizeTypeName(collectionContract.XmlName.Name) + "ToJson", typeof(JsonFormatCollectionWriterDelegate), memberAccessFlag);
109
return (JsonFormatCollectionWriterDelegate)
_ilg
.EndMethod();
128
_xmlWriterArg =
_ilg
.GetArg(0);
129
_contextArg =
_ilg
.GetArg(2);
130
_dataContractArg =
_ilg
.GetArg(3);
132
_objectLocal =
_ilg
.DeclareLocal(objType);
133
ArgBuilder objectArg =
_ilg
.GetArg(1);
134
_ilg
.Load(objectArg);
142
_ilg
.ConvertValue(objectArg.ArgType, Globals.TypeOfDateTimeOffset);
143
_ilg
.Call(XmlFormatGeneratorStatics.GetDateTimeOffsetAdapterMethod);
147
_ilg
.ConvertValue(objectArg.ArgType, Globals.TypeOfMemoryStream);
148
_ilg
.Call(XmlFormatGeneratorStatics.GetMemoryStreamAdapterMethod);
152
_ilg
.ConvertValue(objectArg.ArgType, objType);
154
_ilg
.Stloc(_objectLocal);
164
_ilg
.Load(_contextArg);
165
_ilg
.LoadMember(XmlFormatGeneratorStatics.SerializeReadOnlyTypesProperty);
166
_ilg
.IfNot();
167
_ilg
.Load(_dataContractArg);
168
_ilg
.LoadMember(serializationExceptionMessageProperty);
169
_ilg
.Load(null);
170
_ilg
.Call(XmlFormatGeneratorStatics.ThrowInvalidDataContractExceptionMethod);
171
_ilg
.EndIf();
180
_ilg
.LoadAddress(_objectLocal);
181
_ilg
.Load(_contextArg);
182
_ilg
.Call(XmlFormatGeneratorStatics.GetStreamingContextMethod);
183
_ilg
.Call(classContract.OnSerializing);
193
_ilg
.LoadAddress(_objectLocal);
194
_ilg
.Load(_contextArg);
195
_ilg
.Call(XmlFormatGeneratorStatics.GetStreamingContextMethod);
196
_ilg
.Call(classContract.OnSerialized);
207
_ilg
.Call(_contextArg, JsonFormatGeneratorStatics.WriteJsonISerializableMethod, _xmlWriterArg, _objectLocal);
213
LocalBuilder extensionDataLocal =
_ilg
.DeclareLocal(Globals.TypeOfExtensionDataObject);
214
_ilg
.Load(_objectLocal);
215
_ilg
.ConvertValue(_objectLocal.LocalType, Globals.TypeOfIExtensibleDataObject);
216
_ilg
.LoadMember(JsonFormatGeneratorStatics.ExtensionDataProperty);
217
_ilg
.Store(extensionDataLocal);
218
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, _xmlWriterArg, extensionDataLocal, -1);
238
_ilg
.Call(thisObj: _contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, classMemberCount);
246
_ilg
.Load(_contextArg);
247
_ilg
.Call(methodInfo: member.IsGetOnlyCollection ?
254
_ilg
.IfNotDefaultValue(memberValue);
264
_ilg
.Call(thisObj: null, JsonFormatGeneratorStatics.WriteJsonNameWithMappingMethod, _xmlWriterArg, _memberNamesArg, i + _childElementIndex);
278
_ilg
.Call(thisObj: _contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, _xmlWriterArg, extensionDataLocal, memberCount);
285
_ilg
.Else();
286
_ilg
.Call(thisObj: null, XmlFormatGeneratorStatics.ThrowRequiredMemberMustBeEmittedMethod, member.Name, classContract.UnderlyingType);
288
_ilg
.EndIf();
299
_ilg
.LoadAddress(_objectLocal);
300
_ilg
.LoadMember(member.MemberInfo);
301
LocalBuilder memberValue =
_ilg
.DeclareLocal(member.MemberType);
302
_ilg
.Stloc(memberValue);
310
LocalBuilder itemName =
_ilg
.DeclareLocal(typeof(XmlDictionaryString));
311
_ilg
.LoadMember(JsonFormatGeneratorStatics.CollectionItemNameProperty);
312
_ilg
.Store(itemName);
317
LocalBuilder i =
_ilg
.DeclareLocal(Globals.TypeOfInt);
319
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.IncrementArrayCountMethod, _xmlWriterArg, _objectLocal);
324
_ilg
.For(i, 0, _objectLocal);
328
_ilg
.LoadArrayElement(_objectLocal, i);
329
LocalBuilder memberValue =
_ilg
.DeclareLocal(itemType);
330
_ilg
.Stloc(memberValue);
334
_ilg
.EndFor();
359
_ilg
.Call(_contextArg, incrementCollectionCountMethod, _xmlWriterArg, _objectLocal);
414
LocalBuilder currentValue =
_ilg
.DeclareLocal(elementType);
416
LocalBuilder enumerator =
_ilg
.DeclareLocal(enumeratorType);
417
_ilg
.Call(_objectLocal, collectionContract.GetEnumeratorMethod);
421
_ilg
.ConvertValue(collectionContract.GetEnumeratorMethod.ReturnType, Globals.TypeOfIDictionaryEnumerator);
422
_ilg
.New(dictEnumCtor);
429
_ilg
.ConvertValue(collectionContract.GetEnumeratorMethod.ReturnType, ctorParam);
430
_ilg
.New(dictEnumCtor);
432
_ilg
.Stloc(enumerator);
442
_ilg
.Load(_contextArg);
443
_ilg
.LoadMember(JsonFormatGeneratorStatics.UseSimpleDictionaryFormatWriteProperty);
444
_ilg
.If();
446
LocalBuilder pairKey =
_ilg
.DeclareLocal(Globals.TypeOfString);
447
LocalBuilder pairValue =
_ilg
.DeclareLocal(keyValueTypes[1]);
448
_ilg
.ForEach(currentValue, elementType, enumerator, getCurrentMethod);
450
_ilg
.LoadAddress(currentValue);
451
_ilg
.LoadMember(genericDictionaryKeyProperty);
452
_ilg
.ToString(keyValueTypes[0]);
453
_ilg
.Stloc(pairKey);
455
_ilg
.LoadAddress(currentValue);
456
_ilg
.LoadMember(genericDictionaryValueProperty);
457
_ilg
.Stloc(pairValue);
463
_ilg
.EndForEach(moveNextMethod);
464
_ilg
.Else();
469
_ilg
.ForEach(currentValue, elementType, enumerator, getCurrentMethod);
472
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, 1);
480
_ilg
.Call(_dataContractArg, JsonFormatGeneratorStatics.GetItemContractMethod);
481
_ilg
.Call(JsonFormatGeneratorStatics.GetRevisedItemContractMethod);
482
_ilg
.Call(JsonFormatGeneratorStatics.GetJsonDataContractMethod);
483
_ilg
.Load(_xmlWriterArg);
484
_ilg
.Load(currentValue);
485
_ilg
.ConvertValue(currentValue.LocalType, Globals.TypeOfObject);
486
_ilg
.Load(_contextArg);
487
_ilg
.Load(currentValue.LocalType);
488
_ilg
.LoadMember(JsonFormatGeneratorStatics.TypeHandleProperty);
489
_ilg
.Call(JsonFormatGeneratorStatics.WriteJsonValueMethod);
497
_ilg
.EndForEach(moveNextMethod);
501
_ilg
.EndIf();
517
_ilg
.Load(_xmlWriterArg);
521
_ilg
.Load(_contextArg);
522
_ilg
.Load(_xmlWriterArg);
527
_ilg
.Load(value);
531
_ilg
.LoadAddress(_objectLocal);
532
_ilg
.LoadMember(memberInfo);
536
_ilg
.LoadArrayElement(_objectLocal, arrayItemIndex);
541
_ilg
.Load(name);
545
_ilg
.LoadArrayElement(_memberNamesArg!, nameIndex);
548
_ilg
.Load(null);
550
_ilg
.Call(primitiveContract.XmlFormatWriterMethod);
597
_ilg
.Call(_xmlWriterArg, writeArrayMethodInfo, value, itemName, null);
605
_ilg
.Call(_xmlWriterArg, JsonFormatGeneratorStatics.WriteAttributeStringMethod,
614
_ilg
.Call(_xmlWriterArg, JsonFormatGeneratorStatics.WriteAttributeStringMethod,
628
_ilg
.Load(memberValue);
629
_ilg
.Load(memberType);
630
_ilg
.Call(JsonFormatGeneratorStatics.BoxPointer);
632
memberValue =
_ilg
.DeclareLocal(memberType);
633
_ilg
.Store(memberValue);
641
_ilg
.Call(_xmlWriterArg, primitiveContract.XmlFormatContentWriterMethod, memberValue);
654
_ilg
.Load(memberValue);
655
_ilg
.Load(null);
656
_ilg
.Ceq();
658
_ilg
.If();
659
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.WriteNullMethod, _xmlWriterArg, memberType, DataContract.IsTypeSerializable(memberType));
660
_ilg
.Else();
666
_ilg
.Call(_xmlWriterArg, primitiveContract.XmlFormatContentWriterMethod, memberValue);
670
_ilg
.Call(_contextArg, primitiveContract.XmlFormatContentWriterMethod, _xmlWriterArg, memberValue);
679
_ilg
.Load(memberValue);
680
_ilg
.ConvertValue(memberValue.LocalType, Globals.TypeOfObject);
681
memberValue =
_ilg
.DeclareLocal(Globals.TypeOfObject);
683
_ilg
.Stloc(memberValue);
684
_ilg
.If(memberValue, Cmp.EqualTo, null);
685
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.WriteNullMethod, _xmlWriterArg, memberType, DataContract.IsTypeSerializable(memberType));
686
_ilg
.Else();
692
_ilg
.EndIf();
694
_ilg
.EndIf();
700
_ilg
.Load(_contextArg);
701
_ilg
.Load(_xmlWriterArg);
702
_ilg
.Load(memberValue);
703
_ilg
.ConvertValue(memberValue.LocalType, Globals.TypeOfObject);
704
LocalBuilder typeHandleValue =
_ilg
.DeclareLocal(typeof(RuntimeTypeHandle));
705
_ilg
.Call(memberValue, XmlFormatGeneratorStatics.GetTypeMethod);
706
_ilg
.Call(XmlFormatGeneratorStatics.GetTypeHandleMethod);
707
_ilg
.Stloc(typeHandleValue);
708
_ilg
.LoadAddress(typeHandleValue);
709
_ilg
.Ldtoken(memberType);
710
_ilg
.Call(typeof(RuntimeTypeHandle).GetMethod("Equals", new Type[] { typeof(RuntimeTypeHandle) })!);
711
_ilg
.Load(writeXsiType);
712
_ilg
.Load(DataContract.GetId(memberType.TypeHandle));
713
_ilg
.Ldtoken(memberType);
714
_ilg
.Call(methodInfo);
722
Label onNull =
_ilg
.DefineLabel();
723
Label end =
_ilg
.DefineLabel();
724
_ilg
.LoadAddress(memberValue);
728
_ilg
.Dup();
729
_ilg
.Call(typeof(Nullable<>).MakeGenericType(innerType).GetMethod("get_HasValue")!);
730
_ilg
.Brfalse(onNull);
731
_ilg
.Call(typeof(Nullable<>).MakeGenericType(innerType).GetMethod("get_Value")!);
734
memberValue =
_ilg
.DeclareLocal(memberType);
735
_ilg
.Stloc(memberValue);
736
_ilg
.Load(false); //isNull
737
_ilg
.Br(end);
738
_ilg
.MarkLabel(onNull);
739
_ilg
.Pop();
740
_ilg
.LoadAddress(memberValue);
741
_ilg
.InitObj(memberType);
742
_ilg
.Load(true); //isNull
743
_ilg
.MarkLabel(end);
749
_ilg
.Load(_xmlWriterArg);
753
_ilg
.LoadArrayElement(_memberNamesArg!, nameIndex);
755
_ilg
.Load(nameLocal);
758
_ilg
.Load(null);
762
_ilg
.Call(JsonFormatGeneratorStatics.WriteStartElementStringMethod);
766
_ilg
.Call(JsonFormatGeneratorStatics.WriteStartElementMethod);
772
_ilg
.Call(_xmlWriterArg, JsonFormatGeneratorStatics.WriteEndElementMethod);