Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WriteSourceEnd() [2/2]

void System.Xml.Serialization.XmlSerializationReaderILGen.WriteSourceEnd ( string source,
Type elementType,
Type stackType )
inlineprivate

Definition at line 2311 of file XmlSerializationReaderILGen.cs.

2312 {
2314 {
2316 if (CodeGenerator.IsNullableGenericType(variableType))
2317 {
2318 ilg.Call(variableType.GetConstructor(variableType.GetGenericArguments()));
2319 return;
2320 }
2324 return;
2325 }
2326 if (source.StartsWith("o.@", StringComparison.Ordinal))
2327 {
2328 MemberInfo memberInfo = memberInfos[source.Substring(3)];
2331 return;
2332 }
2333 Regex regex = XmlSerializationILGen.NewRegex("(?<locA1>[^ ]+) = .+EnsureArrayIndex[(](?<locA2>[^,]+), (?<locI1>[^,]+),[^;]+;(?<locA3>[^[]+)[[](?<locI2>[^+]+)[+][+][]]");
2334 Match match = regex.Match(source);
2335 if (match.Success)
2336 {
2337 object variable2 = ilg.GetVariable(match.Groups["locA1"].Value);
2340 if (CodeGenerator.IsNullableGenericType(elementType2) || elementType2.IsValueType)
2341 {
2343 }
2344 else
2345 {
2347 }
2348 }
2349 else if (source.EndsWith(".Add(", StringComparison.Ordinal))
2350 {
2351 int length = source.LastIndexOf(".Add(", StringComparison.Ordinal);
2352 LocalBuilder local = ilg.GetLocal(source.Substring(0, length));
2353 MethodInfo method = local.LocalType.GetMethod("Add", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, new Type[1] { elementType });
2354 Type parameterType = method.GetParameters()[0].ParameterType;
2356 ilg.Call(method);
2357 if (method.ReturnType != typeof(void))
2358 {
2359 ilg.Pop();
2360 }
2361 }
2362 else
2363 {
2364 regex = XmlSerializationILGen.NewRegex("(?<a>[^[]+)[[](?<ia>.+)[]]");
2365 match = regex.Match(source);
2366 if (!match.Success)
2367 {
2368 throw Globals.NotSupported("Unexpected: " + source);
2369 }
2371 Type elementType3 = variableType2.GetElementType();
2374 }
2375 }
Type? GetElementType()
void Stelem(Type arrayElementType)
void ConvertValue(Type source, Type target)
void StoreMember(MemberInfo memberInfo)
void Call(MethodInfo methodInfo)
void Stloc(Type type, string name)
LocalBuilder GetLocal(string name)
bool TryGetVariable(string name, [NotNullWhen(true)] out object variable)
XmlSerializationILGen(TypeScope[] scopes, string access, string className)

References System.Xml.Serialization.CodeGenerator.Call(), System.Xml.Serialization.CodeGenerator.ConvertValue(), System.elementType, System.Type.GetElementType(), System.Xml.Serialization.CodeGenerator.GetLocal(), System.Xml.Serialization.CodeGenerator.GetVariable(), System.Xml.Serialization.CodeGenerator.GetVariableType(), System.Xml.Serialization.XmlSerializationILGen.ilg, System.Xml.Serialization.CodeGenerator.IsNullableGenericType(), System.length, System.match, System.Xml.Serialization.XmlSerializationILGen.memberInfos, System.Xml.Serialization.XmlSerializationILGen.NewRegex(), System.Xml.Serialization.CodeGenerator.Pop(), System.source, System.Xml.Serialization.CodeGenerator.Stelem(), System.Xml.Serialization.CodeGenerator.Stloc(), System.Xml.Serialization.CodeGenerator.Stobj(), System.Xml.Serialization.CodeGenerator.StoreMember(), and System.Xml.Serialization.CodeGenerator.TryGetVariable().