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