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; 1101mapping.TypeDesc = model.TypeDesc; 1171mapping.TypeDesc = TypeScope.GetMatchingTypeDesc(dataType, XmlSchema.Namespace, modelTypeDesc.FullName); 1175mapping.TypeDesc = TypeScope.GetTypeDesc(dataType, UrtTypes.Namespace); 1184mapping.TypeDesc = model.TypeDesc; 1208mapping.TypeDesc = model.TypeDesc; 1256members.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;
700 references to TypeDesc
System.Private.Xml (700)
System\Xml\Serialization\Compilation.cs (1)
500VerifyLoadContext(mapping.Accessor.Mapping?.TypeDesc?.Type, contextAssembly);
System\Xml\Serialization\Mappings.cs (15)
631if (BaseMapping == null || BaseMapping.TypeDesc!.IsRoot) 640throw new InvalidOperationException(SR.Format(SR.XmlIllegalSimpleContentExtension, TypeDesc!.FullName, BaseMapping.TypeDesc.FullName)); 651if (!_hasSimpleContent && text != null && !text.Mapping!.TypeDesc!.CanBeTextValue && !(BaseMapping != null && !BaseMapping.TypeDesc!.IsRoot && (text.Mapping.TypeDesc.IsEnum || text.Mapping.TypeDesc.IsPrimitive))) 653throw new InvalidOperationException(SR.Format(SR.XmlIllegalTypedTextAttribute, TypeDesc!.FullName, text.Name, text.Mapping.TypeDesc.FullName)); 674if (TypeDesc!.IsRoot) 680while (start.BaseMapping != null && !start.BaseMapping.IsSequence && !start.BaseMapping.TypeDesc!.IsRoot) 692get { return _isSequence && !TypeDesc!.IsRoot; } 770int w1 = a1.Mapping!.TypeDesc!.Weight; 771int w2 = a2.Mapping!.TypeDesc!.Weight; 1122throw new InvalidOperationException(SR.Format(SR.XmlCircularDerivation, TypeDesc!.FullName));
System\Xml\Serialization\ReflectionXmlSerializationReader.cs (65)
47!mapping.TypeDesc!.IsRoot) 52mapping.TypeDesc.Type!, 463memberMapping.TypeDesc = mapping.TypeDesc; 695if (special.TypeDesc!.Kind == TypeKind.Node) 708string stringValue = text.Mapping!.TypeDesc!.CollapseWhitespace 729if (text.Mapping!.TypeDesc == StringTypeDesc || text.Mapping.TypeDesc!.FormatterName == "String") 731value = ReadString(null, text.Mapping.TypeDesc.CollapseWhitespace); 806TypeDesc td = nullableMapping.BaseMapping!.TypeDesc!; 811elementType = ele.Mapping!.TypeDesc!.Type!; 916if (element.Mapping.TypeDesc!.IsValueType) 918value = ReflectionCreateObject(element.Mapping.TypeDesc.Type!); 929if ((element.Default != null && element.Default != DBNull.Value && element.Mapping.TypeDesc!.IsValueType) 934else if (element.Mapping.TypeDesc!.Type == typeof(TimeSpan) && Reader.IsEmptyElement) 939else if (element.Mapping.TypeDesc!.Type == typeof(DateTimeOffset) && Reader.IsEmptyElement) 944else if (element.Mapping.TypeDesc!.Type == typeof(DateOnly) && Reader.IsEmptyElement) 949else if (element.Mapping.TypeDesc!.Type == typeof(TimeOnly) && Reader.IsEmptyElement) 956if (element.Mapping.TypeDesc == QnameTypeDesc) 962if (element.Mapping.TypeDesc.FormatterName == "ByteArrayBase64") 966else if (element.Mapping.TypeDesc.FormatterName == "ByteArrayHex") 988if (!mapping.TypeDesc!.IsValueType || rre != null) 1015isNullable: mapping.TypeDesc!.IsNullable && element.IsNullable, 1024switch (specialMapping.TypeDesc!.Kind) 1027bool isDoc = specialMapping.TypeDesc.FullName == typeof(XmlDocument).FullName; 1048value = ReadSerializable((IXmlSerializable)ReflectionCreateObject(sm.TypeDesc!.Type!)!, isWrappedAny); 1069value = ReadSerializable((IXmlSerializable)ReflectionCreateObject(sm.TypeDesc!.Type!)!, isWrappedAny); 1115value = ReadSerializable((IXmlSerializable)ReflectionCreateObject(derived.TypeDesc!.Type!)!, isWrappedAny); 1133object? WriteStruct() => WriteStructMethod(structMapping, mapping.TypeDesc!.IsNullable, true, defaultNamespace: null); 1183return mapping.TypeDesc!.CanBeElementValue; 1201TypeDesc td = arrayMapping.TypeDesc!; 1235TypeDesc = arrayMapping.TypeDesc, 1279else if (mapping.TypeDesc == StringTypeDesc) 1283else if (mapping.TypeDesc!.FormatterName == "String") 1285if (mapping.TypeDesc.CollapseWhitespace) 1296if (!mapping.TypeDesc.HasCustomFormatter) 1299object retObj = mapping.TypeDesc.FormatterName switch 1317_ => throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorDetails, $"unknown FormatterName: {mapping.TypeDesc.FormatterName}")), 1323string methodName = $"To{mapping.TypeDesc.FormatterName}"; 1327throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorDetails, $"unknown FormatterName: {mapping.TypeDesc.FormatterName}")); 1345object? o = Activator.CreateInstance(nullableMapping.TypeDesc!.Type!); 1351element.IsNullable = nullableMapping.BaseMapping!.TypeDesc!.IsNullable; 1377return Enum.ToObject(mapping.TypeDesc!.Type!, ToEnum(source, table, mapping.TypeDesc.Name)); 1385return Enum.Parse(mapping.TypeDesc!.Type!, c.Name); 1389throw CreateUnknownConstantException(source, mapping.TypeDesc!.Type!); 1437if (structMapping.TypeDesc!.IsRoot) 1442if (structMapping.TypeDesc.IsAbstract) 1448object? o = ReflectionCreateObject(structMapping.TypeDesc.Type!); 1620if (structMapping.TypeDesc!.IsRoot && isNull) 1628if (structMapping.TypeDesc.IsValueType) 1630return ReflectionCreateObject(structMapping.TypeDesc.Type!); 1640if (xsiType == null || (!structMapping.TypeDesc.IsRoot && QNameEqual(xsiType, structMapping.TypeName, defaultNamespace))) 1642if (structMapping.TypeDesc.IsRoot) 1651else if (structMapping.TypeDesc.IsRoot && WriteEnumAndArrayTypes(out o, xsiType, defaultNamespace)) 1657if (structMapping.TypeDesc.IsRoot) 1664if (structMapping.TypeDesc!.IsNullable && isNull) 1668else if (structMapping.TypeDesc.IsAbstract) 1674if (structMapping.TypeDesc.Type != null && typeof(XmlSchemaObject).IsAssignableFrom(structMapping.TypeDesc.Type)) 1679object? o = ReflectionCreateObject(structMapping.TypeDesc.Type!)!; 1734throw new InvalidOperationException(SR.Format(SR.XmlSequenceHierarchy, structMapping.TypeDesc.FullName, mapping.Name, declaringMapping!.TypeDesc!.FullName, "Order")); 1859object choiceValue = Enum.Parse(choice.Mapping!.TypeDesc!.Type!, memberIds[elementIndex]); 2103if (special.TypeDesc!.Kind == TypeKind.Attribute) 2107else if (special.TypeDesc.CanBeAttributeValue)
System\Xml\Serialization\ReflectionXmlSerializationWriter.cs (42)
48!mapping.TypeDesc!.IsRoot) 51mapping.TypeDesc.Type!, 54CreateXmlSerializationWriteCallback(mapping, mapping.TypeName!, mapping.Namespace, mapping.TypeDesc.IsNullable) 106if (!mapping.TypeDesc!.IsValueType && !mapping.TypeDesc.Type!.IsPrimitive) 111WriteMember(o, null, new ElementAccessor[] { element }, null, null, mapping.TypeDesc, !element.IsSoap); 147throw CreateInvalidChoiceIdentifierValueException(choice.Mapping!.TypeDesc!.FullName, choice.MemberName!); 229Type? elementType = mapping.TypeDesc!.Type; 257return mapping.TypeDesc.FormatterName switch 292WritePrimitiveMethodRequirement suffixRaw = mapping.TypeDesc!.XmlEncodingNotRequired ? WritePrimitiveMethodRequirement.Raw : WritePrimitiveMethodRequirement.None; 297bool hasDefault = mapping.TypeDesc.HasDefaultSupport && element.Default is T; 384TypeDesc td = element.Mapping!.TypeDesc!; 385bool enumUseReflection = choice.Mapping!.TypeDesc!.UseReflection; 386string enumTypeName = choice.Mapping!.TypeDesc!.FullName; 408TypeDesc td = element.IsUnbounded ? element.Mapping!.TypeDesc!.CreateArrayTypeDesc() : element.Mapping!.TypeDesc!; 432throw CreateChoiceIdentifierValueException(choice.Mapping!.TypeDesc!.FullName, choice.MemberName!, elem.Name, elem.NamespaceURI); 500throw new InvalidOperationException(SR.Format(SR.XmlChoiceMissingAnyValue, choiceMapping.TypeDesc!.FullName)); 503throw new InvalidOperationException(SR.Format(SR.XmlChoiceMissingValue, choiceMapping.TypeDesc!.FullName, element.Namespace + ":" + element.Name, element.Name, element.Namespace)); 521if (!WritePrimitiveValue(primitiveMapping.TypeDesc!, o, out stringValue)) 538switch (specialMapping.TypeDesc!.Kind) 583WritePotentiallyReferencingElement(name, ns, o, mapping.TypeDesc!.Type, true, element.IsNullable); 626if (mapping!.TypeDesc == ReflectionXmlSerializationReader.QnameTypeDesc) 644WritePrimitiveMethodRequirement suffixRaw = mapping.TypeDesc!.XmlEncodingNotRequired ? WritePrimitiveMethodRequirement.Raw : WritePrimitiveMethodRequirement.None; 656WritePotentiallyReferencingElement(name, ns, o, !writeAccessor ? mapping.TypeDesc!.Type : null, !writeAccessor, element.IsNullable); 712bool hasDefault = defaultValue != null && defaultValue != DBNull.Value && mapping.TypeDesc!.HasDefaultSupport; 742if (mapping.IsSoap && mapping.TypeDesc!.IsRoot) return; 753&& o.GetType() != mapping.TypeDesc!.Type) 760if (mapping.TypeDesc.IsRoot) 775if (!mapping.TypeDesc!.IsAbstract) 777if (mapping.TypeDesc.Type != null && typeof(XmlSchemaObject).IsAssignableFrom(mapping.TypeDesc.Type)) 795if (!mapping.TypeDesc.IsRoot) 895if (m is EnumMapping em && em.TypeDesc!.Type == objType) 904if (m is ArrayMapping am && am.TypeDesc!.Type == objType) 908WriteMember(o, null, am.ElementsSortedByDerivation!, null, null, am.TypeDesc!, true); 955throw CreateInvalidEnumValueException(v, mapping.TypeDesc!.FullName); 1106if (special.TypeDesc!.Kind == TypeKind.Attribute || special.TypeDesc.CanBeAttributeValue) 1140if (t == derived.TypeDesc!.Type) 1157TypeDesc typeDesc = mapping.TypeDesc!; 1158bool 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)
798if (typeMapping.TypeDesc == typeDesc) 1215if (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)); 878if (!member.Text.Mapping!.TypeDesc!.CanBeTextValue && member.Text.Mapping.IsList) 879throw new InvalidOperationException(SR.Format(SR.XmlIllegalTypedTextAttribute, typeName, member.Text.Name, member.Text.Mapping.TypeDesc.FullName)); 1050name = itemTypeMapping.TypeDesc!.DataType!.Name; 1052else if (itemTypeMapping is StructMapping && itemTypeMapping.TypeDesc!.IsRoot) 1126if (existingMapping.TypeDesc == model.TypeDesc) 1172if (mapping.TypeDesc == null) 1176if (mapping.TypeDesc == null) 1186mapping.TypeName = mapping.TypeDesc.DataType!.Name; 1187mapping.Namespace = mapping.TypeDesc.IsXsdType ? XmlSchema.Namespace : UrtTypes.Namespace; 1189CheckContext(mapping.TypeDesc, context); 1847if (element.Mapping.TypeDesc!.Kind == TypeKind.Node) 2047throw new InvalidOperationException(SR.Format(SR.XmlChoiceMissingAnyValue, accessor.ChoiceIdentifier.Mapping!.TypeDesc!.FullName)); 2053throw new InvalidOperationException(SR.Format(SR.XmlChoiceMissingValue, accessor.ChoiceIdentifier.Mapping!.TypeDesc!.FullName, id, element.Name, element.Namespace)); 2289bool 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; 439type.IsMixed = mapping.TypeDesc.IsMixed; 572if (mapping.TypeDesc!.IsXsdType) 574qname = new XmlQualifiedName(mapping.TypeDesc.DataType!.Name, XmlSchema.Namespace); 724if (!accessor.HasDefault && !valueTypeOptional && accessor.Mapping!.TypeDesc!.IsValueType) 811int minOccurs = repeats || accessor.HasDefault || (!accessor.IsNullable && !accessor.Mapping!.TypeDesc!.IsValueType) || valueTypeOptional ? 0 : 1; 889return val != 0 ? XmlCustomFormatter.FromEnum(val, names, ids, mapping.TypeDesc!.FullName) : null; 906if (!pm.TypeDesc!.HasCustomFormatter) 910if (pm.TypeDesc.Type == null) 912throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorDetails, "Mapping for " + pm.TypeDesc.Name + " missing type property")); 916if (pm.TypeDesc.FormatterName == "String") 920System.Reflection.MethodInfo? format = formatter.GetMethod("ToString", new Type[] { pm.TypeDesc.Type! }); 926string defaultValue = XmlCustomFormatter.FromDefaultValue(value, pm.TypeDesc.FormatterName!); 928throw new InvalidOperationException(SR.Format(SR.XmlInvalidDefaultValue, value, pm.TypeDesc.Name)); 931throw new InvalidOperationException(SR.Format(SR.XmlInvalidDefaultValue, value, pm.TypeDesc.Name)); 940if (mapping is StructMapping && mapping.TypeDesc!.IsRoot) 957if (mapping.TypeDesc!.IsRoot) 965throw new InvalidOperationException(SR.Format(SR.XmlCircularReference2, mapping.TypeDesc.Name, "AnonymousType", "false")); 971if (!mapping.IncludeInSchema) throw new InvalidOperationException(SR.Format(SR.XmlCannotIncludeInSchema, mapping.TypeDesc.Name)); 980type.IsAbstract = mapping.TypeDesc.IsAbstract; 986throw new InvalidOperationException(SR.Format(SR.XmlAnonymousBaseType, mapping.TypeDesc.Name, mapping.BaseMapping.TypeDesc!.Name, "AnonymousType", "false")); 1091throw new InvalidOperationException(SR.Format(SR.XmlAnonymousBaseType, textMapping.TypeDesc!.Name, pm.TypeDesc!.Name, "AnonymousType", "false")); 1138if (!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 (128)
2182bool choiceUseReflection = mapping.ChoiceIdentifier.Mapping!.TypeDesc!.UseReflection; 2183string choiceTypeFullName = mapping.ChoiceIdentifier.Mapping.TypeDesc.CSharpName; 2187_choiceArraySource = init + outerClass.RaCodeGen.GetStringForArrayMember(a, $"{c}++", mapping.ChoiceIdentifier.Mapping.TypeDesc); 2296MethodNames.Add(mapping, NextMethodName(mapping.TypeDesc!.Name)); 2455!mapping.TypeDesc!.IsRoot) 2471Writer.Write(RaCodeGen.GetStringForTypeof(mapping.TypeDesc.CSharpName, mapping.TypeDesc.UseReflection)); 2861member.TypeDesc = mapping.TypeDesc; 2890if (enumMethodName == null) throw new InvalidOperationException(SR.Format(SR.XmlMissingMethodEnum, mapping.TypeDesc!.Name)); 2895Writer.Write(mapping.TypeDesc!.CSharpName); 2903else if (mapping.TypeDesc == StringTypeDesc) 2907else if (mapping.TypeDesc!.FormatterName == "String") 2909if (mapping.TypeDesc.CollapseWhitespace) 2922if (!mapping.TypeDesc.HasCustomFormatter) 2928Writer.Write(mapping.TypeDesc.FormatterName); 2999if (!mapping.TypeDesc!.UseReflection) 3002Writer.Write(mapping.TypeDesc.CSharpName); 3039tableName = WriteHashtable(mapping, mapping.TypeDesc!.Name); 3043bool useReflection = mapping.TypeDesc!.UseReflection; 3044string fullTypeName = mapping.TypeDesc.CSharpName; 3134if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, derived.TypeDesc!.Name)); 3138if (derived.TypeDesc!.UseReflection && isTypedReturn) 3142if (derived.TypeDesc.IsNullable) 3171if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, enumMapping.TypeDesc!.Name)); 3183if (arrayMapping.TypeDesc!.HasDefaultConstructor) 3190memberMapping.TypeDesc = arrayMapping.TypeDesc; 3194TypeDesc td = arrayMapping.TypeDesc; 3195string fullTypeName = arrayMapping.TypeDesc.CSharpName; 3206if (arrayMapping.TypeDesc.IsValueType) 3227bool useReflection = nullableMapping.BaseMapping!.TypeDesc!.UseReflection; 3228string typeName = useReflection ? "object" : nullableMapping.TypeDesc!.CSharpName; 3261element.IsNullable = nullableMapping.BaseMapping.TypeDesc.IsNullable; 3281bool useReflection = structMapping.TypeDesc!.UseReflection; 3282string typeName = useReflection ? "object" : structMapping.TypeDesc.CSharpName; 3288if (structMapping.TypeDesc.IsNullable) 3296if (structMapping.TypeDesc.IsNullable) 3300if (structMapping.TypeDesc.IsRoot) 3307if (structMapping.TypeDesc.IsValueType) 3309Writer.Write(RaCodeGen.GetStringForCreateInstance(structMapping.TypeDesc.CSharpName, useReflection, false, false)); 3319if (!structMapping.TypeDesc.IsRoot) 3325if (structMapping.TypeDesc.IsRoot) 3334WriteDerivedTypes(structMapping, !useReflection && !structMapping.TypeDesc.IsRoot, typeName); 3335if (structMapping.TypeDesc.IsRoot) WriteEnumAndArrayTypes(); 3336if (structMapping.TypeDesc.IsRoot) 3344if (structMapping.TypeDesc.IsRoot) 3347if (structMapping.TypeDesc.IsNullable) 3350if (structMapping.TypeDesc.IsAbstract) 3360if (structMapping.TypeDesc.Type != null && typeof(XmlSchemaObject).IsAssignableFrom(structMapping.TypeDesc.Type)) 3381string source = RaCodeGen.GetStringForMember("o", mapping.Name, structMapping.TypeDesc); 3382Member member = new Member(this, source, "a", i, mapping, GetChoiceIdentifierSource(mapping, "o", structMapping.TypeDesc)); 3387member.CheckSpecifiedSource = RaCodeGen.GetStringForMember("o", $"{mapping.Name}Specified", structMapping.TypeDesc); 3408throw new InvalidOperationException(SR.Format(SR.XmlSequenceHierarchy, structMapping.TypeDesc.FullName, mapping.Name, declaringMapping!.TypeDesc!.FullName, "Order")); 3412Member arrayMember = new Member(this, source, source, "a", i, mapping, GetChoiceIdentifierSource(mapping, "o", structMapping.TypeDesc)); 3485if (structMapping.TypeDesc!.IsRoot) 3500if (structMapping.TypeDesc.IsAbstract) 3521string source = RaCodeGen.GetStringForMember("o", mapping.Name, structMapping.TypeDesc); 3522Member member = new Member(this, source, source, "a", i, mapping, GetChoiceIdentifierSource(mapping, "o", structMapping.TypeDesc)); 3524member.CheckSpecifiedSource = RaCodeGen.GetStringForMember("o", $"{mapping.Name}Specified", structMapping.TypeDesc); 3556if (anyFixups) WriteFixupMethod(fixupMethodName, members, structMapping.TypeDesc.CSharpName, structMapping.TypeDesc.UseReflection, true, "o"); 3863if (special.TypeDesc!.Kind == TypeKind.Attribute) 3870else if (special.TypeDesc.CanBeAttributeValue) 3992WriteArrayLocalDecl($"{member.Mapping.ChoiceIdentifier.Mapping!.TypeDesc!.CSharpName}[]", 3994member.Mapping.ChoiceIdentifier.Mapping.TypeDesc); 4149WriteSourceBeginTyped(member.ArraySource, special.TypeDesc); 4150switch (special.TypeDesc!.Kind) 4173Writer.WriteLine(text.Mapping!.TypeDesc!.CollapseWhitespace ? "CollapseWhitespace(Reader.ReadString());" : "Reader.ReadString();"); 4189if (text.Mapping!.TypeDesc!.CollapseWhitespace) 4200if (text.Mapping!.TypeDesc == StringTypeDesc || text.Mapping.TypeDesc!.FormatterName == "String") 4203if (text.Mapping.TypeDesc!.CollapseWhitespace) 4343TypeDesc td = ((NullableMapping)e.Mapping).BaseMapping!.TypeDesc!; 4348Writer.Write(RaCodeGen.GetStringForTypeof(e.Mapping!.TypeDesc!.CSharpName, e.Mapping.TypeDesc.UseReflection)); 4373if (e.Mapping!.TypeDesc!.IsValueType || e.Mapping is NullableMapping) 4383TypeDesc td = ((NullableMapping)e.Mapping).BaseMapping!.TypeDesc!; 4384Writer.Write(RaCodeGen.GetStringForCreateInstance(e.Mapping.TypeDesc.CSharpName, e.Mapping.TypeDesc.UseReflection, false, true, $"({td.CSharpName}){checkTypeSource}")); 4388WriteSourceBeginTyped(member.ArraySource, e.Mapping.TypeDesc); 4393if (e.Mapping.TypeDesc.IsValueType) 4555bool choiceUseReflection = member.Mapping.ChoiceIdentifier.Mapping!.TypeDesc!.UseReflection; 4556string choiceTypeName = member.Mapping.ChoiceIdentifier.Mapping.TypeDesc.CSharpName; 4653TypeDesc td = arrayMapping.TypeDesc!; 4666WriteSourceBeginTyped(source, arrayMapping.TypeDesc); 4670WriteCatchCastException(arrayMapping.TypeDesc!, "rre", null); 4681memberMapping.TypeDesc = arrayMapping.TypeDesc; 4754if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, element.Mapping.TypeDesc!.Name)); 4769if (element.Mapping.TypeDesc!.IsValueType) 4771Writer.Write(RaCodeGen.GetStringForCreateInstance(element.Mapping.TypeDesc.CSharpName, element.Mapping.TypeDesc.UseReflection, false, false)); 4789if (element.Default != null && element.Default != DBNull.Value && element.Mapping.TypeDesc!.IsValueType) 4804if (element.Mapping.TypeDesc!.Type == typeof(TimeSpan) || element.Mapping.TypeDesc!.Type == typeof(DateTimeOffset) 4805|| element.Mapping.TypeDesc!.Type == typeof(DateOnly) || element.Mapping.TypeDesc!.Type == typeof(TimeOnly)) 4811if (element.Mapping.TypeDesc!.Type == typeof(TimeSpan)) 4815else if (element.Mapping.TypeDesc!.Type == typeof(DateTimeOffset)) 4819else if (element.Mapping.TypeDesc!.Type == typeof(DateOnly)) 4823else if (element.Mapping.TypeDesc!.Type == typeof(TimeOnly)) 4843if (element.Mapping.TypeDesc == QnameTypeDesc) 4848switch (element.Mapping.TypeDesc.FormatterName) 4894if (mapping.TypeDesc!.IsValueType) 4902WriteSourceBeginTyped(source, mapping.TypeDesc); 4906WriteCatchCastException(mapping.TypeDesc, "rre", null); 4910if (mapping.TypeDesc.IsValueType) 4921if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, mapping.TypeDesc!.Name)); 4933if (mapping.TypeDesc!.IsNullable) 4946switch (special.TypeDesc!.Kind) 4949bool isDoc = special.TypeDesc.FullName == typeof(XmlDocument).FullName; 4950WriteSourceBeginTyped(source, special.TypeDesc); 4971WriteSourceBeginTyped(source, sm.TypeDesc); 4975if (sm.TypeDesc!.CSharpName == "global::System.Xml.Linq.XElement") 4977Writer.Write(RaCodeGen.GetStringForCreateInstance(sm.TypeDesc!.CSharpName, false, false, false, "\"default\"")); 4981Writer.Write(RaCodeGen.GetStringForCreateInstance(sm.TypeDesc!.CSharpName, sm.TypeDesc.UseReflection, sm.TypeDesc.CannotNew, false)); 5014string enumTypeName = choice.Mapping!.TypeDesc!.CSharpName; 5018Writer.Write(RaCodeGen.GetStringForEnumMember(enumTypeName, choice.MemberIds[elementIndex], choice.Mapping.TypeDesc.UseReflection)); 5040WriteSourceBeginTyped(source, head.TypeDesc); 5044Writer.Write(RaCodeGen.GetStringForCreateInstance(derived.TypeDesc!.CSharpName, derived.TypeDesc.UseReflection, derived.TypeDesc.CannotNew, false)); 5192string fullTypeName = mapping.TypeDesc!.CSharpName; 5193bool useReflection = mapping.TypeDesc.UseReflection; 5194bool ctorInaccessible = mapping.TypeDesc.CannotNew; 5208Writer.Write(RaCodeGen.GetStringForCreateInstance(fullTypeName, useReflection, mapping.TypeDesc.CannotNew, true));
System\Xml\Serialization\XmlSerializationReaderILGen.cs (120)
101string choiceTypeFullName = mapping.ChoiceIdentifier.Mapping!.TypeDesc!.CSharpName; 206MethodNames.Add(mapping, NextMethodName(mapping.TypeDesc!.Name)); 720member.TypeDesc = mapping.TypeDesc; 761if (enumMethodName == null) throw new InvalidOperationException(SR.Format(SR.XmlMissingMethodEnum, mapping.TypeDesc!.Name)); 767mapping.TypeDesc!.Type, 819else if (mapping.TypeDesc == StringTypeDesc) 864else if (mapping.TypeDesc!.FormatterName == "String") 869if (mapping.TypeDesc.CollapseWhitespace) 874if (mapping.TypeDesc.CollapseWhitespace) 898if (mapping.TypeDesc.CollapseWhitespace) 903if (mapping.TypeDesc.CollapseWhitespace) 918if (mapping.TypeDesc.HasCustomFormatter) 922if ((mapping.TypeDesc.FormatterName == "ByteArrayBase64" && source == "false") 923|| (mapping.TypeDesc.FormatterName == "ByteArrayHex" && source == "false") 924|| (mapping.TypeDesc.FormatterName == "XmlQualifiedName")) 931$"To{mapping.TypeDesc.FormatterName}", 939$"To{mapping.TypeDesc.FormatterName}", 1069ilg.Ldc(Enum.ToObject(mapping.TypeDesc!.Type!, constants[i].Value)); 1070ilg.ConvertValue(mapping.TypeDesc.Type!, typeof(long)); 1095WriteHashtable(mapping, mapping.TypeDesc!.Name, out get_TableName); 1099string fullTypeName = mapping.TypeDesc!.CSharpName; 1105returnType = mapping.TypeDesc.Type!; 1172retValues.Add(Enum.ToObject(mapping.TypeDesc.Type!, c.Value)); 1195ilg.Ldc(mapping.TypeDesc.Type!); 1218if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, derived.TypeDesc!.Name)); 1223if (derived.TypeDesc!.IsNullable) 1234derived.TypeDesc.Type, 1273if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, enumMapping.TypeDesc!.Name)); 1279enumMapping.TypeDesc!.Type, 1315if (arrayMapping.TypeDesc!.HasDefaultConstructor) 1322memberMapping.TypeDesc = arrayMapping.TypeDesc; 1328TypeDesc td = arrayMapping.TypeDesc; 1329LocalBuilder aLoc = ilg.DeclareLocal(arrayMapping.TypeDesc.Type!, aVar); 1330if (arrayMapping.TypeDesc.IsValueType) 1356nullableMapping.TypeDesc!.Type!, 1362LocalBuilder oLoc = ilg.DeclareLocal(nullableMapping.TypeDesc.Type!, "o"); 1365ilg.InitObj(nullableMapping.TypeDesc.Type!); 1383element.IsNullable = nullableMapping.BaseMapping!.TypeDesc!.IsNullable; 1404string typeName = structMapping.TypeDesc!.CSharpName; 1408if (structMapping.TypeDesc.IsNullable) 1416structMapping.TypeDesc.Type!, 1447if (structMapping.TypeDesc.IsNullable) 1461if (structMapping.TypeDesc.IsRoot) 1479if (structMapping.TypeDesc.IsValueType) 1496if (!structMapping.TypeDesc.IsRoot) 1510if (structMapping.TypeDesc.IsRoot) 1529WriteDerivedTypes(structMapping, !structMapping.TypeDesc.IsRoot, typeName); 1530if (structMapping.TypeDesc.IsRoot) WriteEnumAndArrayTypes(); 1532if (structMapping.TypeDesc.IsRoot) 1560if (structMapping.TypeDesc.IsNullable) 1572if (structMapping.TypeDesc.IsAbstract) 1587if (structMapping.TypeDesc.Type != null && typeof(XmlSchemaObject).IsAssignableFrom(structMapping.TypeDesc.Type)) 1644throw new InvalidOperationException(SR.Format(SR.XmlSequenceHierarchy, structMapping.TypeDesc.FullName, mapping.Name, declaringMapping!.TypeDesc!.FullName, "Order")); 1762ilg.Ldloc(structMapping.TypeDesc.Type!, "o"); 2113if (special.TypeDesc!.Kind == TypeKind.Attribute) 2119else if (special.TypeDesc.CanBeAttributeValue) 2220WriteArrayLocalDecl($"{member.Mapping.ChoiceIdentifier.Mapping!.TypeDesc!.CSharpName}[]", 2222member.Mapping.ChoiceIdentifier.Mapping.TypeDesc); 2397switch (special.TypeDesc!.Kind) 2430WriteSourceEnd(member.ArraySource, special.TypeDesc.Type!); 2468WriteSourceEnd(member.ArraySource, text.Mapping!.TypeDesc!.Type!); 2476if (text.Mapping!.TypeDesc!.CollapseWhitespace) 2496if (text.Mapping.TypeDesc.CollapseWhitespace) 2508if (text.Mapping!.TypeDesc == StringTypeDesc || text.Mapping.TypeDesc!.FormatterName == "String") 2518ilg.Ldc(text.Mapping.TypeDesc!.CollapseWhitespace); 2531WriteSourceEnd(member.ArraySource, text.Mapping.TypeDesc.Type!); 2775ilg.Ldc(member.Mapping.ChoiceIdentifier.Mapping!.TypeDesc!.Type!); 2778ilg.ConvertValue(XmlSerializationReader_ShrinkArray.ReturnType, member.Mapping.ChoiceIdentifier.Mapping.TypeDesc.Type!.MakeArrayType()); 2779WriteSourceEnd(member.ChoiceSource!, member.Mapping.ChoiceIdentifier.Mapping.TypeDesc.Type!.MakeArrayType()); 3067memberMapping.TypeDesc = arrayMapping.TypeDesc; 3185if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, element.Mapping.TypeDesc!.Name)); 3194element.Mapping.TypeDesc!.Type, 3198WriteSourceEnd(source, element.Mapping.TypeDesc.Type!); 3214if (element.Mapping.TypeDesc!.IsValueType) 3222WriteSourceEnd(source, element.Mapping.TypeDesc.Type!); 3230if (element.Default != null && element.Default != DBNull.Value && element.Mapping.TypeDesc!.IsValueType) 3261if ((element.Mapping.TypeDesc!.Type == typeof(TimeSpan)) || element.Mapping.TypeDesc!.Type == typeof(DateTimeOffset) 3262|| element.Mapping.TypeDesc!.Type == typeof(DateOnly) || element.Mapping.TypeDesc!.Type == typeof(TimeOnly)) 3287LocalBuilder tmpLoc = ilg.GetTempLocal(element.Mapping.TypeDesc!.Type); 3289ilg.InitObj(element.Mapping.TypeDesc!.Type); 3291WriteSourceEnd(source, element.Mapping.TypeDesc.Type); 3295WriteSourceEnd(source, element.Mapping.TypeDesc.Type); 3301if (element.Mapping.TypeDesc == QnameTypeDesc) 3314switch (element.Mapping.TypeDesc.FormatterName) 3327WriteSourceEnd(source, element.Mapping.TypeDesc.Type!); 3339if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, mapping.TypeDesc!.Name)); 3365if (mapping.TypeDesc!.IsNullable) 3375mapping.TypeDesc.Type, 3379WriteSourceEnd(source, mapping.TypeDesc.Type!); 3386switch (special.TypeDesc!.Kind) 3389bool isDoc = special.TypeDesc.FullName == typeof(XmlDocument).FullName; 3400if (special.TypeDesc != null) 3401ilg.Castclass(special.TypeDesc.Type!); 3402WriteSourceEnd(source, special.TypeDesc!.Type!); 3440ReflectionAwareILGen.ILGenForCreateInstance(ilg, sm.TypeDesc!.Type!, sm.TypeDesc.CannotNew, false); 3441if (sm.TypeDesc.CannotNew) 3443else if (sm.TypeDesc.IsValueType) 3444ilg.ConvertValue(sm.TypeDesc.Type!, typeof(IXmlSerializable)); 3449if (sm.TypeDesc != null) 3450ilg.ConvertValue(typeof(IXmlSerializable), sm.TypeDesc.Type!); 3451WriteSourceEnd(source, sm.TypeDesc!.Type!); 3475ReflectionAwareILGen.ILGenForEnumMember(ilg, choice.Mapping!.TypeDesc!.Type!, choice.MemberIds[elementIndex]); 3476WriteSourceEnd(choiceSource!, choice.Mapping.TypeDesc.Type!); 3513ReflectionAwareILGen.ILGenForCreateInstance(ilg, derived.TypeDesc!.Type!, derived.TypeDesc.CannotNew, false); 3514if (derived.TypeDesc.CannotNew) 3520if (head.TypeDesc != null) 3521ilg.ConvertValue(typeof(IXmlSerializable), head.TypeDesc.Type!); 3522WriteSourceEnd(source, head.TypeDesc!.Type!); 3643string fullTypeName = mapping.TypeDesc!.CSharpName; 3644bool ctorInaccessible = mapping.TypeDesc.CannotNew; 3647mapping.TypeDesc.Type!, 3654ReflectionAwareILGen.ILGenForCreateInstance(ilg, mapping.TypeDesc.Type!, mapping.TypeDesc.CannotNew, true);
System\Xml\Serialization\XmlSerializationWriter.cs (118)
1743string typeFullName = mapping.TypeDesc!.CSharpName; 1953return $"{mapping.TypeDesc!.CSharpName}.@{memberName}"; 1955string memberAccess = GetStringForEnumMember(mapping.TypeDesc!.CSharpName, memberName, useReflection); 2311MethodNames.Add(mapping, NextMethodName(mapping.TypeDesc!.Name)); 2387!typeMapping.TypeDesc!.IsRoot) 2391Writer.Write(RaCodeGen.GetStringForTypeof(typeMapping.TypeDesc.CSharpName, typeMapping.TypeDesc.UseReflection)); 2455if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, mapping.TypeDesc!.Name) + Environment.StackTrace); 2495TypeDesc typeDesc = mapping.TypeDesc!; 2496bool hasDefault = defaultValue != null && defaultValue != DBNull.Value && mapping.TypeDesc!.HasDefaultSupport; 2507if (mapping.TypeDesc!.UseReflection) 2508Writer.Write(ReflectionAwareCodeGen.GetStringForEnumLongValue(source, mapping.TypeDesc.UseReflection)); 2522Writer.Write(RaCodeGen.GetStringForEnumCompare((EnumMapping)mapping, values[i], mapping.TypeDesc.UseReflection)); 2528Writer.Write(RaCodeGen.GetStringForEnumCompare((EnumMapping)mapping, (string)defaultValue!, mapping.TypeDesc.UseReflection)); 2796if (member.ChoiceIdentifier.Mapping!.TypeDesc!.UseReflection) 2887if (!mapping.IsSoap && !mapping.TypeDesc!.IsValueType && !mapping.TypeDesc.Type!.IsPrimitive) 2892WriteMember("o", null, new ElementAccessor[] { element }, null, null, mapping.TypeDesc!, !element.IsSoap); 2912string fullTypeName = mapping.TypeDesc!.CSharpName; 2918WriteLocalDecl(fullTypeName, "v", "e", mapping.TypeDesc.UseReflection); 2925Writer.Write(mapping.TypeDesc.UseReflection ? "object" : fullTypeName); 2935if (mapping.TypeDesc.UseReflection) 2936Writer.WriteLine($"switch ({ReflectionAwareCodeGen.GetStringForEnumLongValue("v", mapping.TypeDesc.UseReflection)} ){{"); 2945WriteEnumCase(fullTypeName, c, mapping.TypeDesc.UseReflection); 2957Writer.Write(ReflectionAwareCodeGen.GetStringForEnumLongValue("v", mapping.TypeDesc.UseReflection)); 2977if (mapping.TypeDesc.UseReflection) 2989WriteQuotedCSharpString(mapping.TypeDesc.FullName); 2995Writer.Write(ReflectionAwareCodeGen.GetStringForEnumLongValue("v", mapping.TypeDesc.UseReflection)); 2997WriteQuotedCSharpString(mapping.TypeDesc.FullName); 3024string fullTypeName = derived.TypeDesc!.CSharpName; 3026WriteTypeCompare("t", fullTypeName, derived.TypeDesc.UseReflection); 3034if (methodName == null) throw new InvalidOperationException("derived from " + mapping.TypeDesc!.FullName + ", " + SR.Format(SR.XmlInternalErrorMethod, derived.TypeDesc.Name) + Environment.StackTrace); 3039if (!derived.TypeDesc.UseReflection) Writer.Write($"({fullTypeName})"); 3041if (derived.TypeDesc.IsNullable) 3063string fullTypeName = mapping.TypeDesc!.CSharpName; 3065WriteTypeCompare("t", fullTypeName, mapping.TypeDesc.UseReflection); 3073if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, mapping.TypeDesc.Name) + Environment.StackTrace); 3084if (!mapping.TypeDesc.UseReflection) Writer.Write($"({fullTypeName})"); 3095string fullTypeName = mapping.TypeDesc!.CSharpName; 3097if (mapping.TypeDesc.IsArray) 3098WriteArrayTypeCompare("t", fullTypeName, mapping.TypeDesc.ArrayElementTypeDesc!.CSharpName, mapping.TypeDesc.UseReflection); 3100WriteTypeCompare("t", fullTypeName, mapping.TypeDesc.UseReflection); 3111WriteMember("o", null, mapping.ElementsSortedByDerivation!, null, null, mapping.TypeDesc, true); 3125if (mapping.IsSoap && mapping.TypeDesc!.IsRoot) return; 3132string fullTypeName = mapping.TypeDesc!.CSharpName; 3138WriteLocalDecl(fullTypeName, "o", "s", mapping.TypeDesc.UseReflection); 3143Writer.Write(mapping.TypeDesc.UseReflection ? "object" : fullTypeName); 3145if (mapping.TypeDesc.IsNullable) 3149if (mapping.TypeDesc.IsNullable) 3164WriteTypeCompare("t", fullTypeName, mapping.TypeDesc.UseReflection); 3170if (mapping.TypeDesc.IsRoot) 3173if (mapping.TypeDesc.IsRoot) 3188if (!mapping.TypeDesc.IsAbstract) 3190if (mapping.TypeDesc.Type != null && typeof(XmlSchemaObject).IsAssignableFrom(mapping.TypeDesc.Type)) 3202xmlnsSource = RaCodeGen.GetStringForMember("o", member.Name, mapping.TypeDesc); 3203if (mapping.TypeDesc.UseReflection) 3218if (!mapping.TypeDesc.IsRoot) 3240string methodInvoke = RaCodeGen.GetStringForMethodInvoke("o", fullTypeName, $"ShouldSerialize{m.Name}", mapping.TypeDesc.UseReflection); 3241if (mapping.TypeDesc.UseReflection) methodInvoke = $"(({typeof(bool).FullName}){methodInvoke})"; 3249string memberGet = RaCodeGen.GetStringForMember("o", $"{m.Name}Specified", mapping.TypeDesc); 3250if (mapping.TypeDesc.UseReflection) memberGet = $"(({typeof(bool).FullName}){memberGet})"; 3255WriteMember(RaCodeGen.GetStringForMember("o", m.Name, mapping.TypeDesc), m.Attribute, m.TypeDesc!, "o"); 3281string methodInvoke = RaCodeGen.GetStringForMethodInvoke("o", fullTypeName, $"ShouldSerialize{m.Name}", mapping.TypeDesc.UseReflection); 3282if (mapping.TypeDesc.UseReflection) methodInvoke = $"(({typeof(bool).FullName}){methodInvoke})"; 3290string memberGet = RaCodeGen.GetStringForMember("o", $"{m.Name}Specified", mapping.TypeDesc); 3291if (mapping.TypeDesc.UseReflection) memberGet = $"(({typeof(bool).FullName}){memberGet})"; 3301choiceSource = RaCodeGen.GetStringForMember("o", m.ChoiceIdentifier.MemberName, mapping.TypeDesc); 3303WriteMember(RaCodeGen.GetStringForMember("o", m.Name, mapping.TypeDesc), choiceSource, m.ElementsSortedByDerivation!, m.Text, m.ChoiceIdentifier, m.TypeDesc!, true); 3511if (special.TypeDesc!.Kind == TypeKind.Attribute || special.TypeDesc.CanBeAttributeValue) 3524TypeDesc typeDesc = attribute.Mapping!.TypeDesc!; 3556string choiceFullName = choice.Mapping!.TypeDesc!.CSharpName; 3557WriteArrayLocalDecl($"{choiceFullName}[]", "c", choiceSource, choice.Mapping.TypeDesc); 3562WriteQuotedCSharpString(choice.Mapping.TypeDesc.FullName); 3682string choiceFullName = choice.Mapping!.TypeDesc!.CSharpName; 3683WriteLocalDecl(choiceFullName, $"{choiceName}i", RaCodeGen.GetStringForArrayMember(choiceName!, $"i{arrayName}", choice.Mapping.TypeDesc), choice.Mapping.TypeDesc.UseReflection); 3712TypeDesc td = elements[0].IsUnbounded ? elements[0].Mapping!.TypeDesc!.CreateArrayTypeDesc() : elements[0].Mapping!.TypeDesc!; 3713if (!elements[0].Any && !elements[0].Mapping!.TypeDesc!.UseReflection && !elements[0].Mapping!.TypeDesc!.IsOptionalValue) 3731string? enumTypeName = choice == null ? null : choice.Mapping!.TypeDesc!.FullName; 3751bool useReflection = element.Mapping!.TypeDesc!.UseReflection; 3752string fullTypeName = element.Mapping.TypeDesc.CSharpName; 3753bool enumUseReflection = choice.Mapping!.TypeDesc!.UseReflection; 3771WriteChoiceTypeCheck(source, fullTypeName, useReflection, choice, enumFullName, element.Mapping.TypeDesc); 3782bool useReflection = element.Mapping!.TypeDesc!.UseReflection; 3783TypeDesc td = element.IsUnbounded ? element.Mapping.TypeDesc.CreateArrayTypeDesc() : element.Mapping.TypeDesc; 3829bool enumUseReflection = choice.Mapping!.TypeDesc!.UseReflection; 3895bool useReflection = text.Mapping!.TypeDesc!.UseReflection; 3896string fullTypeName = text.Mapping.TypeDesc.CSharpName; 3956WritePrimitiveValue(primitive.TypeDesc!, source); 3962switch (simple.TypeDesc!.Kind) 3985string fullTypeName = element.Mapping.TypeDesc!.BaseTypeDesc!.CSharpName; 3987if (!element.Mapping.TypeDesc.BaseTypeDesc.UseReflection) 4016Writer.Write(RaCodeGen.GetStringForTypeof(arrayMapping.TypeDesc!.CSharpName, arrayMapping.TypeDesc.UseReflection)); 4028TypeDesc td = arrayMapping.TypeDesc!.CreateArrayTypeDesc(); 4034WriteArrayLocalDecl(fullTypeName, elementArrayName, source, arrayMapping.TypeDesc); 4041if (arrayMapping.TypeDesc.IsNullable) 4089string fullTypeName = arrayMapping.TypeDesc!.CSharpName; 4092WriteArrayLocalDecl(fullTypeName, arrayName, source, arrayMapping.TypeDesc); 4099if (arrayMapping.TypeDesc.IsNullable) 4109WriteArrayItems(arrayMapping.ElementsSortedByDerivation!, null, null, arrayMapping.TypeDesc, arrayName, null); 4140if (primitiveMapping.TypeDesc == QnameTypeDesc) 4145string suffixRaw = primitiveMapping.TypeDesc!.XmlEncodingNotRequired ? "Raw" : ""; 4163Writer.Write(RaCodeGen.GetStringForTypeof(structMapping.TypeDesc!.CSharpName, structMapping.TypeDesc.UseReflection)); 4178if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, structMapping.TypeDesc!.Name) + Environment.StackTrace); 4192if (structMapping.TypeDesc!.IsNullable) 4281Type? type = Type.GetType(mapping.TypeDesc!.Type!.FullName!); 4289Type? type = Type.GetType(mapping.TypeDesc!.Type!.FullName!); 4571throw new InvalidOperationException(SR.Format(SR.XmlChoiceMissingAnyValue, choiceMapping.TypeDesc!.FullName)); 4574throw 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)); 1573WriteLocalDecl($"{choiceName}i", ReflectionAwareILGen.GetStringForArrayMember(choiceName, iPlusArrayName), choice.Mapping!.TypeDesc!.Type!); 1612TypeDesc td = elements[0].IsUnbounded ? elements[0].Mapping!.TypeDesc!.CreateArrayTypeDesc() : elements[0].Mapping!.TypeDesc!; 1613if (!elements[0].Any && !elements[0].Mapping!.TypeDesc!.IsOptionalValue) 1631string? enumTypeName = choice == null ? null : choice.Mapping!.TypeDesc!.FullName; 1656ILGenLoad(enumSource!, choice == null ? null : choice.Mapping!.TypeDesc!.Type); 1674WriteChoiceTypeCheck(source, choice!, enumFullName, element.Mapping!.TypeDesc!); 1676SourceInfo castedSource = source.CastTo(element.Mapping.TypeDesc!); 1681TypeDesc td = element.IsUnbounded ? element.Mapping!.TypeDesc!.CreateArrayTypeDesc() : element.Mapping!.TypeDesc!; 1733ILGenLoad(enumSource!, choice == null ? null : choice.Mapping!.TypeDesc!.Type); 1850WriteInstanceOf(source, text.Mapping!.TypeDesc!.Type!); 1852SourceInfo castedSource = source.CastTo(text.Mapping.TypeDesc); 1857SourceInfo castedSource = source.CastTo(text.Mapping!.TypeDesc!); 1904WritePrimitiveValue(primitiveMapping.TypeDesc!, source, out argType); 1915switch (specialMapping.TypeDesc!.Kind) 1945if (source.Type == element.Mapping.TypeDesc!.Type) 1947MethodInfo Nullable_get_HasValue = element.Mapping.TypeDesc.Type!.GetMethod( 1952source.LoadAddress(element.Mapping.TypeDesc.Type); 1962SourceInfo castedSource = source.CastTo(element.Mapping.TypeDesc.BaseTypeDesc!); 1982string fullTypeName = arrayMapping.TypeDesc!.CSharpName; 1983WriteArrayLocalDecl(fullTypeName, arrayName, source, arrayMapping.TypeDesc); 1990if (arrayMapping.TypeDesc.IsNullable) 1998WriteArrayItems(arrayMapping.ElementsSortedByDerivation!, null, null, arrayMapping.TypeDesc, arrayName, null); 2006if (arrayMapping.TypeDesc.IsNullable) 2020if (primitiveMapping.TypeDesc == QnameTypeDesc) 2026string suffixRaw = primitiveMapping.TypeDesc!.XmlEncodingNotRequired ? "Raw" : ""; 2037if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, structMapping.TypeDesc!.Name)); 2045source.Load(structMapping.TypeDesc!.Type); 2046argTypes.Add(structMapping.TypeDesc.Type!); 2047if (structMapping.TypeDesc.IsNullable) 2296eValue = Enum.ToObject(choiceMapping.TypeDesc!.Type!, choiceMapping.Constants[i].Value); 2310eValue = Enum.ToObject(choiceMapping.TypeDesc!.Type!, choiceMapping.Constants[i].Value); 2320throw new InvalidOperationException(SR.Format(SR.XmlChoiceMissingAnyValue, choiceMapping.TypeDesc!.FullName)); 2323throw 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;