Machinations

SourceTemplateAttribute Class Reference

An extension method marked with this attribute is processed by ReSharper code completion as a 'Source Template'. When extension method is completed over some expression, it's source code is automatically expanded like a template at call site. More...

Inheritance diagram for SourceTemplateAttribute:

## Detailed Description

An extension method marked with this attribute is processed by ReSharper code completion as a 'Source Template'. When extension method is completed over some expression, it's source code is automatically expanded like a template at call site.

Template method body can contain valid source code and/or special comments starting with '$'. Text inside these comments is added as source code when the template is applied. Template parameters can be used either as additional method parameters or as identifiers wrapped in two '$' signs. Use the MacroAttribute attribute to specify macros for parameters.

In this example, the 'forEach' method is a source template available over all values of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block:

[SourceTemplate]
public static void forEach<T>(this IEnumerable<T> xs) {
foreach (var x in xs) {
//$ $END$
}
}

The documentation for this class was generated from the following file:

- Properties/Annotations.cs