ReSharper Platform SDK
 
Because ReSharper Platform SDK undefined is still in development, this documentation may not be entirely accurate and is subject to change.

Scopes

Last modified: 04 July 2023

ReSharper's Live Templates can declare the scope in which they are available. That is, instead of allowing all templates to be inserted at any location in any file, a template can be constrained to certain file types, and even to certain locations within those files. For example, a template can be constrained not just to C# files, but to any location where a namespace declaration, type definition, or an expression is valid.

Furthermore, the template scope can be parameterised. For example, a C# template can state that it is only available in C# 3.0 files (perhaps the template wants to make use of LINQ), or in files that match a specific file pattern (e.g. "actions.xml", "*.html", etc.)

A template can have multiple scope points, in which case, the template is available if any of the scope points match the current context.

In this way, templates can be constrained to be more targeted and useful, even allowing multiple templates with the same shortcut, as long as they are valid in different scopes.