Browse Source

Fix #1789: missing hyperlink for `MethodGroupResolveResult`.

null-coalescing-assignment
Daniel Grunwald 4 months ago
parent
commit
bd9ee28552
  1. 22
      ICSharpCode.Decompiler/CSharp/Annotations.cs
  2. 4
      ICSharpCode.Decompiler/CSharp/CallBuilder.cs
  3. 16
      ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs
  4. 8
      ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs
  5. 4
      ICSharpCode.Decompiler/Output/TextTokenWriter.cs
  6. 6
      ILSpy/Languages/CSharpHighlightingTokenWriter.cs

22
ICSharpCode.Decompiler/CSharp/Annotations.cs

@ -137,27 +137,9 @@ namespace ICSharpCode.Decompiler.CSharp @@ -137,27 +137,9 @@ namespace ICSharpCode.Decompiler.CSharp
public static ISymbol GetSymbol(this AstNode node)
{
var rr = node.Annotation<ResolveResult>();
if (rr is MethodGroupResolveResult)
if (rr is MethodGroupResolveResult mgrr)
{
// delegate construction?
var newObj = node.Annotation<NewObj>();
if (newObj != null)
{
var funcptr = newObj.Arguments.ElementAtOrDefault(1);
if (funcptr is LdFtn ldftn)
{
return ldftn.Method;
}
else if (funcptr is LdVirtFtn ldVirtFtn)
{
return ldVirtFtn.Method;
}
}
var ldVirtDelegate = node.Annotation<LdVirtDelegate>();
if (ldVirtDelegate != null)
{
return ldVirtDelegate.Method;
}
return mgrr.ChosenMethod;
}
return rr?.GetSymbol();
}

4
ICSharpCode.Decompiler/CSharp/CallBuilder.cs

@ -2025,6 +2025,10 @@ namespace ICSharpCode.Decompiler.CSharp @@ -2025,6 +2025,10 @@ namespace ICSharpCode.Decompiler.CSharp
}
break;
}
if (result is MethodGroupResolveResult mgrr)
{
result = mgrr.WithChosenMethod(method);
}
return (currentTarget, addTypeArguments, method.Name, result);
}
}

16
ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs

@ -20,6 +20,7 @@ using System; @@ -20,6 +20,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.NetworkInformation;
using ICSharpCode.Decompiler.Semantics;
using ICSharpCode.Decompiler.TypeSystem;
@ -81,6 +82,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -81,6 +82,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
readonly IReadOnlyList<IType> typeArguments;
readonly ResolveResult targetResult;
readonly string methodName;
IMethod chosenMethod;
public MethodGroupResolveResult(ResolveResult targetResult, string methodName,
IReadOnlyList<MethodListWithDeclaringType> methods, IReadOnlyList<IType> typeArguments)
@ -148,6 +150,20 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -148,6 +150,20 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
// the resolver is used to fetch extension methods on demand
internal CSharpResolver resolver;
/// <summary>
/// Gets the method that was chosen for this group.
///
/// Only set for MethodGroupResolveResults found in ILSpy AST annotations.
/// </summary>
public IMethod ChosenMethod => chosenMethod;
public MethodGroupResolveResult WithChosenMethod(IMethod method)
{
var result = (MethodGroupResolveResult)ShallowClone();
result.chosenMethod = method;
return result;
}
/// <summary>
/// Gets all candidate extension methods.
/// Note: this includes candidates that are not eligible due to an inapplicable

8
ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs

@ -131,17 +131,17 @@ namespace ICSharpCode.Decompiler.Documentation @@ -131,17 +131,17 @@ namespace ICSharpCode.Decompiler.Documentation
string localizedXmlDocFile = GetLocalizedName(xmlFileName, currentCulture.Name);
string localizedXmlDocFallbackFile = GetLocalizedName(xmlFileName, currentCulture.TwoLetterISOLanguageName);
Debug.WriteLine("Try find XMLDoc @" + localizedXmlDocFile);
//Debug.WriteLine("Try find XMLDoc @" + localizedXmlDocFile);
if (File.Exists(localizedXmlDocFile))
{
return localizedXmlDocFile;
}
Debug.WriteLine("Try find XMLDoc @" + localizedXmlDocFallbackFile);
//Debug.WriteLine("Try find XMLDoc @" + localizedXmlDocFallbackFile);
if (File.Exists(localizedXmlDocFallbackFile))
{
return localizedXmlDocFallbackFile;
}
Debug.WriteLine("Try find XMLDoc @" + xmlFileName);
//Debug.WriteLine("Try find XMLDoc @" + xmlFileName);
if (File.Exists(xmlFileName))
{
return xmlFileName;
@ -149,7 +149,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -149,7 +149,7 @@ namespace ICSharpCode.Decompiler.Documentation
if (currentCulture.TwoLetterISOLanguageName != "en")
{
string englishXmlDocFile = GetLocalizedName(xmlFileName, "en");
Debug.WriteLine("Try find XMLDoc @" + englishXmlDocFile);
//Debug.WriteLine("Try find XMLDoc @" + englishXmlDocFile);
if (File.Exists(englishXmlDocFile))
{
return englishXmlDocFile;

4
ICSharpCode.Decompiler/Output/TextTokenWriter.cs

@ -118,7 +118,9 @@ namespace ICSharpCode.Decompiler @@ -118,7 +118,9 @@ namespace ICSharpCode.Decompiler
}
if (symbol != null && node.Role == Roles.Type && node.Parent is ObjectCreateExpression)
{
symbol = node.Parent.GetSymbol();
var ctorSymbol = node.Parent.GetSymbol();
if (ctorSymbol != null)
symbol = ctorSymbol;
}
if (node is IdentifierExpression && node.Role == Roles.TargetExpression && node.Parent is InvocationExpression && symbol is IMember member)

6
ILSpy/Languages/CSharpHighlightingTokenWriter.cs

@ -500,9 +500,11 @@ namespace ICSharpCode.ILSpy @@ -500,9 +500,11 @@ namespace ICSharpCode.ILSpy
{
symbol = node.Parent.GetSymbol();
}
if (symbol != null && node.Parent is ObjectCreateExpression)
if (symbol != null && node.Role == Roles.Type && node.Parent is ObjectCreateExpression)
{
symbol = node.Parent.GetSymbol();
var ctorSymbol = node.Parent.GetSymbol();
if (ctorSymbol != null)
symbol = ctorSymbol;
}
if (node is IdentifierExpression && node.Role == Roles.TargetExpression && node.Parent is InvocationExpression && symbol is IMember member)
{

Loading…
Cancel
Save