提交 9383851c 编写于 作者: R Ravi Chande

Group members by kind and name

Only show the warning icon if there's no member/type with the same kind
and name available.
上级 685e9f24
......@@ -6948,6 +6948,99 @@ void Shared()
VerifyItemInLinkedFiles(markup, "Do", expectedDescription);
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public void MethodOverloadDifferencesIgnored_ExtensionMethod()
{
var markup = @"<Workspace>
<Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""ONE"">
<Document FilePath=""CurrentDocument.cs""><![CDATA[
class C
{
#if ONE
void Do(int x){}
#endif
void Shared()
{
this.$$
}
}
public static class Extensions
{
#if TWO
public static void Do (this C c, string x)
{
}
#endif
}
]]>
</Document>
</Project>
<Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"" PreprocessorSymbols=""TWO"">
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = $"(extension) void C.Do(string x)";
VerifyItemInLinkedFiles(markup, "Do", expectedDescription);
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public void MethodOverloadDifferencesIgnored_ContainingType()
{
var markup = @"<Workspace>
<Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""ONE"">
<Document FilePath=""CurrentDocument.cs""><![CDATA[
class C
{
void Shared()
{
var x = GetThing();
x.$$
}
#if ONE
private Methods1 GetThing()
{
return new Methods1();
}
#endif
#if TWO
private Methods2 GetThing()
{
return new Methods2();
}
#endif
}
#if ONE
public class Methods1
{
public void Do(string x) { }
}
#endif
#if TWO
public class Methods2
{
public void Do(string x) { }
}
#endif
]]>
</Document>
</Project>
<Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"" PreprocessorSymbols=""TWO"">
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = $"void Methods2.Do(string x)";
VerifyItemInLinkedFiles(markup, "Do", expectedDescription);
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public void ConditionalAccessWalkUp()
{
......
......@@ -243,7 +243,7 @@ private HashSet<ISymbol> UnionSymbols(List<Tuple<DocumentId, AbstractSyntaxConte
{
// We need to use the SemanticModel any particular symbol came from in order to generate its description correctly.
// Therefore, when we add a symbol to set of union symbols, add a mapping from it to its SyntaxContext.
foreach (var symbol in linkedContextSymbolList.Item3.GroupBy(s => new { s.ContainingType, s.Name, s.Kind }).Select(g => g.First()))
foreach (var symbol in linkedContextSymbolList.Item3.GroupBy(s => new { s.Name, s.Kind }).Select(g => g.First()))
{
if (set.Add(symbol))
{
......
......@@ -28,16 +28,12 @@ public LinkedFilesSymbolEquivalenceComparer(SymbolEquivalenceComparer symbolEqui
bool IEqualityComparer<ISymbol>.Equals(ISymbol x, ISymbol y)
{
return x.Kind == y.Kind && (x.IsKind(SymbolKind.Local) || x.IsKind(SymbolKind.Label) || x.IsKind(SymbolKind.RangeVariable))
? x.Name == y.Name
: x.Name == y.Name && x.Kind == y.Kind && _symbolEquivalenceComparer.Equals(x.ContainingType, y.ContainingType);
return x.Kind == y.Kind && x.Name == y.Name;
}
int IEqualityComparer<ISymbol>.GetHashCode(ISymbol symbol)
{
return symbol.IsKind(SymbolKind.Local) || symbol.IsKind(SymbolKind.Label) || symbol.IsKind(SymbolKind.RangeVariable)
? symbol.Name.GetHashCode()
: _symbolEquivalenceComparer.GetHashCode(symbol.ContainingType);
return symbol.Name.GetHashCode();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册