I'm using Visual Studio 2022. I'm trying to write my own language extension that does auto complete for a custom language my work uses. I have tried following documentation, videos and chat gpt but cannot get the auto complete to work or for that matter even load the symbols on my code. I have created a class to define an extension and content type
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Utilities;
namespace OpcenterCoreLanguagePlugin.Types
{
public class FileAndContentTypeDefinitions
{
[Export]
[Name("CommonLanguageFunction")]
[BaseDefinition("text")]
internal static ContentTypeDefinition CommonLanguageFunctionDefinition;
[Export]
[ContentType("CommonLanguageFunction")]
[FileExtension(".clf")]
internal static FileExtensionToContentTypeDefinition CommonLanguageFunctionTypeDefinition;
}
}
Then I created a source provider using this code:
[Export(typeof(ICompletionSourceProvider))]
[ContentType("CommonLanguageFunction")]
[Name("CLFAutoComplete")]
and completion handler
[Export(typeof(IVsTextViewCreationListener))]
[Name("CLFcompletionhandler")]
[ContentType("CommonLanguageFunction")]
[TextViewRole(PredefinedTextViewRoles.Editable)]
My problem is that the symbols don't even seem to load for the actual code of these classes. I have no included the code because I don't think it is necessarily relevant. I'm just trying to get a static list of strings to display before i start writing the actual logic.
Are there additional steps I am missing? I can't seem to find anything else I'm supposed to do.
I have implemented the following interfaces in my project:
IOleCommandTarget
IVsTextViewCreationListener
ICompletionSource
ICompletionSourceProvider
I largely copied the code out of the Visual Studio instructions here https://learn.microsoft.com/en-us/visualstudio/extensibility/walkthrough-displaying-statement-completion?view=vs-2022&tabs=csharp#create-a-mef-project.
Just to see if I could get it working before I strip out their code and replace it with my own.
I was trying to create my own editor for a custom file type of .clf and have it auto complete when I type a letter.
Turned out that i had to mark the project as a MEF component in my vsix file for the classes to get read. took a long time to find that information.