未验证 提交 1afc0cf9 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #49824 from jnm2/debuggerdisplay_static_class

Stop offering to add DebuggerDisplay on static types 
......@@ -38,6 +38,23 @@ private string GetDebuggerDisplay()
}");
}
[Fact]
public async Task OfferedOnEmptyRecord()
{
await TestInRegularAndScriptAsync(@"
[||]record C;", @"
using System.Diagnostics;
[DebuggerDisplay(""{"" + nameof(GetDebuggerDisplay) + ""(),nq}"")]
record C
{
private string GetDebuggerDisplay()
{
return ToString();
}
}");
}
[Fact]
public async Task OfferedOnEmptyStruct()
{
......@@ -57,6 +74,15 @@ private string GetDebuggerDisplay()
}");
}
[Fact]
public async Task NotOfferedOnStaticClass()
{
await TestMissingInRegularAndScriptAsync(@"
[||]static class Foo
{
}");
}
[Fact]
public async Task NotOfferedOnInterfaceWithToString()
{
......
......@@ -46,6 +46,13 @@ Structure Foo
End Structure")
End Function
<Fact>
Public Async Function NotOfferedOnModule() As Task
Await TestMissingInRegularAndScriptAsync("
[||]Module Foo
End Module")
End Function
<Fact>
Public Async Function NotOfferedOnInterfaceWithToString() As Task
Await TestMissingInRegularAndScriptAsync("
......
......@@ -48,7 +48,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
var typeSymbol = (INamedTypeSymbol)semanticModel.GetRequiredDeclaredSymbol(type, context.CancellationToken);
if (!IsClassOrStruct(typeSymbol))
if (typeSymbol.IsStatic || !IsClassOrStruct(typeSymbol))
return;
if (HasDebuggerDisplayAttribute(typeSymbol, compilation))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册