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 @@ -12998,6 +12998,32 @@ public class Class1
End Using
End Function

<WpfTheory, CombinatorialData>
<WorkItem("https://github.com/dotnet/roslyn/issues/79444")>
Public Async Function TestStaticExtensionMethod_OnEnumType(showCompletionInArgumentLists As Boolean) As Task
Using state = TestStateFactory.CreateCSharpTestState(
<Document>
using System;

E.$$

enum E;

static class C
{
extension(E)
{
public static void EM() { }
}
}
</Document>,
showCompletionInArgumentLists:=showCompletionInArgumentLists, languageVersion:=LanguageVersionExtensions.CSharpNext)

state.SendInvokeCompletionList()
Await state.AssertCompletionItemsContain("EM", displayTextSuffix:="")
End Using
End Function

<WorkItem("https://github.com/dotnet/roslyn/issues/78284")>
<WpfTheory, CombinatorialData>
Public Async Function TestOverrideInstanceAssignmentOperator(showCompletionInArgumentLists As Boolean) As Task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@

namespace Microsoft.CodeAnalysis.CSharp.Completion.Providers;

[ExportCompletionProvider(nameof(EnumAndCompletionListTagCompletionProvider), LanguageNames.CSharp)]
[ExportCompletionProvider(nameof(EnumAndCompletionListTagCompletionProvider), LanguageNames.CSharp), Shared]
[ExtensionOrder(After = nameof(CSharpSuggestionModeCompletionProvider))]
[Shared]
internal sealed partial class EnumAndCompletionListTagCompletionProvider : LSPCompletionProvider
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed partial class EnumAndCompletionListTagCompletionProvider()
: LSPCompletionProvider
{
private static readonly CompletionItemRules s_enumTypeRules =
CompletionItemRules.Default.WithCommitCharacterRules([CharacterSetModificationRule.Create(CharacterSetModificationKind.Replace, '.')])
Expand All @@ -35,12 +37,6 @@ internal sealed partial class EnumAndCompletionListTagCompletionProvider : LSPCo

private static readonly ImmutableHashSet<char> s_triggerCharacters = [' ', '[', '(', '~'];

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public EnumAndCompletionListTagCompletionProvider()
{
}

internal override string Language => LanguageNames.CSharp;

public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Expand Down Expand Up @@ -105,7 +101,12 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)
}

private static async Task HandleSingleTypeAsync(
CompletionContext context, SemanticModel semanticModel, SyntaxToken token, ITypeSymbol type, bool isParams, CancellationToken cancellationToken)
CompletionContext context,
SemanticModel semanticModel,
SyntaxToken token,
ITypeSymbol type,
bool isParams,
CancellationToken cancellationToken)
{
if (isParams && type is IArrayTypeSymbol arrayType)
type = arrayType.ElementType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Collections;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Extensions.ContextQuery;
using Microsoft.CodeAnalysis.Shared.Utilities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ internal bool ShouldIncludeSymbol(ISymbol symbol)

if (_context.IsEnumTypeMemberAccessContext)
{
return symbol.Kind == SymbolKind.Field;
// Within an enum type, we can access fields of the enum, as well as static extensions on that type.
return symbol.Kind == SymbolKind.Field ||
symbol is { IsStatic: true, ContainingType.IsExtension: true };
}

// In an expression or statement context, we don't want to display instance members declared in outer containing types.
Expand Down
Loading