Skip to content

C# intellisense features of the CS Script plugin for Notepad††

Oleg Shilo edited this page May 9, 2017 · 3 revisions

Features

  • CLR Type members auto-completion. (Ctrl+Space or type '.')

  • Show Member info

    The info is implemented as a non-interactive tooltip. It pops up by rolling mouse over the C# syntax token. It cannot be triggered by any shortcut.

  • Show Method Info (overloads) popup while typing.

    The info is implemented as a interactive tooltip: you can iterate through method overloads with the up and down buttons. Triggered either automatically by typing '(' or by F6 shortcut. For both triggers to work it is required that caret should be further the method opening bracket. If this condition is not met the info will not popup. The info will also not popup if the method information cannot be obtained (e.g. because of compiling error).

  • Adding missing 'usings'. (Ctrl+.)

  • Go to definition (F12)

    • in C# source code
    • in the reconstructed referenced assembly.

  • Formatting C# source code (Ctrl+F82)

    Before

    After

Usage

"CS-Script Intellisense" will display the completion suggestions when the '.' character is typed or the plugin shortcut is pressed. The plugin is bound to "Ctrl+." shortcut by default.

"CS-Script Intellisense" will also allow resolving and add the missing namespaces (with using statements) in the similar to the way Visual Studio does it. The plugin is bound to "Ctrl+Shift+." shortcut by default. however if the "Invoke native Auto-Completion for non .cs files" is enabled the "Namespace resolving is remapped to the more familiar "Ctrl+." shortcut.

The Intellisense implementation is based on the CS-Script C# source code model. A single .cs file (Notepad++ current document) forms a single-file C# project. The referenced assemblies are resolved automatically from the "using ;" clauses. The CS-Script //css_ref (or //css_reference) directives can be used to reference assemblies explicitly.

Extra C# files can also be added to the logical C# project with the //css_inc (or //css_include) directives. The information about all CS-Script directives (~8 in total) can be found here: http://www.csscript.net/help/Directives.html.

The majority of the dependency scenarios can be handled by just two directives: //css_inc and //css_ref. And in many case there is even no need for any CS-Script directives at all as a plain vanilla C# file is usually compatible with the CS-Script Intellisense model.

The following are the samples of how to use the CS-Script directives: Including the C# file math.cs containing the Math class definition

//css_inc math.cs;
using System;

class Script 
{
    static public void Main(string[] args)
    {
        Console.WriteLine(Math.Calculator.Add(1,2));
    }
}

Referencing the math.dll assembly containing the Math class implementation

//css_ref math.dll;
using System;
 
class Script 
{
    static public void Main(string [] args)
    {
        Console.WriteLine(Math.Calculator.Add(1,2));
    }
}

NOTE: All CS-Script directives and 'using' clauses are processed on the file opening. Thus if the new directive or 'using' clauses added to the "current document" you may want to re-generate the Intellisense data with the menu 'Plugins->C# Intellisense->Re-analyse Current Document'.

Clone this wiki locally