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)
63BeginMethod(_ilg, "Write" + DataContract.SanitizeTypeName(classContract.XmlName.Name) + "ToJson", typeof(JsonFormatClassWriterDelegate), memberAccessFlag); 77_memberNamesArg = _ilg.GetArg(4); 79return (JsonFormatClassWriterDelegate)_ilg.EndMethod(); 90BeginMethod(_ilg, "Write" + DataContract.SanitizeTypeName(collectionContract.XmlName.Name) + "ToJson", typeof(JsonFormatCollectionWriterDelegate), memberAccessFlag); 109return (JsonFormatCollectionWriterDelegate)_ilg.EndMethod(); 128_xmlWriterArg = _ilg.GetArg(0); 129_contextArg = _ilg.GetArg(2); 130_dataContractArg = _ilg.GetArg(3); 132_objectLocal = _ilg.DeclareLocal(objType); 133ArgBuilder 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); 213LocalBuilder 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); 301LocalBuilder memberValue = _ilg.DeclareLocal(member.MemberType); 302_ilg.Stloc(memberValue); 310LocalBuilder itemName = _ilg.DeclareLocal(typeof(XmlDictionaryString)); 311_ilg.LoadMember(JsonFormatGeneratorStatics.CollectionItemNameProperty); 312_ilg.Store(itemName); 317LocalBuilder i = _ilg.DeclareLocal(Globals.TypeOfInt); 319_ilg.Call(_contextArg, XmlFormatGeneratorStatics.IncrementArrayCountMethod, _xmlWriterArg, _objectLocal); 324_ilg.For(i, 0, _objectLocal); 328_ilg.LoadArrayElement(_objectLocal, i); 329LocalBuilder memberValue = _ilg.DeclareLocal(itemType); 330_ilg.Stloc(memberValue); 334_ilg.EndFor(); 359_ilg.Call(_contextArg, incrementCollectionCountMethod, _xmlWriterArg, _objectLocal); 414LocalBuilder currentValue = _ilg.DeclareLocal(elementType); 416LocalBuilder 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(); 446LocalBuilder pairKey = _ilg.DeclareLocal(Globals.TypeOfString); 447LocalBuilder 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); 632memberValue = _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); 681memberValue = _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); 704LocalBuilder 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); 722Label onNull = _ilg.DefineLabel(); 723Label 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")!); 734memberValue = _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);