ReSharper Web Help

ReSharper | Templates Explorer | Live Templates | VB.NET | Other

VB.net

Other

This group contains non-categorized templates. Templates for creating arrays, declaring public variables and creating empty methods are provided here, among others.

Template name Description
asrt

Go to top

Purpose
This template calls the System.Diagnostics.Debug.Assert() method, which is used for debugging purposes. After the template expanded, the caret moves between the parentheses so that you can specify a condition.

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

Before expansion

After expansion

Parameters

  • END - an empty set of method arguments.

attachedProperty

Go to top

Purpose
This template creates an attached property with required get and set procedures.

Public Shared ReadOnly $propertyName$Property As System.Windows.DependencyProperty = System.Windows.DependencyProperty.RegisterAttached("$propertyName$", GetType ($propertyType$), GetType ($containingType$), new System.Windows.PropertyMetadata(Nothing))

Public Shared Function Get$propertyName$ (ByVal $element$ As $UIElement$) As $propertyType$
  Return DirectCast ($element$.GetValue ($propertyName$Property), $propertyType$)
End Function

Public Shared Sub Set$propertyName$ (ByVal $element$ As $UIElement$, ByVal value As $propertyType$)
  $element$.SetValue ($propertyName$Property, value)
End Sub

Before expansion

After expansion

Parameters

  • propertyName - name of attached property.
  • propertyType - type of attached property.
  • containingType - type that contains attached property.
  • element - object that has specified attached property.
  • UIElement - type of object with attached property.

ByRef

Go to top

Purpose
This template inserts ByRef parameter declaration.

ByRef $PARAM_NAME$ As $PARAM_TYPE$

Before expansion

After expansion

Parameters

  • PARAM_NAME - parameter name.
  • PARAM_TYPE - parameter type.

ByVal

Go to top

Purpose
This template inserts ByVal parameter declaration.

ByVal $PARAM_NAME$ As $PARAM_TYPE$

Before expansion

After expansion

Parameters

  • PARAM_NAME - parameter name.
  • PARAM_TYPE - parameter type.

ct

Go to top

Purpose
Generates the CType() function, which is used to explicitly convert VB.NET types.

CType($EXPR$, $TYPE$)

Before expansion

After expansion

Parameters

  • EXPR - name of variable to cast from.
  • TYPE - type to cast to.

dc

Go to top

Purpose
Generates the DirectCast() function as an alternative way to perform type casts.

DirectCast($EXPR$, $TYPE$)

Before expansion

After expansion

Parameters

  • EXPR - name of variable to cast from.
  • TYPE - type to cast to.

 Note

For more details on CType vs. DirectCast see Visual Basic Language Reference: DirectCast and Visual Basic .NET Internals at MSDN.
dependencyProperty

Go to top

Purpose
This template inserts dependency property with necessary wrapper.

Public Shared ReadOnly $propertyName$Property As System.Windows.DependencyProperty = System.Windows.DependencyProperty.Register("$propertyName$", GetType ($propertyType$), GetType ($containingType$), new System.Windows.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

Before expansion

After expansion

Parameters

  • propertyName - name of dependency property.
  • propertyType - type of dependency property.
  • containingType - type that contains dependency property.

dim

Go to top

Purpose
Declares a new variable.

Dim $VAR$ As $TYPE$

Before expansion

After expansion

Parameters

  • VAR - name of new variable.
  • TYPE - type of new variable.

fun

Go to top

Purpose
Declares a new function.

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

Before expansion

After expansion

Parameters

  • NAME - name of new function.
  • TYPE - type of value to be returned by the function.
  • END - empty function body.

out

Go to top

Purpose
Outputs a string.

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

Before expansion

After expansion

Parameters

  • END - string value.

outv

Go to top

Purpose
Outputs value of an expression.

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

Before expansion

After expansion

Parameters

  • EXPR - name of variable that is converted into string to produce the appropriate output.

pssm

Go to top

Purpose
Generates the Main() method for a VB.NET application.

Public Shared Sub Main
    $END$
End Sub

Before expansion

After expansion

Parameters

  • END - empty body of the Main() function.

sel

Go to top

Purpose
This template inserts Select Case statement.

Select Case $expression$
    $END$
End Select

Before expansion

After expansion

Parameters

  • expression - expression for Select Case statement.
  • END - empty body of statement.

sfc

Go to top

Purpose
Casts a variable in a safe manner, checking for null reference.

Dim $VAR$ As $TYPE$ = TryCast($EXPR$, $TYPE$)

If $VAR$ IsNot Nothing Then
    $END$
End If

Before expansion

After expansion

Parameters

  • VAR - name of new variable.
  • TYPE - type of new variable and (in the second occurrence) target cast type.
  • EXPR - name of variable to cast from.
  • END - empty body of verification loop.

sub

Go to top

Purpose
Declares a new subroutine.

Sub $NAME$
    $END$
End Sub

Before expansion

After expansion

Parameters

  • NAME - name of new subroutine.
  • END - empty subroutine body.

tc

Go to top

Purpose
Performs a cast that doesn't throw exceptions.

TryCast($EXPR$, $TYPE$)

Before expansion

After expansion

Parameters

  • EXPR - name of variable to cast from.
  • TYPE - type to cast to.

See Also

Reference

External Links