private DumpTypeRef(DumpTypeRef other, GenericTypeMap genericTypes) { Namespace = other.Namespace; Name = other.Name; IsGenericInstance = true; IsGenericTemplate = false; var newGenerics = new List <TypeRef>(other.Generics.Count); foreach (var genericParameter in other.Generics) { if (genericParameter.IsGeneric) { newGenerics.Add(genericParameter.MakeGenericInstance(genericTypes)); } else if (genericTypes.TryGetValue(genericParameter, out var genericArgument)) { newGenerics.Add(genericArgument); } else { throw new UnresolvedTypeException(genericParameter, other); } } Generics = newGenerics; OriginalDeclaringType = other.DeclaringType; UnNested = other.UnNested; ElementType = other.ElementType; }
private DumpTypeRef(DumpTypeRef other, string?nameOverride = null) { Namespace = other.Namespace; Name = nameOverride ?? other.Name; IsGenericInstance = other.IsGenericInstance; IsGenericTemplate = other.IsGenericTemplate; Generics = new List <TypeRef>(other.Generics); DeclaringType = other.DeclaringType; ElementType = other.ElementType; }
internal DumpTypeRef(string @namespace, string typeName) { Namespace = @namespace; var GenericTypes = new List <TypeRef>(); if (typeName.EndsWith(">") && !typeName.StartsWith("<")) { var ind = typeName.IndexOf("<"); var types = typeName.Substring(ind + 1, typeName.Length - ind - 2); var spl = types.Split(new string[] { ", " }, StringSplitOptions.None); for (int i = 0; i < spl.Length;) { string s = spl[i]; int unclosed = s.Count(c => c == '<'); unclosed -= s.Count(c => c == '>'); i++; while (unclosed > 0) { unclosed += spl[i].Count(c => c == '<'); unclosed -= spl[i].Count(c => c == '>'); s += ", " + spl[i]; i++; } // TODO: if this DumpTypeRef is the This for a DumpTypeData, mark these IsGenericParameter. "out" is not in dump.cs. GenericTypes.Add(new DumpTypeRef(s)); } } Generics = GenericTypes; // TODO: check that this gives correct results if (string.IsNullOrEmpty(@namespace)) { IsGenericInstance = true; } else { IsGenericTemplate = true; } var declInd = typeName.LastIndexOf('.'); if (declInd != -1) { // Create a new TypeRef for the declaring type, it should recursively create more declaring types OriginalDeclaringType = new DumpTypeRef(typeName.Substring(0, declInd)); // TODO: need to resolve DeclaringType before this will make sense? Namespace = OriginalDeclaringType.Namespace; } Name = typeName.Replace('.', '/'); if (IsArray()) { ElementType = new DumpTypeRef(Name[0..^ 2]);
internal DumpProperty(TypeRef declaring, PeekableStreamReader fs) { DeclaringType = declaring; var line = fs.PeekLine()?.Trim(); while (line != null && line.StartsWith("[")) { Attributes.Add(new DumpAttribute(fs)); line = fs.PeekLine()?.Trim(); } line = fs.ReadLine()?.Trim() ?? ""; var split = line.Split(' '); if (split.Length < 5) { throw new InvalidOperationException($"Line {fs.CurrentLineIndex}: Property cannot be created from: \"{line.Trim()}\""); } // Start at the end (but before the }), count back until we hit a { (or we have gone 3 steps) // Keep track of how far back we count int i; for (i = 0; i < 3; i++) { var val = split[split.Length - 2 - i]; if (val == "{") { break; } else if (val == "get;") { GetMethod = true; } else if (val == "set;") { SetMethod = true; } } Name = split[split.Length - 3 - i]; Type = new DumpTypeRef(DumpTypeRef.FromMultiple(split, split.Length - 4 - i, out int adjust, -1, " ")); for (int j = 0; j < adjust; j++) { Specifiers.Add(new DumpSpecifier(split[j])); } }