未验证 提交 b32e4b75 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #30242 from...

Merge pull request #30242 from Scott-Caldwell/26947-Include-volatile-in-tool-tips-for-volatile-fields

Include static, readonly, and volatile in tool tips for fields
......@@ -1090,7 +1090,7 @@ public async Task TestMemberOfStructFromSource()
static class Test { int a = MyStruct.Some$$Field; }";
await TestAsync(markup,
MainDescription($"({FeaturesResources.field}) int MyStruct.SomeField"));
MainDescription($"({FeaturesResources.field}) static int MyStruct.SomeField"));
}
[WorkItem(538638, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538638")]
......@@ -1104,7 +1104,7 @@ public async Task TestMemberOfStructFromSourceWithDocComment()
static class Test { int a = MyStruct.Some$$Field; }";
await TestAsync(markup,
MainDescription($"({FeaturesResources.field}) int MyStruct.SomeField"),
MainDescription($"({FeaturesResources.field}) static int MyStruct.SomeField"),
Documentation("My Field"));
}
......@@ -1117,7 +1117,7 @@ public async Task TestMemberOfStructInsideMethodFromSource()
static class Test { static void Method() { int a = MyStruct.Some$$Field; } }";
await TestAsync(markup,
MainDescription($"({FeaturesResources.field}) int MyStruct.SomeField"));
MainDescription($"({FeaturesResources.field}) static int MyStruct.SomeField"));
}
[WorkItem(538638, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538638")]
......@@ -1131,7 +1131,7 @@ public async Task TestMemberOfStructInsideMethodFromSourceWithDocComment()
static class Test { static void Method() { int a = MyStruct.Some$$Field; } }";
await TestAsync(markup,
MainDescription($"({FeaturesResources.field}) int MyStruct.SomeField"),
MainDescription($"({FeaturesResources.field}) static int MyStruct.SomeField"),
Documentation("My Field"));
}
......@@ -1139,7 +1139,7 @@ static class Test { static void Method() { int a = MyStruct.Some$$Field; } }";
public async Task TestMetadataFieldMinimal()
{
await TestInMethodAsync(@"DateTime dt = DateTime.MaxValue$$",
MainDescription($"({FeaturesResources.field}) DateTime DateTime.MaxValue"));
MainDescription($"({FeaturesResources.field}) static readonly DateTime DateTime.MaxValue"));
}
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
......@@ -1154,7 +1154,7 @@ void M()
}
}";
await TestAsync(markup,
MainDescription($"({FeaturesResources.field}) System.DateTime System.DateTime.MaxValue"));
MainDescription($"({FeaturesResources.field}) static readonly System.DateTime System.DateTime.MaxValue"));
}
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
......@@ -1168,7 +1168,7 @@ void M()
DateTime dt = System.DateTime.MaxValue$$
}
}",
MainDescription($"({FeaturesResources.field}) System.DateTime System.DateTime.MaxValue"));
MainDescription($"({FeaturesResources.field}) static readonly System.DateTime System.DateTime.MaxValue"));
}
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
......@@ -1184,7 +1184,7 @@ void M()
DateTime dt = System.DateTime.MaxValue$$
}
}",
MainDescription($"({FeaturesResources.field}) DateTime DateTime.MaxValue"));
MainDescription($"({FeaturesResources.field}) static readonly DateTime DateTime.MaxValue"));
}
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
......
......@@ -145,6 +145,86 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
</Workspace>
Await TestCSharpAsync(workspace, "class System.String")
End Function
<Fact>
Public Async Function TestCSharpStaticField() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
class Foo
{
private static int $$x;
}
</Document>
</Project>
</Workspace>
Await TestCSharpAsync(workspace, $"({FeaturesResources.field}) static int Foo.x")
End Function
<Fact>
Public Async Function TestCSharpReadOnlyField() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
class Foo
{
private readonly int $$x;
}
</Document>
</Project>
</Workspace>
Await TestCSharpAsync(workspace, $"({FeaturesResources.field}) readonly int Foo.x")
End Function
<Fact>
Public Async Function TestCSharpVolatileField() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
class Foo
{
private volatile int $$x;
}
</Document>
</Project>
</Workspace>
Await TestCSharpAsync(workspace, $"({FeaturesResources.field}) volatile int Foo.x")
End Function
<Fact>
Public Async Function TestCSharpStaticReadOnlyField() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
class Foo
{
private static readonly int $$x;
}
</Document>
</Project>
</Workspace>
Await TestCSharpAsync(workspace, $"({FeaturesResources.field}) static readonly int Foo.x")
End Function
<Fact>
Public Async Function TestCSharpStaticVolatileField() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
class Foo
{
private static volatile int $$x;
}
</Document>
</Project>
</Workspace>
Await TestCSharpAsync(workspace, $"({FeaturesResources.field}) static volatile int Foo.x")
End Function
#End Region
......@@ -476,6 +556,60 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Await TestBasicAsync(workspace, $"({FeaturesResources.field}) Goo.field As Integer")
End Function
<Fact>
Public Async Function TestSharedField() As Task
Dim workspace =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Class Goo
private Shared field as Integer
sub Method()
fie$$ld = 5
End sub
End Class
</Document>
</Project>
</Workspace>
Await TestBasicAsync(workspace, $"({FeaturesResources.field}) Shared Goo.field As Integer")
End Function
<Fact>
Public Async Function TestReadOnlyField() As Task
Dim workspace =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Class Goo
private ReadOnly field as Integer
sub Method()
fie$$ld = 5
End sub
End Class
</Document>
</Project>
</Workspace>
Await TestBasicAsync(workspace, $"({FeaturesResources.field}) ReadOnly Goo.field As Integer")
End Function
<Fact>
Public Async Function TestSharedReadOnlyField() As Task
Dim workspace =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Class Goo
private Shared ReadOnly field as Integer
sub Method()
fie$$ld = 5
End sub
End Class
</Document>
</Project>
</Workspace>
Await TestBasicAsync(workspace, $"({FeaturesResources.field}) Shared ReadOnly Goo.field As Integer")
End Function
<Fact>
Public Async Function TestLocal() As Task
Dim workspace =
......
......@@ -9,6 +9,7 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;
......@@ -29,6 +30,9 @@ protected class SymbolDescriptionBuilder : AbstractSymbolDescriptionBuilder
.AddMemberOptions(SymbolDisplayMemberOptions.IncludeConstantValue)
.AddParameterOptions(SymbolDisplayParameterOptions.IncludeDefaultValue);
private static readonly SymbolDisplayFormat s_minimallyQualifiedFormatWithConstantsAndModifiers = s_minimallyQualifiedFormatWithConstants
.AddMemberOptions(SymbolDisplayMemberOptions.IncludeModifiers);
public SymbolDescriptionBuilder(
ISymbolDisplayService displayService,
SemanticModel semanticModel,
......@@ -200,6 +204,8 @@ protected override void AddCaptures(ISymbol symbol)
protected override SymbolDisplayFormat MinimallyQualifiedFormat => s_minimallyQualifiedFormat;
protected override SymbolDisplayFormat MinimallyQualifiedFormatWithConstants => s_minimallyQualifiedFormatWithConstants;
protected override SymbolDisplayFormat MinimallyQualifiedFormatWithConstantsAndModifiers => s_minimallyQualifiedFormatWithConstantsAndModifiers;
}
}
}
......@@ -107,6 +107,7 @@ protected abstract partial class AbstractSymbolDescriptionBuilder
protected abstract SymbolDisplayFormat MinimallyQualifiedFormat { get; }
protected abstract SymbolDisplayFormat MinimallyQualifiedFormatWithConstants { get; }
protected abstract SymbolDisplayFormat MinimallyQualifiedFormatWithConstantsAndModifiers { get; }
protected void AddPrefixTextForAwaitKeyword()
{
......@@ -488,7 +489,7 @@ private async Task<ImmutableArray<SymbolDisplayPart>> GetFieldPartsAsync(IFieldS
}
}
return ToMinimalDisplayParts(symbol, MinimallyQualifiedFormatWithConstants);
return ToMinimalDisplayParts(symbol, MinimallyQualifiedFormatWithConstantsAndModifiers);
}
private async Task AddDescriptionForLocalAsync(ILocalSymbol symbol)
......
......@@ -4,6 +4,7 @@ Imports System.Collections.Immutable
Imports System.Threading
Imports Microsoft.CodeAnalysis.Classification
Imports Microsoft.CodeAnalysis.LanguageServices
Imports Microsoft.CodeAnalysis.PooledObjects
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
......@@ -21,6 +22,9 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.LanguageServices
.AddMemberOptions(SymbolDisplayMemberOptions.IncludeConstantValue) _
.AddParameterOptions(SymbolDisplayParameterOptions.IncludeDefaultValue)
Private Shared ReadOnly s_minimallyQualifiedFormatWithConstantsAndModifiers As SymbolDisplayFormat = s_minimallyQualifiedFormatWithConstants _
.AddMemberOptions(SymbolDisplayMemberOptions.IncludeModifiers)
Public Sub New(displayService As ISymbolDisplayService,
semanticModel As SemanticModel,
position As Integer,
......@@ -170,6 +174,12 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.LanguageServices
Return s_minimallyQualifiedFormatWithConstants
End Get
End Property
Protected Overrides ReadOnly Property MinimallyQualifiedFormatWithConstantsAndModifiers As SymbolDisplayFormat
Get
Return s_minimallyQualifiedFormatWithConstantsAndModifiers
End Get
End Property
End Class
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册