41 writes to TypeDesc
System.Private.Xml (41)
System\Xml\Serialization\SchemaImporter.cs (1)
114mapping.TypeDesc = typeDesc;
System\Xml\Serialization\SoapReflectionImporter.cs (9)
229mapping.TypeDesc = typeDesc; 286mapping.TypeDesc = typeDesc; 313mapping.TypeDesc = model.TypeDesc; 428mapping.TypeDesc = model.TypeDesc; 534mapping.TypeDesc = TypeScope.GetTypeDesc(dataType, XmlSchema.Namespace); 538mapping.TypeDesc = TypeScope.GetTypeDesc(dataType, UrtTypes.Namespace); 547mapping.TypeDesc = model.TypeDesc; 569mapping.TypeDesc = model.TypeDesc; 609members.TypeDesc = _typeScope.GetTypeDesc(typeof(object[]));
System\Xml\Serialization\XmlReflectionImporter.cs (12)
561serializableMapping.TypeDesc = typeDesc; 569serializableMapping.TypeDesc = typeDesc; 577mapping.TypeDesc = typeDesc; 638mapping.TypeDesc = typeDesc; 684mapping.TypeDesc = typeDesc; 746mapping.TypeDesc = model.TypeDesc; 1096mapping.TypeDesc = model.TypeDesc; 1165mapping.TypeDesc = TypeScope.GetTypeDesc(dataType, XmlSchema.Namespace); 1169mapping.TypeDesc = TypeScope.GetTypeDesc(dataType, UrtTypes.Namespace); 1178mapping.TypeDesc = model.TypeDesc; 1202mapping.TypeDesc = model.TypeDesc; 1250members.TypeDesc = _typeScope.GetTypeDesc(typeof(object[]));
System\Xml\Serialization\XmlSchemaImporter.cs (19)
44mapping.TypeDesc = TypeScope.GetTypeDesc("string", XmlSchema.Namespace, flags); 215mapping.TypeDesc = Scope.GetTypeDesc(typeof(object[])); 488mappings.TypeDesc = Scope.GetTypeDesc(typeof(object[])); 558structMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Struct, baseTypeDesc, flags); 614structMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Struct, baseTypeDesc, flags); 1183textMapping.TypeDesc = Scope.GetTypeDesc(typeof(XmlNode)); 1205mapping.TypeDesc = Scope.GetTypeDesc(makeElement ? typeof(XmlElement) : typeof(XmlNode)); 1294arrayMapping.TypeDesc = choiceMember.TypeDesc; 1312arrayMapping.TypeDesc = ((TypeMapping)itemAccessor.Mapping!).TypeDesc!.CreateArrayTypeDesc(); 1384mapping.TypeDesc = Scope.GetTypeDesc(typeof(XmlElement)); 1393mapping.TypeDesc = Scope.GetTypeDesc(mixed ? typeof(XmlNode) : typeof(XmlElement)); 1398mapping.TypeDesc = mapping.TypeDesc.CreateArrayTypeDesc(); 1491mapping.TypeDesc = Scope.GetTypeDesc(typeof(XmlAttribute)); 1552xmlnsMapping.TypeDesc = xmlnsTypeDesc; 1591mapping.TypeDesc = Scope.GetTypeDesc(typeof(string)); 1744enumMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Enum, null, 0); 1801enumMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Enum, null, 0); 1831mapping.TypeDesc = sourceTypeDesc; 1847mapping.TypeDesc = typeDesc;
678 references to TypeDesc
System.Private.Xml (678)
System\Xml\Serialization\Compilation.cs (1)
455VerifyLoadContext(mapping.Accessor.Mapping?.TypeDesc?.Type, mainAssembly);
System\Xml\Serialization\Mappings.cs (15)
617if (BaseMapping == null || BaseMapping.TypeDesc!.IsRoot) 626throw new InvalidOperationException(SR.Format(SR.XmlIllegalSimpleContentExtension, TypeDesc!.FullName, BaseMapping.TypeDesc.FullName)); 637if (!_hasSimpleContent && text != null && !text.Mapping!.TypeDesc!.CanBeTextValue && !(BaseMapping != null && !BaseMapping.TypeDesc!.IsRoot && (text.Mapping.TypeDesc.IsEnum || text.Mapping.TypeDesc.IsPrimitive))) 639throw new InvalidOperationException(SR.Format(SR.XmlIllegalTypedTextAttribute, TypeDesc!.FullName, text.Name, text.Mapping.TypeDesc.FullName)); 660if (TypeDesc!.IsRoot) 666while (start.BaseMapping != null && !start.BaseMapping.IsSequence && !start.BaseMapping.TypeDesc!.IsRoot) 678get { return _isSequence && !TypeDesc!.IsRoot; } 756int w1 = a1.Mapping!.TypeDesc!.Weight; 757int w2 = a2.Mapping!.TypeDesc!.Weight; 1083throw new InvalidOperationException(SR.Format(SR.XmlCircularDerivation, TypeDesc!.FullName));
System\Xml\Serialization\ReflectionXmlSerializationReader.cs (61)
40!mapping.TypeDesc!.IsRoot) 45mapping.TypeDesc.Type!, 455memberMapping.TypeDesc = mapping.TypeDesc; 686if (special.TypeDesc!.Kind == TypeKind.Node) 699if (text.Mapping!.TypeDesc!.CollapseWhitespace) 710if (text.Mapping!.TypeDesc == StringTypeDesc || text.Mapping.TypeDesc!.FormatterName == "String") 712value = ReadString(null, text.Mapping.TypeDesc.CollapseWhitespace); 769TypeDesc td = nullableMapping.BaseMapping!.TypeDesc!; 774elementType = ele.Mapping!.TypeDesc!.Type!; 859if (element.Mapping.TypeDesc!.IsValueType) 861value = ReflectionCreateObject(element.Mapping.TypeDesc.Type!); 868else if ((element.Default != null && element.Default != DBNull.Value && element.Mapping.TypeDesc!.IsValueType) 873else if (element.Mapping.TypeDesc!.Type == typeof(TimeSpan) && Reader.IsEmptyElement) 878else if (element.Mapping.TypeDesc!.Type == typeof(DateTimeOffset) && Reader.IsEmptyElement) 885if (element.Mapping.TypeDesc == QnameTypeDesc) 891if (element.Mapping.TypeDesc.FormatterName == "ByteArrayBase64") 895else if (element.Mapping.TypeDesc.FormatterName == "ByteArrayHex") 916if (!mapping.TypeDesc!.IsValueType || rre != null) 943isNullable: mapping.TypeDesc!.IsNullable && element.IsNullable, 952switch (specialMapping.TypeDesc!.Kind) 955bool isDoc = specialMapping.TypeDesc.FullName == typeof(XmlDocument).FullName; 985value = ReadSerializable((IXmlSerializable)ReflectionCreateObject(sm.TypeDesc!.Type!)!, isWrappedAny); 1025object? WriteStruct() => WriteStructMethod(structMapping, mapping.TypeDesc!.IsNullable, true, defaultNamespace: null); 1075return mapping.TypeDesc!.CanBeElementValue; 1093TypeDesc td = arrayMapping.TypeDesc!; 1125TypeDesc = arrayMapping.TypeDesc, 1172else if (mapping.TypeDesc == StringTypeDesc) 1176else if (mapping.TypeDesc!.FormatterName == "String") 1178if (mapping.TypeDesc.CollapseWhitespace) 1189if (!mapping.TypeDesc.HasCustomFormatter) 1192object retObj = mapping.TypeDesc.FormatterName switch 1210_ => throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorDetails, $"unknown FormatterName: {mapping.TypeDesc.FormatterName}")), 1216string methodName = $"To{mapping.TypeDesc.FormatterName}"; 1220throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorDetails, $"unknown FormatterName: {mapping.TypeDesc.FormatterName}")); 1238object? o = Activator.CreateInstance(nullableMapping.TypeDesc!.Type!); 1244element.IsNullable = nullableMapping.BaseMapping!.TypeDesc!.IsNullable; 1270return Enum.ToObject(mapping.TypeDesc!.Type!, ToEnum(source, table, mapping.TypeDesc.Name)); 1278return Enum.Parse(mapping.TypeDesc!.Type!, c.Name); 1282throw CreateUnknownConstantException(source, mapping.TypeDesc!.Type!); 1330if (structMapping.TypeDesc!.IsRoot) 1335if (structMapping.TypeDesc.IsAbstract) 1341object? o = ReflectionCreateObject(structMapping.TypeDesc.Type!); 1513if (structMapping.TypeDesc!.IsRoot && isNull) 1521if (structMapping.TypeDesc.IsValueType) 1523return ReflectionCreateObject(structMapping.TypeDesc.Type!); 1533if (xsiType == null || (!structMapping.TypeDesc.IsRoot && QNameEqual(xsiType, structMapping.TypeName, defaultNamespace))) 1535if (structMapping.TypeDesc.IsRoot) 1544else if (structMapping.TypeDesc.IsRoot && WriteEnumAndArrayTypes(out o, xsiType, defaultNamespace)) 1550if (structMapping.TypeDesc.IsRoot) 1557if (structMapping.TypeDesc!.IsNullable && isNull) 1561else if (structMapping.TypeDesc.IsAbstract) 1567if (structMapping.TypeDesc.Type != null && typeof(XmlSchemaObject).IsAssignableFrom(structMapping.TypeDesc.Type)) 1574object? o = ReflectionCreateObject(structMapping.TypeDesc.Type!)!; 1629throw new InvalidOperationException(SR.Format(SR.XmlSequenceHierarchy, structMapping.TypeDesc.FullName, mapping.Name, declaringMapping!.TypeDesc!.FullName, "Order")); 1705object choiceValue = Enum.Parse(choice.Mapping!.TypeDesc!.Type!, name); 1917if (special.TypeDesc!.Kind == TypeKind.Attribute) 1921else if (special.TypeDesc.CanBeAttributeValue)
System\Xml\Serialization\ReflectionXmlSerializationWriter.cs (34)
46!mapping.TypeDesc!.IsRoot) 49mapping.TypeDesc.Type!, 52CreateXmlSerializationWriteCallback(mapping, mapping.TypeName!, mapping.Namespace, mapping.TypeDesc.IsNullable) 104if (!mapping.TypeDesc!.IsValueType && !mapping.TypeDesc.Type!.IsPrimitive) 109WriteMember(o, null, new ElementAccessor[] { element }, null, null, mapping.TypeDesc, !element.IsSoap); 145throw CreateInvalidChoiceIdentifierValueException(choice.Mapping!.TypeDesc!.FullName, choice.MemberName!); 219if (o != null && o.GetType() == element.Mapping!.TypeDesc!.Type) 227TypeDesc td = element.IsUnbounded ? element.Mapping!.TypeDesc!.CreateArrayTypeDesc() : element.Mapping!.TypeDesc!; 251throw CreateChoiceIdentifierValueException(choice.Mapping!.TypeDesc!.FullName, choice.MemberName!, elem.Name, elem.NamespaceURI); 288if (!WritePrimitiveValue(primitiveMapping.TypeDesc!, o, out stringValue)) 305switch (specialMapping.TypeDesc!.Kind) 350WritePotentiallyReferencingElement(name, ns, o, mapping.TypeDesc!.Type, true, element.IsNullable); 393if (mapping!.TypeDesc == ReflectionXmlSerializationReader.QnameTypeDesc) 411WritePrimitiveMethodRequirement suffixRaw = mapping.TypeDesc!.XmlEncodingNotRequired ? WritePrimitiveMethodRequirement.Raw : WritePrimitiveMethodRequirement.None; 423WritePotentiallyReferencingElement(name, ns, o, !writeAccessor ? mapping.TypeDesc!.Type : null, !writeAccessor, element.IsNullable); 479bool hasDefault = defaultValue != null && defaultValue != DBNull.Value && mapping.TypeDesc!.HasDefaultSupport; 509if (mapping.IsSoap && mapping.TypeDesc!.IsRoot) return; 520&& o.GetType() != mapping.TypeDesc!.Type) 527if (mapping.TypeDesc.IsRoot) 542if (!mapping.TypeDesc!.IsAbstract) 544if (mapping.TypeDesc.Type != null && typeof(XmlSchemaObject).IsAssignableFrom(mapping.TypeDesc.Type)) 562if (!mapping.TypeDesc.IsRoot) 666if (m is EnumMapping em && em.TypeDesc!.Type == objType) 675if (m is ArrayMapping am && am.TypeDesc!.Type == objType) 679WriteMember(o, null, am.ElementsSortedByDerivation!, null, null, am.TypeDesc!, true); 726throw CreateInvalidEnumValueException(v, mapping.TypeDesc!.FullName); 877if (special.TypeDesc!.Kind == TypeKind.Attribute || special.TypeDesc.CanBeAttributeValue) 911if (t == derived.TypeDesc!.Type) 928TypeDesc typeDesc = mapping.TypeDesc!; 929bool hasDefault = defaultValue != null && defaultValue != DBNull.Value && mapping.TypeDesc!.HasDefaultSupport;
System\Xml\Serialization\SchemaImporter.cs (2)
88TypeDesc typeDescToChange = structMapping.TypeDesc!; 97throw new InvalidOperationException(SR.Format(SR.XmlInvalidBaseType, structMapping.TypeDesc!.FullName, baseType.FullName, typeDescToChange.BaseTypeDesc.FullName));
System\Xml\Serialization\SoapReflectionImporter.cs (17)
252if (mapping.TypeDesc != typeDesc) 253throw new InvalidOperationException(SR.Format(SR.XmlTypesDuplicate, typeDesc.FullName, mapping.TypeDesc!.FullName, typeName, ns)); 260TypeDesc typeDesc = baseMapping.TypeDesc!.GetNullableTypeDesc(type); 276throw new InvalidOperationException(SR.Format(SR.XmlTypesDuplicate, typeDesc.FullName, existingMapping.TypeDesc!.FullName, typeDesc.Name, existingMapping.Namespace)); 281throw new InvalidOperationException(SR.Format(SR.XmlTypesDuplicate, typeDesc.FullName, existingMapping.TypeDesc!.FullName, typeDesc.Name, existingMapping.Namespace)); 425if (itemTypeMapping.TypeDesc!.IsValueType && !itemTypeMapping.TypeDesc.IsPrimitive && !itemTypeMapping.TypeDesc.IsEnum) 442if (existingMapping.TypeDesc == model.TypeDesc) 477itemTypeNamespace = itemTypeMapping.TypeDesc!.IsXsdType ? XmlSchema.Namespace : UrtTypes.Namespace; 478itemTypeName = itemTypeMapping.TypeDesc.DataType!.Name!; 483if (itemTypeMapping.TypeDesc!.IsRoot) 502throw new InvalidOperationException(SR.Format(SR.XmlInvalidSoapArray, mapping.TypeDesc!.FullName)); 535if (mapping.TypeDesc == null) 539if (mapping.TypeDesc == null) 549mapping.TypeName = mapping.TypeDesc.DataType!.Name; 550mapping.Namespace = mapping.TypeDesc.IsXsdType ? XmlSchema.Namespace : UrtTypes.Namespace;
System\Xml\Serialization\Types.cs (2)
735if (typeMapping.TypeDesc == typeDesc) 1130if (ShouldBeReplaced(pair.Value, structMapping.TypeDesc!.Type!, out replacedInfo))
System\Xml\Serialization\XmlReflectionImporter.cs (28)
127if (mapping.IsAnonymousType && !mapping.TypeDesc!.IsSpecial) 301return ((TypeMapping)mapping).TypeDesc!.FullName; 330if (accessor.Mapping!.TypeDesc == existing.Mapping!.TypeDesc 331|| (existing.Mapping is NullableMapping && accessor.Mapping.TypeDesc == ((NullableMapping)existing.Mapping).BaseMapping!.TypeDesc) 332|| (accessor.Mapping is NullableMapping && ((NullableMapping)accessor.Mapping).BaseMapping!.TypeDesc == existing.Mapping.TypeDesc)) 516CheckContext(mapping.TypeDesc!, context); 649TypeDesc typeDesc = baseMapping.TypeDesc!.GetNullableTypeDesc(type); 674throw new InvalidOperationException(SR.Format(SR.XmlTypesDuplicate, typeDesc.FullName, existingMapping.TypeDesc!.FullName, typeDesc.Name, existingMapping.Namespace)); 679throw new InvalidOperationException(SR.Format(SR.XmlTypesDuplicate, typeDesc.FullName, existingMapping.TypeDesc!.FullName, typeDesc.Name, existingMapping.Namespace)); 721if (!mapping.IsAnonymousType && mapping.TypeDesc != typeDesc) 722throw new InvalidOperationException(SR.Format(SR.XmlTypesDuplicate, typeDesc.FullName, mapping.TypeDesc!.FullName, typeName, ns)); 873if (!member.Text.Mapping!.TypeDesc!.CanBeTextValue && member.Text.Mapping.IsList) 874throw new InvalidOperationException(SR.Format(SR.XmlIllegalTypedTextAttribute, typeName, member.Text.Name, member.Text.Mapping.TypeDesc.FullName)); 1045name = itemTypeMapping.TypeDesc!.DataType!.Name; 1047else if (itemTypeMapping is StructMapping && itemTypeMapping.TypeDesc!.IsRoot) 1121if (existingMapping.TypeDesc == model.TypeDesc) 1166if (mapping.TypeDesc == null) 1170if (mapping.TypeDesc == null) 1180mapping.TypeName = mapping.TypeDesc.DataType!.Name; 1181mapping.Namespace = mapping.TypeDesc.IsXsdType ? XmlSchema.Namespace : UrtTypes.Namespace; 1183CheckContext(mapping.TypeDesc, context); 1827if (element.Mapping.TypeDesc!.Kind == TypeKind.Node) 2027throw new InvalidOperationException(SR.Format(SR.XmlChoiceMissingAnyValue, accessor.ChoiceIdentifier.Mapping!.TypeDesc!.FullName)); 2033throw new InvalidOperationException(SR.Format(SR.XmlChoiceMissingValue, accessor.ChoiceIdentifier.Mapping!.TypeDesc!.FullName, id, element.Name, element.Namespace)); 2239bool isAny = mapping.TypeDesc!.Kind == TypeKind.Node;
System\Xml\Serialization\XmlSchemaExporter.cs (29)
231if (!accessor.Mapping!.IncludeInSchema && !accessor.Mapping.TypeDesc!.IsRoot) 400XmlSchemaSimpleType type = (XmlSchemaSimpleType)mapping.TypeDesc!.DataType!; 409return new XmlQualifiedName(mapping.TypeDesc.DataType!.Name, UrtTypes.Namespace); 414switch (mapping.TypeDesc!.Kind) 419type.IsMixed = mapping.TypeDesc.IsMixed; 440type.IsMixed = mapping.TypeDesc.IsMixed; 576if (mapping.TypeDesc!.IsXsdType) 578qname = new XmlQualifiedName(mapping.TypeDesc.DataType!.Name, XmlSchema.Namespace); 728if (!accessor.HasDefault && !valueTypeOptional && accessor.Mapping!.TypeDesc!.IsValueType) 815int minOccurs = repeats || accessor.HasDefault || (!accessor.IsNullable && !accessor.Mapping!.TypeDesc!.IsValueType) || valueTypeOptional ? 0 : 1; 893return val != 0 ? XmlCustomFormatter.FromEnum(val, names, ids, mapping.TypeDesc!.FullName) : null; 910if (!pm.TypeDesc!.HasCustomFormatter) 914if (pm.TypeDesc.Type == null) 916throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorDetails, "Mapping for " + pm.TypeDesc.Name + " missing type property")); 920if (pm.TypeDesc.FormatterName == "String") 924System.Reflection.MethodInfo? format = formatter.GetMethod("ToString", new Type[] { pm.TypeDesc.Type! }); 930string defaultValue = XmlCustomFormatter.FromDefaultValue(value, pm.TypeDesc.FormatterName!); 932throw new InvalidOperationException(SR.Format(SR.XmlInvalidDefaultValue, value, pm.TypeDesc.Name)); 935throw new InvalidOperationException(SR.Format(SR.XmlInvalidDefaultValue, value, pm.TypeDesc.Name)); 944if (mapping is StructMapping && mapping.TypeDesc!.IsRoot) 961if (mapping.TypeDesc!.IsRoot) 969throw new InvalidOperationException(SR.Format(SR.XmlCircularReference2, mapping.TypeDesc.Name, "AnonymousType", "false")); 975if (!mapping.IncludeInSchema) throw new InvalidOperationException(SR.Format(SR.XmlCannotIncludeInSchema, mapping.TypeDesc.Name)); 984type.IsAbstract = mapping.TypeDesc.IsAbstract; 990throw new InvalidOperationException(SR.Format(SR.XmlAnonymousBaseType, mapping.TypeDesc.Name, mapping.BaseMapping.TypeDesc!.Name, "AnonymousType", "false")); 1096throw new InvalidOperationException(SR.Format(SR.XmlAnonymousBaseType, textMapping.TypeDesc!.Name, pm.TypeDesc!.Name, "AnonymousType", "false")); 1143if (!mapping.IncludeInSchema) throw new InvalidOperationException(SR.Format(SR.XmlCannotIncludeInSchema, mapping.TypeDesc!.Name));
System\Xml\Serialization\XmlSchemaImporter.cs (40)
45mapping.TypeName = mapping.TypeDesc!.DataType!.Name; 106accessor.IsNullable = typeMapping.TypeDesc!.IsNullable; 209member.TypeDesc = accessor.Mapping!.TypeDesc; 506baseTypeDesc = ((StructMapping)baseMapping).TypeDesc; 514baseTypeDesc = baseMapping.TypeDesc; 591throw new InvalidOperationException(SR.Format(SR.XmlIllegalOverride, type.Name, baseMember.Name, baseMember.TypeDesc!.FullName, structMapping.Members[i].TypeDesc!.FullName, declaringMapping!.TypeDesc!.FullName)); 787string tdFullName = element.Mapping!.TypeDesc!.FullName; 824typeDescs[i] = ((ElementAccessor)enumerator.Current).Mapping!.TypeDesc!; 857choiceIdentifier.TypeDesc = member.ChoiceIdentifier.Mapping.TypeDesc!.CreateArrayTypeDesc(); 861choiceIdentifier.TypeDesc = member.ChoiceIdentifier.Mapping.TypeDesc; 895if (item.Mapping!.TypeDesc != null) 897if (item.IsNullable != item.Mapping.TypeDesc.IsNullable) 900if (item.Mapping.TypeDesc.IsAmbiguousDataType) 995if (scopeElement.Mapping!.TypeDesc != element.Mapping!.TypeDesc) 1123if (!(mapping is PrimitiveMapping || mapping!.TypeDesc!.CanBeTextValue)) 1144member.TypeDesc = accessor.Mapping.TypeDesc!.CreateArrayTypeDesc(); 1153member.TypeDesc = accessor.Mapping.TypeDesc!.CreateArrayTypeDesc(); 1158member.TypeDesc = accessor.Mapping.TypeDesc; 1176member.TypeDesc = ((TypeMapping)accessors[0].Mapping!).TypeDesc; 1184textMapping.TypeName = textMapping.TypeDesc.Name; 1185member.TypeDesc = textMapping.TypeDesc; 1206mapping.TypeName = mapping.TypeDesc.Name; 1252if (arrayMapping.TypeDesc!.IsNullable) 1296arrayMapping.TypeName = string.IsNullOrEmpty(type.Name) ? $"ArrayOf{CodeIdentifier.MakePascal(arrayMapping.TypeDesc!.Name)}" : type.Name; 1312arrayMapping.TypeDesc = ((TypeMapping)itemAccessor.Mapping!).TypeDesc!.CreateArrayTypeDesc(); 1313arrayMapping.TypeName = string.IsNullOrEmpty(type.Name) ? $"ArrayOf{CodeIdentifier.MakePascal(itemAccessor.Mapping.TypeDesc.Name)}" : type.Name; 1396mapping.TypeName = mapping.TypeDesc.Name; 1398mapping.TypeDesc = mapping.TypeDesc.CreateArrayTypeDesc(); 1434member.TypeDesc = accessor.Mapping.TypeDesc; 1438member.TypeDesc = accessor.Mapping.TypeDesc; 1452member.TypeDesc = accessor.Mapping.TypeDesc!.CreateArrayTypeDesc(); 1479member.TypeDesc = accessor.IsList ? accessor.Mapping!.TypeDesc!.CreateArrayTypeDesc() : accessor.Mapping!.TypeDesc; 1492mapping.TypeName = mapping.TypeDesc.Name; 1504member.TypeDesc = ((TypeMapping)accessor.Mapping).TypeDesc; 1553xmlnsMapping.TypeName = xmlnsMapping.TypeDesc.Name; 1592mapping.TypeName = mapping.TypeDesc.DataType!.Name; 1833mapping.Namespace = mapping.TypeDesc.IsXsdType ? XmlSchema.Namespace : UrtTypes.Namespace; 1849mapping.Namespace = mapping.TypeDesc.IsXsdType ? XmlSchema.Namespace : ns;
System\Xml\Serialization\XmlSerializationGeneratedCode.cs (3)
241string serializerName = CodeIdentifier.MakeValid(Accessor.UnescapeName(mapping.Accessor.Mapping!.TypeDesc!.Name)); 346Type? type = xmlMappings[i].Accessor.Mapping!.TypeDesc!.Type; 401return mapping.TypeDesc!.CanBeElementValue;
System\Xml\Serialization\XmlSerializationILGen.cs (3)
314string serializerName = CodeIdentifier.MakeValid(Accessor.UnescapeName(mapping.Accessor.Mapping!.TypeDesc!.Name)); 448Type? type = xmlMappings[i].Accessor.Mapping!.TypeDesc!.Type; 569return mapping.TypeDesc!.CanBeElementValue;
System\Xml\Serialization\XmlSerializationReader.cs (123)
2131bool choiceUseReflection = mapping.ChoiceIdentifier.Mapping!.TypeDesc!.UseReflection; 2132string choiceTypeFullName = mapping.ChoiceIdentifier.Mapping.TypeDesc.CSharpName; 2136_choiceArraySource = init + outerClass.RaCodeGen.GetStringForArrayMember(a, $"{c}++", mapping.ChoiceIdentifier.Mapping.TypeDesc); 2245MethodNames.Add(mapping, NextMethodName(mapping.TypeDesc!.Name)); 2391!mapping.TypeDesc!.IsRoot) 2407Writer.Write(RaCodeGen.GetStringForTypeof(mapping.TypeDesc.CSharpName, mapping.TypeDesc.UseReflection)); 2797member.TypeDesc = mapping.TypeDesc; 2826if (enumMethodName == null) throw new InvalidOperationException(SR.Format(SR.XmlMissingMethodEnum, mapping.TypeDesc!.Name)); 2831Writer.Write(mapping.TypeDesc!.CSharpName); 2839else if (mapping.TypeDesc == StringTypeDesc) 2843else if (mapping.TypeDesc!.FormatterName == "String") 2845if (mapping.TypeDesc.CollapseWhitespace) 2858if (!mapping.TypeDesc.HasCustomFormatter) 2864Writer.Write(mapping.TypeDesc.FormatterName); 2935if (!mapping.TypeDesc!.UseReflection) 2938Writer.Write(mapping.TypeDesc.CSharpName); 2975tableName = WriteHashtable(mapping, mapping.TypeDesc!.Name); 2979bool useReflection = mapping.TypeDesc!.UseReflection; 2980string fullTypeName = mapping.TypeDesc.CSharpName; 3070if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, derived.TypeDesc!.Name)); 3074if (derived.TypeDesc!.UseReflection && isTypedReturn) 3078if (derived.TypeDesc.IsNullable) 3107if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, enumMapping.TypeDesc!.Name)); 3119if (arrayMapping.TypeDesc!.HasDefaultConstructor) 3126memberMapping.TypeDesc = arrayMapping.TypeDesc; 3130TypeDesc td = arrayMapping.TypeDesc; 3131string fullTypeName = arrayMapping.TypeDesc.CSharpName; 3142if (arrayMapping.TypeDesc.IsValueType) 3163bool useReflection = nullableMapping.BaseMapping!.TypeDesc!.UseReflection; 3164string typeName = useReflection ? "object" : nullableMapping.TypeDesc!.CSharpName; 3197element.IsNullable = nullableMapping.BaseMapping.TypeDesc.IsNullable; 3217bool useReflection = structMapping.TypeDesc!.UseReflection; 3218string typeName = useReflection ? "object" : structMapping.TypeDesc.CSharpName; 3224if (structMapping.TypeDesc.IsNullable) 3232if (structMapping.TypeDesc.IsNullable) 3236if (structMapping.TypeDesc.IsRoot) 3243if (structMapping.TypeDesc.IsValueType) 3245Writer.Write(RaCodeGen.GetStringForCreateInstance(structMapping.TypeDesc.CSharpName, useReflection, false, false)); 3255if (!structMapping.TypeDesc.IsRoot) 3261if (structMapping.TypeDesc.IsRoot) 3270WriteDerivedTypes(structMapping, !useReflection && !structMapping.TypeDesc.IsRoot, typeName); 3271if (structMapping.TypeDesc.IsRoot) WriteEnumAndArrayTypes(); 3272if (structMapping.TypeDesc.IsRoot) 3280if (structMapping.TypeDesc.IsRoot) 3283if (structMapping.TypeDesc.IsNullable) 3286if (structMapping.TypeDesc.IsAbstract) 3296if (structMapping.TypeDesc.Type != null && typeof(XmlSchemaObject).IsAssignableFrom(structMapping.TypeDesc.Type)) 3317string source = RaCodeGen.GetStringForMember("o", mapping.Name, structMapping.TypeDesc); 3318Member member = new Member(this, source, "a", i, mapping, GetChoiceIdentifierSource(mapping, "o", structMapping.TypeDesc)); 3323member.CheckSpecifiedSource = RaCodeGen.GetStringForMember("o", $"{mapping.Name}Specified", structMapping.TypeDesc); 3344throw new InvalidOperationException(SR.Format(SR.XmlSequenceHierarchy, structMapping.TypeDesc.FullName, mapping.Name, declaringMapping!.TypeDesc!.FullName, "Order")); 3348Member arrayMember = new Member(this, source, source, "a", i, mapping, GetChoiceIdentifierSource(mapping, "o", structMapping.TypeDesc)); 3421if (structMapping.TypeDesc!.IsRoot) 3436if (structMapping.TypeDesc.IsAbstract) 3457string source = RaCodeGen.GetStringForMember("o", mapping.Name, structMapping.TypeDesc); 3458Member member = new Member(this, source, source, "a", i, mapping, GetChoiceIdentifierSource(mapping, "o", structMapping.TypeDesc)); 3460member.CheckSpecifiedSource = RaCodeGen.GetStringForMember("o", $"{mapping.Name}Specified", structMapping.TypeDesc); 3492if (anyFixups) WriteFixupMethod(fixupMethodName, members, structMapping.TypeDesc.CSharpName, structMapping.TypeDesc.UseReflection, true, "o"); 3799if (special.TypeDesc!.Kind == TypeKind.Attribute) 3806else if (special.TypeDesc.CanBeAttributeValue) 3921WriteArrayLocalDecl($"{member.Mapping.ChoiceIdentifier.Mapping!.TypeDesc!.CSharpName}[]", 3923member.Mapping.ChoiceIdentifier.Mapping.TypeDesc); 4078WriteSourceBeginTyped(member.ArraySource, special.TypeDesc); 4079switch (special.TypeDesc!.Kind) 4094if (text.Mapping!.TypeDesc!.CollapseWhitespace) 4105if (text.Mapping!.TypeDesc == StringTypeDesc || text.Mapping.TypeDesc!.FormatterName == "String") 4108if (text.Mapping.TypeDesc!.CollapseWhitespace) 4248TypeDesc td = ((NullableMapping)e.Mapping).BaseMapping!.TypeDesc!; 4253Writer.Write(RaCodeGen.GetStringForTypeof(e.Mapping!.TypeDesc!.CSharpName, e.Mapping.TypeDesc.UseReflection)); 4278if (e.Mapping!.TypeDesc!.IsValueType || e.Mapping is NullableMapping) 4288TypeDesc td = ((NullableMapping)e.Mapping).BaseMapping!.TypeDesc!; 4289Writer.Write(RaCodeGen.GetStringForCreateInstance(e.Mapping.TypeDesc.CSharpName, e.Mapping.TypeDesc.UseReflection, false, true, $"({td.CSharpName}){checkTypeSource}")); 4293WriteSourceBeginTyped(member.ArraySource, e.Mapping.TypeDesc); 4298if (e.Mapping.TypeDesc.IsValueType) 4460bool choiceUseReflection = member.Mapping.ChoiceIdentifier.Mapping!.TypeDesc!.UseReflection; 4461string choiceTypeName = member.Mapping.ChoiceIdentifier.Mapping.TypeDesc.CSharpName; 4535TypeDesc td = arrayMapping.TypeDesc!; 4548WriteSourceBeginTyped(source, arrayMapping.TypeDesc); 4552WriteCatchCastException(arrayMapping.TypeDesc!, "rre", null); 4562memberMapping.TypeDesc = arrayMapping.TypeDesc; 4635if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, element.Mapping.TypeDesc!.Name)); 4650if (element.Mapping.TypeDesc!.IsValueType) 4652Writer.Write(RaCodeGen.GetStringForCreateInstance(element.Mapping.TypeDesc.CSharpName, element.Mapping.TypeDesc.UseReflection, false, false)); 4664if (element.Default != null && element.Default != DBNull.Value && element.Mapping.TypeDesc!.IsValueType) 4679if (element.Mapping.TypeDesc!.Type == typeof(TimeSpan) || element.Mapping.TypeDesc!.Type == typeof(DateTimeOffset)) 4685if (element.Mapping.TypeDesc!.Type == typeof(TimeSpan)) 4689else if (element.Mapping.TypeDesc!.Type == typeof(DateTimeOffset)) 4709if (element.Mapping.TypeDesc == QnameTypeDesc) 4714switch (element.Mapping.TypeDesc.FormatterName) 4755if (mapping.TypeDesc!.IsValueType) 4763WriteSourceBeginTyped(source, mapping.TypeDesc); 4767WriteCatchCastException(mapping.TypeDesc, "rre", null); 4771if (mapping.TypeDesc.IsValueType) 4782if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, mapping.TypeDesc!.Name)); 4794if (mapping.TypeDesc!.IsNullable) 4807switch (special.TypeDesc!.Kind) 4810bool isDoc = special.TypeDesc.FullName == typeof(XmlDocument).FullName; 4811WriteSourceBeginTyped(source, special.TypeDesc); 4832WriteSourceBeginTyped(source, sm.TypeDesc); 4836if (sm.TypeDesc!.CSharpName == "global::System.Xml.Linq.XElement") 4838Writer.Write(RaCodeGen.GetStringForCreateInstance(sm.TypeDesc!.CSharpName, false, false, false, "\"default\"")); 4842Writer.Write(RaCodeGen.GetStringForCreateInstance(sm.TypeDesc!.CSharpName, sm.TypeDesc.UseReflection, sm.TypeDesc.CannotNew, false)); 4875string enumTypeName = choice.Mapping!.TypeDesc!.CSharpName; 4879Writer.Write(RaCodeGen.GetStringForEnumMember(enumTypeName, choice.MemberIds[elementIndex], choice.Mapping.TypeDesc.UseReflection)); 4901WriteSourceBeginTyped(source, head.TypeDesc); 4905Writer.Write(RaCodeGen.GetStringForCreateInstance(derived.TypeDesc!.CSharpName, derived.TypeDesc.UseReflection, derived.TypeDesc.CannotNew, false)); 5053string fullTypeName = mapping.TypeDesc!.CSharpName; 5054bool useReflection = mapping.TypeDesc.UseReflection; 5055bool ctorInaccessible = mapping.TypeDesc.CannotNew; 5069Writer.Write(RaCodeGen.GetStringForCreateInstance(fullTypeName, useReflection, mapping.TypeDesc.CannotNew, true));
System\Xml\Serialization\XmlSerializationReaderILGen.cs (115)
93string choiceTypeFullName = mapping.ChoiceIdentifier.Mapping!.TypeDesc!.CSharpName; 198MethodNames.Add(mapping, NextMethodName(mapping.TypeDesc!.Name)); 644member.TypeDesc = mapping.TypeDesc; 685if (enumMethodName == null) throw new InvalidOperationException(SR.Format(SR.XmlMissingMethodEnum, mapping.TypeDesc!.Name)); 691mapping.TypeDesc!.Type, 743else if (mapping.TypeDesc == StringTypeDesc) 788else if (mapping.TypeDesc!.FormatterName == "String") 793if (mapping.TypeDesc.CollapseWhitespace) 798if (mapping.TypeDesc.CollapseWhitespace) 822if (mapping.TypeDesc.CollapseWhitespace) 827if (mapping.TypeDesc.CollapseWhitespace) 842if (mapping.TypeDesc.HasCustomFormatter) 846if ((mapping.TypeDesc.FormatterName == "ByteArrayBase64" && source == "false") 847|| (mapping.TypeDesc.FormatterName == "ByteArrayHex" && source == "false") 848|| (mapping.TypeDesc.FormatterName == "XmlQualifiedName")) 855$"To{mapping.TypeDesc.FormatterName}", 863$"To{mapping.TypeDesc.FormatterName}", 993ilg.Ldc(Enum.ToObject(mapping.TypeDesc!.Type!, constants[i].Value)); 994ilg.ConvertValue(mapping.TypeDesc.Type!, typeof(long)); 1019WriteHashtable(mapping, mapping.TypeDesc!.Name, out get_TableName); 1023string fullTypeName = mapping.TypeDesc!.CSharpName; 1029returnType = mapping.TypeDesc.Type!; 1096retValues.Add(Enum.ToObject(mapping.TypeDesc.Type!, c.Value)); 1119ilg.Ldc(mapping.TypeDesc.Type!); 1142if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, derived.TypeDesc!.Name)); 1147if (derived.TypeDesc!.IsNullable) 1158derived.TypeDesc.Type, 1197if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, enumMapping.TypeDesc!.Name)); 1203enumMapping.TypeDesc!.Type, 1239if (arrayMapping.TypeDesc!.HasDefaultConstructor) 1246memberMapping.TypeDesc = arrayMapping.TypeDesc; 1252TypeDesc td = arrayMapping.TypeDesc; 1253LocalBuilder aLoc = ilg.DeclareLocal(arrayMapping.TypeDesc.Type!, aVar); 1254if (arrayMapping.TypeDesc.IsValueType) 1280nullableMapping.TypeDesc!.Type!, 1286LocalBuilder oLoc = ilg.DeclareLocal(nullableMapping.TypeDesc.Type!, "o"); 1289ilg.InitObj(nullableMapping.TypeDesc.Type!); 1307element.IsNullable = nullableMapping.BaseMapping!.TypeDesc!.IsNullable; 1328string typeName = structMapping.TypeDesc!.CSharpName; 1332if (structMapping.TypeDesc.IsNullable) 1340structMapping.TypeDesc.Type!, 1371if (structMapping.TypeDesc.IsNullable) 1385if (structMapping.TypeDesc.IsRoot) 1403if (structMapping.TypeDesc.IsValueType) 1420if (!structMapping.TypeDesc.IsRoot) 1434if (structMapping.TypeDesc.IsRoot) 1453WriteDerivedTypes(structMapping, !structMapping.TypeDesc.IsRoot, typeName); 1454if (structMapping.TypeDesc.IsRoot) WriteEnumAndArrayTypes(); 1456if (structMapping.TypeDesc.IsRoot) 1484if (structMapping.TypeDesc.IsNullable) 1496if (structMapping.TypeDesc.IsAbstract) 1511if (structMapping.TypeDesc.Type != null && typeof(XmlSchemaObject).IsAssignableFrom(structMapping.TypeDesc.Type)) 1568throw new InvalidOperationException(SR.Format(SR.XmlSequenceHierarchy, structMapping.TypeDesc.FullName, mapping.Name, declaringMapping!.TypeDesc!.FullName, "Order")); 1686ilg.Ldloc(structMapping.TypeDesc.Type!, "o"); 2037if (special.TypeDesc!.Kind == TypeKind.Attribute) 2043else if (special.TypeDesc.CanBeAttributeValue) 2143WriteArrayLocalDecl($"{member.Mapping.ChoiceIdentifier.Mapping!.TypeDesc!.CSharpName}[]", 2145member.Mapping.ChoiceIdentifier.Mapping.TypeDesc); 2320switch (special.TypeDesc!.Kind) 2353WriteSourceEnd(member.ArraySource, special.TypeDesc.Type!); 2360if (text.Mapping!.TypeDesc!.CollapseWhitespace) 2380if (text.Mapping.TypeDesc.CollapseWhitespace) 2392if (text.Mapping!.TypeDesc == StringTypeDesc || text.Mapping.TypeDesc!.FormatterName == "String") 2402ilg.Ldc(text.Mapping.TypeDesc!.CollapseWhitespace); 2415WriteSourceEnd(member.ArraySource, text.Mapping.TypeDesc.Type!); 2659ilg.Ldc(member.Mapping.ChoiceIdentifier.Mapping!.TypeDesc!.Type!); 2662ilg.ConvertValue(XmlSerializationReader_ShrinkArray.ReturnType, member.Mapping.ChoiceIdentifier.Mapping.TypeDesc.Type!.MakeArrayType()); 2663WriteSourceEnd(member.ChoiceSource!, member.Mapping.ChoiceIdentifier.Mapping.TypeDesc.Type!.MakeArrayType()); 2861memberMapping.TypeDesc = arrayMapping.TypeDesc; 2979if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, element.Mapping.TypeDesc!.Name)); 2988element.Mapping.TypeDesc!.Type, 2992WriteSourceEnd(source, element.Mapping.TypeDesc.Type!); 3008if (element.Mapping.TypeDesc!.IsValueType) 3016WriteSourceEnd(source, element.Mapping.TypeDesc.Type!); 3020if (element.Default != null && element.Default != DBNull.Value && element.Mapping.TypeDesc!.IsValueType) 3051if ((element.Mapping.TypeDesc!.Type == typeof(TimeSpan)) || element.Mapping.TypeDesc!.Type == typeof(DateTimeOffset)) 3076LocalBuilder tmpLoc = ilg.GetTempLocal(element.Mapping.TypeDesc!.Type); 3078ilg.InitObj(element.Mapping.TypeDesc!.Type); 3080WriteSourceEnd(source, element.Mapping.TypeDesc.Type); 3084WriteSourceEnd(source, element.Mapping.TypeDesc.Type); 3090if (element.Mapping.TypeDesc == QnameTypeDesc) 3103switch (element.Mapping.TypeDesc.FormatterName) 3116WriteSourceEnd(source, element.Mapping.TypeDesc.Type!); 3128if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, mapping.TypeDesc!.Name)); 3154if (mapping.TypeDesc!.IsNullable) 3164mapping.TypeDesc.Type, 3168WriteSourceEnd(source, mapping.TypeDesc.Type!); 3175switch (special.TypeDesc!.Kind) 3178bool isDoc = special.TypeDesc.FullName == typeof(XmlDocument).FullName; 3189if (special.TypeDesc != null) 3190ilg.Castclass(special.TypeDesc.Type!); 3191WriteSourceEnd(source, special.TypeDesc!.Type!); 3229ReflectionAwareILGen.ILGenForCreateInstance(ilg, sm.TypeDesc!.Type!, sm.TypeDesc.CannotNew, false); 3230if (sm.TypeDesc.CannotNew) 3236if (sm.TypeDesc != null) 3237ilg.ConvertValue(typeof(IXmlSerializable), sm.TypeDesc.Type!); 3238WriteSourceEnd(source, sm.TypeDesc!.Type!); 3262ReflectionAwareILGen.ILGenForEnumMember(ilg, choice.Mapping!.TypeDesc!.Type!, choice.MemberIds[elementIndex]); 3263WriteSourceEnd(choiceSource!, choice.Mapping.TypeDesc.Type!); 3300ReflectionAwareILGen.ILGenForCreateInstance(ilg, derived.TypeDesc!.Type!, derived.TypeDesc.CannotNew, false); 3301if (derived.TypeDesc.CannotNew) 3307if (head.TypeDesc != null) 3308ilg.ConvertValue(typeof(IXmlSerializable), head.TypeDesc.Type!); 3309WriteSourceEnd(source, head.TypeDesc!.Type!); 3430string fullTypeName = mapping.TypeDesc!.CSharpName; 3431bool ctorInaccessible = mapping.TypeDesc.CannotNew; 3434mapping.TypeDesc.Type!, 3441ReflectionAwareILGen.ILGenForCreateInstance(ilg, mapping.TypeDesc.Type!, mapping.TypeDesc.CannotNew, true);
System\Xml\Serialization\XmlSerializationWriter.cs (118)
1696string typeFullName = mapping.TypeDesc!.CSharpName; 1906return $"{mapping.TypeDesc!.CSharpName}.@{memberName}"; 1908string memberAccess = GetStringForEnumMember(mapping.TypeDesc!.CSharpName, memberName, useReflection); 2264MethodNames.Add(mapping, NextMethodName(mapping.TypeDesc!.Name)); 2340!typeMapping.TypeDesc!.IsRoot) 2344Writer.Write(RaCodeGen.GetStringForTypeof(typeMapping.TypeDesc.CSharpName, typeMapping.TypeDesc.UseReflection)); 2408if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, mapping.TypeDesc!.Name) + Environment.StackTrace); 2448TypeDesc typeDesc = mapping.TypeDesc!; 2449bool hasDefault = defaultValue != null && defaultValue != DBNull.Value && mapping.TypeDesc!.HasDefaultSupport; 2460if (mapping.TypeDesc!.UseReflection) 2461Writer.Write(ReflectionAwareCodeGen.GetStringForEnumLongValue(source, mapping.TypeDesc.UseReflection)); 2475Writer.Write(RaCodeGen.GetStringForEnumCompare((EnumMapping)mapping, values[i], mapping.TypeDesc.UseReflection)); 2481Writer.Write(RaCodeGen.GetStringForEnumCompare((EnumMapping)mapping, (string)defaultValue!, mapping.TypeDesc.UseReflection)); 2749if (member.ChoiceIdentifier.Mapping!.TypeDesc!.UseReflection) 2840if (!mapping.IsSoap && !mapping.TypeDesc!.IsValueType && !mapping.TypeDesc.Type!.IsPrimitive) 2845WriteMember("o", null, new ElementAccessor[] { element }, null, null, mapping.TypeDesc!, !element.IsSoap); 2865string fullTypeName = mapping.TypeDesc!.CSharpName; 2871WriteLocalDecl(fullTypeName, "v", "e", mapping.TypeDesc.UseReflection); 2878Writer.Write(mapping.TypeDesc.UseReflection ? "object" : fullTypeName); 2888if (mapping.TypeDesc.UseReflection) 2889Writer.WriteLine($"switch ({ReflectionAwareCodeGen.GetStringForEnumLongValue("v", mapping.TypeDesc.UseReflection)} ){{"); 2898WriteEnumCase(fullTypeName, c, mapping.TypeDesc.UseReflection); 2910Writer.Write(ReflectionAwareCodeGen.GetStringForEnumLongValue("v", mapping.TypeDesc.UseReflection)); 2930if (mapping.TypeDesc.UseReflection) 2942WriteQuotedCSharpString(mapping.TypeDesc.FullName); 2948Writer.Write(ReflectionAwareCodeGen.GetStringForEnumLongValue("v", mapping.TypeDesc.UseReflection)); 2950WriteQuotedCSharpString(mapping.TypeDesc.FullName); 2977string fullTypeName = derived.TypeDesc!.CSharpName; 2979WriteTypeCompare("t", fullTypeName, derived.TypeDesc.UseReflection); 2987if (methodName == null) throw new InvalidOperationException("derived from " + mapping.TypeDesc!.FullName + ", " + SR.Format(SR.XmlInternalErrorMethod, derived.TypeDesc.Name) + Environment.StackTrace); 2992if (!derived.TypeDesc.UseReflection) Writer.Write($"({fullTypeName})"); 2994if (derived.TypeDesc.IsNullable) 3016string fullTypeName = mapping.TypeDesc!.CSharpName; 3018WriteTypeCompare("t", fullTypeName, mapping.TypeDesc.UseReflection); 3026if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, mapping.TypeDesc.Name) + Environment.StackTrace); 3037if (!mapping.TypeDesc.UseReflection) Writer.Write($"({fullTypeName})"); 3048string fullTypeName = mapping.TypeDesc!.CSharpName; 3050if (mapping.TypeDesc.IsArray) 3051WriteArrayTypeCompare("t", fullTypeName, mapping.TypeDesc.ArrayElementTypeDesc!.CSharpName, mapping.TypeDesc.UseReflection); 3053WriteTypeCompare("t", fullTypeName, mapping.TypeDesc.UseReflection); 3064WriteMember("o", null, mapping.ElementsSortedByDerivation!, null, null, mapping.TypeDesc, true); 3078if (mapping.IsSoap && mapping.TypeDesc!.IsRoot) return; 3085string fullTypeName = mapping.TypeDesc!.CSharpName; 3091WriteLocalDecl(fullTypeName, "o", "s", mapping.TypeDesc.UseReflection); 3096Writer.Write(mapping.TypeDesc.UseReflection ? "object" : fullTypeName); 3098if (mapping.TypeDesc.IsNullable) 3102if (mapping.TypeDesc.IsNullable) 3117WriteTypeCompare("t", fullTypeName, mapping.TypeDesc.UseReflection); 3123if (mapping.TypeDesc.IsRoot) 3126if (mapping.TypeDesc.IsRoot) 3141if (!mapping.TypeDesc.IsAbstract) 3143if (mapping.TypeDesc.Type != null && typeof(XmlSchemaObject).IsAssignableFrom(mapping.TypeDesc.Type)) 3155xmlnsSource = RaCodeGen.GetStringForMember("o", member.Name, mapping.TypeDesc); 3156if (mapping.TypeDesc.UseReflection) 3171if (!mapping.TypeDesc.IsRoot) 3193string methodInvoke = RaCodeGen.GetStringForMethodInvoke("o", fullTypeName, $"ShouldSerialize{m.Name}", mapping.TypeDesc.UseReflection); 3194if (mapping.TypeDesc.UseReflection) methodInvoke = $"(({typeof(bool).FullName}){methodInvoke})"; 3202string memberGet = RaCodeGen.GetStringForMember("o", $"{m.Name}Specified", mapping.TypeDesc); 3203if (mapping.TypeDesc.UseReflection) memberGet = $"(({typeof(bool).FullName}){memberGet})"; 3208WriteMember(RaCodeGen.GetStringForMember("o", m.Name, mapping.TypeDesc), m.Attribute, m.TypeDesc!, "o"); 3234string methodInvoke = RaCodeGen.GetStringForMethodInvoke("o", fullTypeName, $"ShouldSerialize{m.Name}", mapping.TypeDesc.UseReflection); 3235if (mapping.TypeDesc.UseReflection) methodInvoke = $"(({typeof(bool).FullName}){methodInvoke})"; 3243string memberGet = RaCodeGen.GetStringForMember("o", $"{m.Name}Specified", mapping.TypeDesc); 3244if (mapping.TypeDesc.UseReflection) memberGet = $"(({typeof(bool).FullName}){memberGet})"; 3254choiceSource = RaCodeGen.GetStringForMember("o", m.ChoiceIdentifier.MemberName, mapping.TypeDesc); 3256WriteMember(RaCodeGen.GetStringForMember("o", m.Name, mapping.TypeDesc), choiceSource, m.ElementsSortedByDerivation!, m.Text, m.ChoiceIdentifier, m.TypeDesc!, true); 3464if (special.TypeDesc!.Kind == TypeKind.Attribute || special.TypeDesc.CanBeAttributeValue) 3477TypeDesc typeDesc = attribute.Mapping!.TypeDesc!; 3509string choiceFullName = choice.Mapping!.TypeDesc!.CSharpName; 3510WriteArrayLocalDecl($"{choiceFullName}[]", "c", choiceSource, choice.Mapping.TypeDesc); 3515WriteQuotedCSharpString(choice.Mapping.TypeDesc.FullName); 3621string choiceFullName = choice.Mapping!.TypeDesc!.CSharpName; 3622WriteLocalDecl(choiceFullName, $"{choiceName}i", RaCodeGen.GetStringForArrayMember(choiceName!, $"i{arrayName}", choice.Mapping.TypeDesc), choice.Mapping.TypeDesc.UseReflection); 3647TypeDesc td = elements[0].IsUnbounded ? elements[0].Mapping!.TypeDesc!.CreateArrayTypeDesc() : elements[0].Mapping!.TypeDesc!; 3648if (!elements[0].Any && !elements[0].Mapping!.TypeDesc!.UseReflection && !elements[0].Mapping!.TypeDesc!.IsOptionalValue) 3666string? enumTypeName = choice == null ? null : choice.Mapping!.TypeDesc!.FullName; 3686bool useReflection = element.Mapping!.TypeDesc!.UseReflection; 3687string fullTypeName = element.Mapping.TypeDesc.CSharpName; 3688bool enumUseReflection = choice.Mapping!.TypeDesc!.UseReflection; 3706WriteChoiceTypeCheck(source, fullTypeName, useReflection, choice, enumFullName, element.Mapping.TypeDesc); 3717bool useReflection = element.Mapping!.TypeDesc!.UseReflection; 3718TypeDesc td = element.IsUnbounded ? element.Mapping.TypeDesc.CreateArrayTypeDesc() : element.Mapping.TypeDesc; 3764bool enumUseReflection = choice.Mapping!.TypeDesc!.UseReflection; 3830bool useReflection = text.Mapping!.TypeDesc!.UseReflection; 3831string fullTypeName = text.Mapping.TypeDesc.CSharpName; 3891WritePrimitiveValue(primitive.TypeDesc!, source); 3897switch (simple.TypeDesc!.Kind) 3920string fullTypeName = element.Mapping.TypeDesc!.BaseTypeDesc!.CSharpName; 3922if (!element.Mapping.TypeDesc.BaseTypeDesc.UseReflection) 3951Writer.Write(RaCodeGen.GetStringForTypeof(arrayMapping.TypeDesc!.CSharpName, arrayMapping.TypeDesc.UseReflection)); 3963TypeDesc td = arrayMapping.TypeDesc!.CreateArrayTypeDesc(); 3969WriteArrayLocalDecl(fullTypeName, elementArrayName, source, arrayMapping.TypeDesc); 3976if (arrayMapping.TypeDesc.IsNullable) 4024string fullTypeName = arrayMapping.TypeDesc!.CSharpName; 4027WriteArrayLocalDecl(fullTypeName, arrayName, source, arrayMapping.TypeDesc); 4034if (arrayMapping.TypeDesc.IsNullable) 4044WriteArrayItems(arrayMapping.ElementsSortedByDerivation!, null, null, arrayMapping.TypeDesc, arrayName, null); 4075if (primitiveMapping.TypeDesc == QnameTypeDesc) 4080string suffixRaw = primitiveMapping.TypeDesc!.XmlEncodingNotRequired ? "Raw" : ""; 4098Writer.Write(RaCodeGen.GetStringForTypeof(structMapping.TypeDesc!.CSharpName, structMapping.TypeDesc.UseReflection)); 4113if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, structMapping.TypeDesc!.Name) + Environment.StackTrace); 4127if (structMapping.TypeDesc!.IsNullable) 4216Type? type = Type.GetType(mapping.TypeDesc!.Type!.FullName!); 4224Type? type = Type.GetType(mapping.TypeDesc!.Type!.FullName!); 4486throw new InvalidOperationException(SR.Format(SR.XmlChoiceMissingAnyValue, choiceMapping.TypeDesc!.FullName)); 4489throw new InvalidOperationException(SR.Format(SR.XmlChoiceMissingValue, choiceMapping.TypeDesc!.FullName, $"{element.Namespace}:{element.Name}", element.Name, element.Namespace));
System\Xml\Serialization\XmlSerializationWriterILGen.cs (85)
41MethodNames.Add(mapping, NextMethodName(mapping.TypeDesc!.Name)); 110source.Load(mapping.TypeDesc!.Type!); 111argTypes.Add(mapping.TypeDesc.Type!); 127if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, mapping.TypeDesc!.Name)); 136new Type[] { mapping.TypeDesc!.Type! }); 138source.Load(mapping.TypeDesc.Type!); 193TypeDesc typeDesc = mapping.TypeDesc!; 194bool hasDefault = defaultValue != null && defaultValue != DBNull.Value && mapping.TypeDesc!.HasDefaultSupport; 204source.Load(mapping.TypeDesc!.Type!); 222ilg.Ldc(Enum.Parse(mapping.TypeDesc.Type!, enumDefaultValue!, false)); 574if (!mapping.TypeDesc!.IsValueType && !mapping.TypeDesc.Type!.IsPrimitive) 585WriteMember(new SourceInfo("o", "o", null, typeof(object), ilg), null, new ElementAccessor[] { element }, null, null, mapping.TypeDesc, true); 602argTypes.Add(mapping.TypeDesc!.Type!); 624LocalBuilder localTmp = ilg.DeclareLocal(mapping.TypeDesc.Type!, "localTmp"); 634ilg.Ldc(Enum.ToObject(mapping.TypeDesc.Type!, c.Value)); 679ilg.Ldstr(GetCSharpString(mapping.TypeDesc.FullName)); 719ilg.ConvertValue(mapping.TypeDesc.Type!, typeof(long)); 726ilg.Ldstr(GetCSharpString(mapping.TypeDesc.FullName)); 741WriteTypeCompare("t", derived.TypeDesc!.Type!); 748if (methodName == null) throw new InvalidOperationException("derived from " + mapping.TypeDesc!.FullName + ", " + SR.Format(SR.XmlInternalErrorMethod, derived.TypeDesc.Name)); 760ilg.ConvertValue(oType, derived.TypeDesc.Type!); 761argTypes.Add(derived.TypeDesc.Type!); 762if (derived.TypeDesc.IsNullable) 791WriteTypeCompare("t", mapping.TypeDesc!.Type!); 799if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, mapping.TypeDesc.Name)); 829new Type[] { mapping.TypeDesc.Type! } 841ilg.ConvertValue(CodeGenerator.GetVariableType(oVar), mapping.TypeDesc.Type!); 859if (mapping.TypeDesc!.IsArray) 860WriteArrayTypeCompare("t", mapping.TypeDesc.Type!); 862WriteTypeCompare("t", mapping.TypeDesc.Type!); 892WriteMember(new SourceInfo("o", "o", null, null, ilg), null, mapping.ElementsSortedByDerivation!, null, null, mapping.TypeDesc, true); 921argTypes.Add(mapping.TypeDesc!.Type!); 923if (mapping.TypeDesc.IsNullable) 935if (mapping.TypeDesc.IsNullable) 969WriteTypeCompare("t", mapping.TypeDesc.Type!); 973if (mapping.TypeDesc.IsRoot) 976if (mapping.TypeDesc.IsRoot) 1007if (!mapping.TypeDesc.IsAbstract) 1009if (mapping.TypeDesc.Type != null && typeof(XmlSchemaObject).IsAssignableFrom(mapping.TypeDesc.Type)) 1052if (!mapping.TypeDesc.IsRoot) 1360if (special.TypeDesc!.Kind == TypeKind.Attribute || special.TypeDesc.CanBeAttributeValue) 1379TypeDesc typeDesc = attribute.Mapping!.TypeDesc!; 1432string choiceFullName = choice.Mapping!.TypeDesc!.CSharpName; 1434cName = $"c{choice.Mapping.TypeDesc.Name}"; 1435WriteArrayLocalDecl($"{choiceFullName}[]", cName, choiceSourceInfo, choice.Mapping.TypeDesc); 1459ilg.Ldstr(GetCSharpString(choice.Mapping.TypeDesc.FullName)); 1552WriteLocalDecl($"{choiceName}i", ReflectionAwareILGen.GetStringForArrayMember(choiceName, iPlusArrayName), choice.Mapping!.TypeDesc!.Type!); 1569TypeDesc td = elements[0].IsUnbounded ? elements[0].Mapping!.TypeDesc!.CreateArrayTypeDesc() : elements[0].Mapping!.TypeDesc!; 1570if (!elements[0].Any && !elements[0].Mapping!.TypeDesc!.IsOptionalValue) 1588string? enumTypeName = choice == null ? null : choice.Mapping!.TypeDesc!.FullName; 1613ILGenLoad(enumSource!, choice == null ? null : choice.Mapping!.TypeDesc!.Type); 1631WriteChoiceTypeCheck(source, choice!, enumFullName, element.Mapping!.TypeDesc!); 1633SourceInfo castedSource = source.CastTo(element.Mapping.TypeDesc!); 1638TypeDesc td = element.IsUnbounded ? element.Mapping!.TypeDesc!.CreateArrayTypeDesc() : element.Mapping!.TypeDesc!; 1690ILGenLoad(enumSource!, choice == null ? null : choice.Mapping!.TypeDesc!.Type); 1807WriteInstanceOf(source, text.Mapping!.TypeDesc!.Type!); 1809SourceInfo castedSource = source.CastTo(text.Mapping.TypeDesc); 1814SourceInfo castedSource = source.CastTo(text.Mapping!.TypeDesc!); 1861WritePrimitiveValue(primitiveMapping.TypeDesc!, source, out argType); 1872switch (specialMapping.TypeDesc!.Kind) 1902if (source.Type == element.Mapping.TypeDesc!.Type) 1904MethodInfo Nullable_get_HasValue = element.Mapping.TypeDesc.Type!.GetMethod( 1909source.LoadAddress(element.Mapping.TypeDesc.Type); 1919SourceInfo castedSource = source.CastTo(element.Mapping.TypeDesc.BaseTypeDesc!); 1939string fullTypeName = arrayMapping.TypeDesc!.CSharpName; 1940WriteArrayLocalDecl(fullTypeName, arrayName, source, arrayMapping.TypeDesc); 1947if (arrayMapping.TypeDesc.IsNullable) 1955WriteArrayItems(arrayMapping.ElementsSortedByDerivation!, null, null, arrayMapping.TypeDesc, arrayName, null); 1963if (arrayMapping.TypeDesc.IsNullable) 1977if (primitiveMapping.TypeDesc == QnameTypeDesc) 1983string suffixRaw = primitiveMapping.TypeDesc!.XmlEncodingNotRequired ? "Raw" : ""; 1994if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, structMapping.TypeDesc!.Name)); 2002source.Load(structMapping.TypeDesc!.Type); 2003argTypes.Add(structMapping.TypeDesc.Type!); 2004if (structMapping.TypeDesc.IsNullable) 2253eValue = Enum.ToObject(choiceMapping.TypeDesc!.Type!, choiceMapping.Constants[i].Value); 2267eValue = Enum.ToObject(choiceMapping.TypeDesc!.Type!, choiceMapping.Constants[i].Value); 2277throw new InvalidOperationException(SR.Format(SR.XmlChoiceMissingAnyValue, choiceMapping.TypeDesc!.FullName)); 2280throw new InvalidOperationException(SR.Format(SR.XmlChoiceMissingValue, choiceMapping.TypeDesc!.FullName, $"{element.Namespace}:{element.Name}", element.Name, element.Namespace));
System\Xml\Serialization\XmlTypeMapping.cs (2)
30return Mapping!.TypeDesc!.Name; 41return Mapping!.TypeDesc!.FullName;