Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2220,4 +2220,21 @@ public void Test(string s)

await TestMissingInRegularAndScriptAsync(code);
}

[Fact]
public async Task TestNotOnNamedType1()
{
await TestMissingInRegularAndScriptAsync(
"""
using System;

class C
{
void M()
{
[||]Console.WriteLine();
}
}
""");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9568,4 +9568,32 @@ class C
parseOptions: null,
index: 1);
}

[Fact]
public async Task TestNotOnNamedType1()
{
await TestMissingInRegularAndScriptAsync(
"""
using System;

class C
{
void M()
{
[||]Console.WriteLine();
}
}
""");
}

[Fact]
public async Task TestNotOnNamedType2()
{
await TestMissingInRegularAndScriptAsync(
"""
using System;

[||]Console.WriteLine();
""");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public sealed override async Task ComputeRefactoringsAsync(CodeRefactoringContex
if (expressionSymbol is IParameterSymbol parameterSymbol && parameterSymbol.ContainingSymbol.Equals(containingSymbol))
return;

// Direct reference to named type or type parameter. e.g. `$$Console.WriteLine()` or `T.Add(...)`. These
// are effectively statics (not values) and cannot become parameter.
if (expressionSymbol is INamedTypeSymbol or ITypeParameterSymbol)
return;

// Code actions for trampoline and overloads will not be offered if the method is a constructor.
// Code actions for overloads will not be offered if the method if the method is a local function.
var methodKind = methodSymbol.MethodKind;
Expand Down
Loading