How it works...

Completion providers are VS IDE extensions that can register completion items to be shown in the Visual Studio IDE when the user is editing source code. The primary APIs on CompletionProvider are:

  • ShouldTriggerCompletion method (virtual): This is the method to decide if completion should be invoked for the given editing context. This method takes the following arguments: SourceText of the document being edited, caretPosition at which completion was invoked, CompletionTrigger (which contains the trigger kind - insertion, deletion, and so on, and the trigger character), and OptionSet for completion.
  • ProvideCompletionsAsync method (abstract): This is the method to register completion items. This method is invoked by the completion ...

Get Roslyn Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.