Search Unity

Question Can you use a CompletionProvider in Unity?

Discussion in 'Code Editors & IDEs' started by JusteTools, Sep 17, 2022.

  1. JusteTools

    JusteTools

    Joined:
    Mar 19, 2021
    Posts:
    14
    Hello!

    I am trying to add custom auto-completion to visual studio.

    I followed this tutorial and it is working well.
    I then tried to replace the code with a CompletionProvider inheriting class, something along the line of:

    Code (CSharp):
    1.     [ExportCompletionProvider("MyCompletionProvider", LanguageNames.CSharp)]
    2.     public class MyCompletionProvider : CompletionProvider
    3.     {
    4.         public async override Task ProvideCompletionsAsync(CompletionContext context)
    5.         {
    6.             context.AddItem(CompletionItem.Create("This is a display text",
    7.                 properties: new Dictionary<string, string> { { "Key 1", "Value 1" } }.ToImmutableDictionary(),
    8.                 tags: new string[] { "tag 1" }.ToImmutableArray()));
    9.         }
    10.     }
    But I get nothing in visual studio.

    I'm new to using roslyn API so the above code may just be wrong, but I tried the code from this page and it doesn't work either.

    Hence my question, can you use a CompletionProvider in Unity?

    Thanks a lot!