提交 6f2f7852 编写于 作者: R Ravi Chande

Merge pull request #4184 from rchande/bugfix3346

Shared IntelliSense should treat fields and properties with the same …
......@@ -6914,40 +6914,6 @@ void Shared()
VerifyItemInLinkedFiles(markup, "Do", expectedDescription);
}
[WorkItem(1063403)]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public void WarningForSymbolsOfDifferingKind()
{
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
#if TWO
int Do;
#endif
void Shared()
{
$$
}
}
]]>
</Document>
</Project>
<Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"" PreprocessorSymbols=""TWO"">
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = $"void C.Do(int x) (+ 1 {FeaturesResources.Overload})\r\n\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}";
VerifyItemInLinkedFiles(markup, "Do", expectedDescription);
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public void MethodOverloadDifferencesIgnored_ExtensionMethod()
{
......@@ -7080,6 +7046,68 @@ public class Methods2
VerifyItemInLinkedFiles(markup, "Do", expectedDescription);
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public void SharedProjectFieldAndPropertiesTreatedAsIdentical()
{
var markup = @"<Workspace>
<Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""ONE"">
<Document FilePath=""CurrentDocument.cs""><![CDATA[
class C
{
#if ONE
public int x;
#endif
#if TWO
public int x {get; set;}
#endif
void foo()
{
x$$
}
}
]]>
</Document>
</Project>
<Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"" PreprocessorSymbols=""TWO"">
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = $"(field) int C.x";
VerifyItemInLinkedFiles(markup, "x", expectedDescription);
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public void SharedProjectFieldAndPropertiesTreatedAsIdentical2()
{
var markup = @"<Workspace>
<Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""ONE"">
<Document FilePath=""CurrentDocument.cs""><![CDATA[
class C
{
#if TWO
public int x;
#endif
#if ONE
public int x {get; set;}
#endif
void foo()
{
x$$
}
}
]]>
</Document>
</Project>
<Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"" PreprocessorSymbols=""TWO"">
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = "int C.x { get; set; }";
VerifyItemInLinkedFiles(markup, "x", expectedDescription);
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public void ConditionalAccessWalkUp()
{
......
......@@ -6536,5 +6536,58 @@ End Class
VerifyItemExists(text, "y")
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.Completion)>
Sub SharedProjectFieldAndPropertiesTreatedAsIdentical()
Dim markup = <Workspace>
<Project Language="Visual Basic" CommonReferences="True" AssemblyName="Proj1" PreprocessorSymbols="ONE=True">
<Document FilePath="CurrentDocument.vb"><![CDATA[
Class C
#if ONE Then
Public x As Integer
#endif
#if TWO Then
Public Property x as Integer
#endif
Sub foo()
x$$
End Sub
End Class]]>
</Document>
</Project>
<Project Language="Visual Basic" CommonReferences="True" AssemblyName="Proj2" PreprocessorSymbols="TWO=True">
<Document IsLinkFile="True" LinkAssemblyName="Proj1" LinkFilePath="CurrentDocument.vb"/>
</Project>
</Workspace>.ToString().NormalizeLineEndings()
Dim expectedDescription = $"(field) C.x As Integer"
VerifyItemInLinkedFiles(markup, "x", expectedDescription)
End Sub
<Fact(), Trait(Traits.Feature, Traits.Features.Completion)>
Public Sub SharedProjectFieldAndPropertiesTreatedAsIdentical2()
Dim markup = <Workspace>
<Project Language="Visual Basic" CommonReferences="True" AssemblyName="Proj1" PreprocessorSymbols="ONE=True">
<Document FilePath="CurrentDocument.vb"><![CDATA[
Class C
#if TWO Then
Public x As Integer
#endif
#if ONE Then
Public Property x as Integer
#endif
Sub foo()
x$$
End Sub
End Class]]>
</Document>
</Project>
<Project Language="Visual Basic" CommonReferences="True" AssemblyName="Proj2" PreprocessorSymbols="TWO=True">
<Document IsLinkFile="True" LinkAssemblyName="Proj1" LinkFilePath="CurrentDocument.vb"/>
</Project>
</Workspace>.ToString().NormalizeLineEndings()
Dim expectedDescription = $"Property C.x As Integer"
VerifyItemInLinkedFiles(markup, "x", expectedDescription)
End Sub
End Class
End Namespace
\ No newline at end of file
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Shared.Extensions;
......@@ -16,7 +17,7 @@ internal sealed class LinkedFilesSymbolEquivalenceComparer : IEqualityComparer<I
bool IEqualityComparer<ISymbol>.Equals(ISymbol x, ISymbol y)
{
return x.Kind == y.Kind && x.Name == y.Name;
return x.Name == y.Name;
}
int IEqualityComparer<ISymbol>.GetHashCode(ISymbol symbol)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册