From 18f9d5d2c3aef5961a6e90eb570e1c6bf808d4ff Mon Sep 17 00:00:00 2001 From: nosami Date: Sun, 23 Oct 2022 18:51:40 +0100 Subject: More Generics evaluation fixes --- .../NRefactoryExpressionEvaluatorVisitor.cs | 41 +++++++++++++++------- .../NRefactoryExpressionResolverVisitor.cs | 11 +++++- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluatorVisitor.cs b/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluatorVisitor.cs index fdb3ba1..e0387b1 100644 --- a/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluatorVisitor.cs +++ b/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluatorVisitor.cs @@ -1292,18 +1292,19 @@ namespace Mono.Debugging.Evaluation public override ValueReference VisitGenericName (GenericNameSyntax node) { - object[] typeArgs = new object[node.TypeArgumentList.Arguments.Count]; + object [] typeArgs = new object [node.TypeArgumentList.Arguments.Count]; for (var i = 0; i < node.TypeArgumentList.Arguments.Count; i++) { - var typeArg = Visit(node.TypeArgumentList.Arguments[i]); - typeArgs[i] = typeArg.Type; + var typeArg = Visit (node.TypeArgumentList.Arguments [i]); + typeArgs [i] = typeArg.Type; } - string typeName = node.Identifier.ValueText; + string typeName = node.Identifier.ValueText; - var d = ctx.Adapter.GetDisplayTypeName(typeName); - var type1 = ctx.Adapter.GetType(ctx, typeName, typeArgs); - return new TypeValueReference(ctx, type1); + typeName = MakeGenericTypeName (node, typeName); + + var type1 = ctx.Adapter.GetType (ctx, typeName, typeArgs); + return new TypeValueReference (ctx, type1); //node. //object[] typeArgs; @@ -1331,14 +1332,28 @@ namespace Mono.Debugging.Evaluation //return LiteralValueReference.CreateTargetObjectLiteral(ctx, expression, ctx.Adapter.CreateValue(ctx, type.Type, args.ToArray())); } - //public override ValueReference VisitQualifiedName (QualifiedNameSyntax node) - //{ - // return Visit(node.Right); - //} + + private static string MakeGenericTypeName (GenericNameSyntax node, string typeName) + { + if (node.Parent is QualifiedNameSyntax qns && qns.Left is IdentifierNameSyntax ins) + return $"{ins.Identifier.Value}.{typeName}`{node.TypeArgumentList.Arguments.Count}"; + + if (node.Parent is QualifiedNameSyntax qns2 && qns2.Left is QualifiedNameSyntax left) + return $"{left}.{typeName}`{node.TypeArgumentList.Arguments.Count}"; + return typeName; + } + + public override ValueReference VisitQualifiedName(QualifiedNameSyntax node) + { + if(node.Right is GenericNameSyntax) { + return Visit(node.Right); + } + var type1 = ctx.Adapter.GetType(ctx, node.ToString()); + return new TypeValueReference(ctx, type1); + } + public override ValueReference DefaultVisit (SyntaxNode node) { - if(node is GenericNameSyntax gns) - Console.WriteLine("o"); if (node is LiteralExpressionSyntax syntax) { return LiteralValueReference.CreateObjectLiteral(ctx, expression, syntax.Token.Value); diff --git a/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionResolverVisitor.cs b/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionResolverVisitor.cs index 98d4a58..db83347 100644 --- a/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionResolverVisitor.cs +++ b/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionResolverVisitor.cs @@ -107,7 +107,7 @@ namespace Mono.Debugging.Evaluation if (memberType) { type = type.Substring (type.LastIndexOf ('.') + 1); } else { - type = "global::" + type; + //type = "global::" + type; } parentType = type + GenerateGenericArgs (genericArgs); @@ -142,5 +142,14 @@ namespace Mono.Debugging.Evaluation { ReplaceType (node); } + + public override void VisitGenericName(GenericNameSyntax node) + { + var loc = node.Identifier.GetLocation(); + int length = loc.SourceSpan.Length; + int offset = loc.SourceSpan.Start; + + ReplaceType(node.Identifier.Text, node.TypeArgumentList.Arguments.Count, offset, length); + } } } \ No newline at end of file -- cgit v1.2.3