JetBrains Fleet 1.32 Help

Code completion in C#

JetBrains Fleet's code completion in C# suggests names of classes, methods, variables, keywords, and any other symbols that are available within the current visibility scope including extension methods that were previously imported. Many other context-specific suggestions, like live templates, code generation suggestions, unit test categories are also available in the completion list.

Completion suggestions will appear automatically as you type, but you can also invoke them explicitly by pressing ⌃ Space.

JetBrains Fleet: Code completion list

You can use CamelHumps in code completion, that is you can type the initial letters of compound name parts and the name will appear in the list of suggestions. For example, you can type tes and then pick TextEncoderSettings from the completion list.

When you use code completion over existing code items, you can either insert the selected completion suggestion before the existing item by pressing Enter or replace the existing identifier with the selected suggestion by pressing Tab.

Apart from suggesting types, members, and identifiers, code completion helps you generate different code constructs with a couple of keystrokes. Below are some examples.

Overriding and implementing members

In the example below, code completion helps create an override for a virtual member from a base class. Start typing the base method name in a derived type, and you will get a suggestion to override it:

JetBrains Fleet: Completion suggestion for method override

After you accept the suggestion, the method body with the default implementation expands in the editor:

public class Derived : BaseClass { protected override void DoSomething(int x, string s) { base.DoSomething(x, s); } }

Properties for fields

To generate properties for a field, start typing the name of the field. JetBrains Fleet will suggest creating a read-only or a read-write property with the corresponding name according to your naming style:

JetBrains Fleet: Completion suggestion to generate a property for a field

After you accept the suggestion, the property body expands in the editor:

public class Properties { private int _myField; public int MyField { get { return _myField; } set { _myField = value; } } }

Type constructors

Depending on the existing members of the current type, JetBrains Fleet suggests different constructors in the completion list. To create a constructor, type ctor. In the completion list, you may see the following suggestions:

  • ctor — a constructor without parameters

  • ctorf — a constructor that initializes all fields

  • ctorp — a constructor that initializes all auto-properties

  • ctorfp — a constructor that initializes all fields and auto-properties

In the example below, all kinds of constructors are available.

JetBrains Fleet: IntelliSense for generating constructors.

If you accept the ctorfp suggestion, the constructor expands in the editor:

public class Person { private string age; public string Name { get; set; } public Person(string age, string name) { this.age = age; Name = name; } }

Generate equality and flag checks for enumeration types

When you need to compare a value of enum type to one of the members of this enum, just type a dot and then pick the desired enum member in the completion list:

Completing enum members to produce equality/flag checks

JetBrains Fleet will generate the comparison for you:

public enum Direction { North, East, South, West } void Turn(Direction whereTo) { if(whereTo == Direction.South }

Templates in completion lists

All your live templates, postfix templates, and source templates appear in the completion list. Templates are identified by their shortcuts (here are the list of shortcuts of predefined templates).

For example, to invoke the public static void Main template, type its shortcut psvm:

JetBrains Fleet: Code template in completion list

After you accept the suggestion, the Main method expands in the editor:

public static void Main(string[] args) { }
Last modified: 22 March 2024