0

I am a beginner level programmer, trying to create a code editor for C# with RoslynPad. I've added the editor control to my WPF window, and highlighting also works. I would also like to enable code completion. I would appreciate if someone could point me in the right direction as to how to go about this.

This is what I have now;

{
    var roslynEditor = new CodeTextEditor();
    var roslynHost = new RoslynHost(additionalAssemblies: new[]
    {
        Assembly.Load("RoslynPad.Roslyn.Windows"),
        Assembly.Load("RoslynPad.Editor.Windows"),
    });
    roslynEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#");

}

From the few resources I have been able to gather, I believe that enabling code completion has to do with creating a Roslyn document and syntax tree for the project and using that to create a Completion Service. Please do tell me the steps to do so as well as how to add my own assemblies to the code completion. Also does the "additionalAssemblies" parameter in RoslynHost constructor have anything to do with that ?

1 Answer 1

0

I believe I have it;

Just did it like this;

 var roslynEditor = new RoslynCodeEditor();               
 var workingDirectory = Directory.GetCurrentDirectory();
 var roslynHost = new RoslynHost(additionalAssemblies: new[]
    {
       Assembly.Load("RoslynPad.Roslyn.Windows"),
       Assembly.Load("RoslynPad.Editor.Windows"),
    },
    references: 
    RoslynHostReferences.NamespaceDefault.With(typeNamespaceImports: 
    new[] { typeof(object), typeof(myassemblyType) }));
            

 roslynEditor.Initialize(roslynHost, new ClassificationHighlightColors(), workingDirectory, "");
 roslynEditor.SyntaxHighlighting =    
 HighlightingManager.Instance.GetDefinition("C#");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.