Skip to content

Commit 86aebea

Browse files
Allow for resolving the method perfectly
1 parent 7af4bf4 commit 86aebea

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

ICSharpCode.CodeConverter/CSharp/CompilationErrorFixer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ private SyntaxNode FixOutParameters(ArgumentListSyntax argumentListSyntax)
7070
return argumentListSyntax;
7171
}
7272

73-
var methodSymbol = _semanticModel.GetSymbolInfo(invocationExpression).CandidateSymbols.OfType<IMethodSymbol>()
74-
.FirstOrDefault(s => argumentListSyntax.Arguments.Count == s.Parameters.Length);
75-
if (methodSymbol != null)
73+
if (_semanticModel.GetSymbolInfo(invocationExpression)
74+
.ExtractBestMatch(s => s is IMethodSymbol ims && argumentListSyntax.Arguments.Count == ims.Parameters.Length) is IMethodSymbol methodSymbol)
7675
{
7776
//Won't work for named parameters
7877
for (var index = 0;

ICSharpCode.CodeConverter/Util/ISymbolExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,15 @@ public static ISymbol GetContainingMemberOrThis(this ISymbol symbol)
170170
}
171171
}
172172

173-
public static ISymbol ExtractBestMatch(this SymbolInfo info)
173+
public static ISymbol ExtractBestMatch(this SymbolInfo info, Func<ISymbol, bool> isMatch = null)
174174
{
175+
isMatch = isMatch ?? (_ => true);
175176
if (info.Symbol == null && info.CandidateSymbols.Length == 0)
176177
return null;
177178
if (info.Symbol != null)
178179
return info.Symbol;
179180
if (info.CandidateSymbols.Length == 1)
180-
return info.CandidateSymbols[0];
181+
return info.CandidateSymbols.FirstOrDefault(isMatch);
181182
return null;
182183
}
183184

0 commit comments

Comments
 (0)