ReSharper 2016.1 Help

Predefined Live Templates for VB.NET

ReSharper | Templates Explorer | Live Templates | VB.NET

This topic lists all predefined live templates for VB.NET in ReSharper 2016.1.1. For more information about live templates, see Creating Source Code Using Live Templates

TemplateDetails
ctx

Current file context

Scope everywhere

Body

$CTX$

Parameters

  • CTX - Provides list of items describing current context. This includes file name, containing type name, namespace name, etc. (context)
foreach

For Each block

Scope VB.NET 8+ statements

Body

For Each $VAR$ As $TYPE$ In $COL$ $END$ Next

Parameters

  • COL - Show basic code completion list at the point where the variable is evaluated (complete)
  • TYPE - Analyzes code and guesses type of element of a collection. (guessElementType)
  • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__foreach__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__foreach__after

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

itar

Iterate an array

Scope VB.NET 8+ statements

Body

For $VAR$ As Integer = 0 To $ARRAY$.Length - 1 Dim $ELEMENT$ As $TYPE$ = $ARRAY$($VAR$) $END$ Next

Parameters

  • ARRAY - Suggests variable which type is array type (arrayVariable)
  • VAR - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
  • TYPE - Analyzes code and guesses type of element of a collection. (guessElementType)
  • ELEMENT - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__itar__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__itar__after

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

itli

Iterate generic System.Collections.Generic.IList(Of T)

Scope VB.NET 8+ statements

Body

For $INDEX$ As Integer = 0 To $LIST$.Count - 1 Dim $ELEM$ As $TYPE$ = $LIST$($INDEX$) $END$ Next

Parameters

  • LIST - Suggests variables of the specified type. (variableOfType)
  • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
  • TYPE - Analyzes code and guesses type of element of a collection. (guessElementType)
  • ELEM - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__itli__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__itli__after

Generates a For loop which iterates over an instance of System.Collections.IList.

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

for

Simple "For" loop

Scope VB.NET 8+ statements

Body

For $VAR$ As Integer = 0 To $MAX$ $END$ Next

Parameters

  • VAR - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
  • MAX - Evaluates to the specified constant value. (constant)
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__for__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__for__after

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

ritar

Iterate array in reverse order

Scope VB.NET 8+ statements

Body

For $VAR$ As Integer = $ARR$.Length - 1 To 0 Step -1 Dim $ELEM$ As $TYPE$ = $ARR$($VAR$) $END$ Next

Parameters

  • ARR - Suggests variable which type is array type (arrayVariable)
  • VAR - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
  • TYPE - Analyzes code and guesses type of element of a collection. (guessElementType)
  • ELEM - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__ritar__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__ritar__after

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

Dim

Declare a variable

Scope VB.NET 8+ statements, VB.NET 8+ type members

Body

Dim $VAR$ As $TYPE$

Parameters

  • TYPE - no macro
  • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__dim__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__dim__after

asrt

Make an assertion

Scope VB.NET 8+ statements

Body

System.Diagnostics.Debug.Assert($END$)

Parameters

  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__asrt__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__asrt__after

The template calls the System.Diagnostics.Debug.Assert() method. After the template expands, the caret moves between the parentheses so that you can specify a condition.

out

Print a string

Scope VB.NET 8+ statements

Body

System.Console.WriteLine("$END$")

Parameters

  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__out__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__out__after

outv

Print value of an expression

Scope VB.NET 8+ statements

Body

System.Console.WriteLine("$EXPR$ = {0}", $EXPR$)

Parameters

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__outv__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__outv__after

pssm

Public Shared Sub Main

Scope VB.NET 8+ type members

Body

Public Shared Sub Main $END$ End Sub

Parameters

  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__pssm__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__pssm__after

sfc

Safely cast a variable

Scope VB.NET 8+ statements

Body

Dim $VAR$ As $TYPE$ = TryCast($EXPR$, $TYPE$) If $VAR$ IsNot Nothing Then $END$ End If

Parameters

  • EXPR - Suggests variables of the specified type. (variableOfType)
  • TYPE - no macro
  • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__sfc__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__sfc__after

sub

Subroutine declaration

Scope VB.NET 8+ type members

Body

Sub $NAME$() $END$ End Sub

Parameters

  • NAME - no macro
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__sub__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__sub__after

fun

Function declaration

Scope VB.NET 8+ type members

Body

Function $NAME$() As $TYPE$ $END$ End Function

Parameters

  • NAME - no macro
  • TYPE - no macro
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__fun__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__fun__after

dc

DirectCast clause

Scope VB.NET 8+ expressions

Body

DirectCast($EXPR$, $TYPE$)

Parameters

  • EXPR - no macro
  • TYPE - no macro

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__dc__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__dc__after

tc

TryCast clause

Scope VB.NET 8+ expressions

Body

TryCast($EXPR$, $TYPE$)

Parameters

  • EXPR - no macro
  • TYPE - no macro

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__tc__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__tc__after

ct

CType clause

Scope VB.NET 8+ expressions

Body

CType($EXPR$, $TYPE$)

Parameters

  • EXPR - no macro
  • TYPE - no macro

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__ct__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__ct__after

ByRef

ByRef parameter

Scope VB.NET 8+ method parameters

Body

ByRef $PARAM_NAME$ As $PARAM_TYPE$

Parameters

  • PARAM_TYPE - no macro
  • PARAM_NAME - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__byref__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__byref__after

ByVal

ByVal parameter

Scope VB.NET 8+ method parameters

Body

ByVal $PARAM_NAME$ As $PARAM_TYPE$

Parameters

  • PARAM_TYPE - no macro
  • PARAM_NAME - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__byval__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__byval__after

sel

Select case statement

Scope VB.NET 8+ statements

Body

Select Case $expression$ $END$ End Select

Parameters

  • expression - Show smart code completion list at the point where the variable is evaluated (completeSmart)
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__sel__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__sel__after

nguid

Insert new GUID

Scope everywhere

Body

$GUID$

Parameters

  • GUID - Generates new Globally Unique Identifier (GUID) (guid)
attachedProperty

Attached property

Scope VB.NET 8+ type members

Body

Public Shared ReadOnly $propertyName$Property As $dependencyProperty$ = $dependencyProperty$.RegisterAttached( _ "$propertyName$", GetType($propertyType$), GetType($containingType$), new PropertyMetadata(Nothing)) Public Shared Function Get$propertyName$(ByVal $element$ As DependencyObject) As $propertyType$ Return DirectCast($element$.GetValue($propertyName$Property), $propertyType$) End Function Public Shared Sub Set$propertyName$(ByVal $element$ As DependencyObject, ByVal value As $propertyType$) $element$.SetValue($propertyName$Property, value) End Sub

Parameters

  • propertyType - no macro
  • propertyName - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
  • containingType - Evaluates to short name of the most inner containing type. (typeName)
  • element - no macro
  • dependencyProperty - Evaluates to dependency property type specific to current framework (dependencyPropertyType)

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__attachedProperty__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__attachedProperty__after

dependencyProperty

Dependency property

Scope VB.NET 8+ type members

Body

Public Shared ReadOnly $propertyName$Property As $dependencyProperty$ = $dependencyProperty$.Register( _ "$propertyName$", GetType($propertyType$), GetType($containingType$), new PropertyMetadata(Nothing)) Public Property $propertyName$ As $propertyType$ Get Return DirectCast(GetValue($propertyName$Property), $propertyType$) End Get Set SetValue($propertyName$Property, value) End Set End Property

Parameters

  • propertyType - no macro
  • propertyName - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
  • containingType - Evaluates to short name of the most inner containing type. (typeName)
  • dependencyProperty - Evaluates to dependency property type specific to current framework (dependencyPropertyType)

Before expansion

Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__dependencyProperty__before

After expansion
Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__dependencyProperty__after

Last modified: 19 August 2016