@Option Directive

Makes sure that your code agrees with a given style.

Syntax

@Option options

Parts

options
Necessary – One or more identifiers

Instructions

Charset Latin

All names must use the Latin character set. That is letters (‘A’ thru ‘Z’), digits (‘0’ thru ‘9’), and underscores (‘_’).

Dim

Dim With Dim

You must start a variable declaration with Dim, and not Var. For example:

Dim x As Int

Dim With Var

You must start a variable declaration with Var, and not Dim. For example:

Var x As Int

End

End For With Name

You can use this only with “@Option End With Block”. You must complete all For statements with End For, plus the loop counter. For example:

For index = 1 To 10
  ' ...
End For index

End For Without Name

You can use this only with “@Option End With Block”. You must complete all For statements with End For, without the loop counter. For example:

For index = 1 To 10
  ' ...
End For

End With Block

You must write End plus the block type. For example:

While condition
  ' ...
End While

End Without Block

You must write End without the block type. For example:

While condition
  ' ...
End

Enum

Enum With Name

You must give a name to all Enum statements. For example:

Enum DogBreed
  ' ...
End

Enum With Type

You must give Enum statements a data type, with the Is clause. For example:

Enum Is UInt16
  ' ...
End

Enum With Equals

You must give Enum statements values assigned with the ‘=’ operator. For example:

Enum
  first  = 1
  second = 2
End

If

If With End

You must complete If...Then...Else statements with End or End If. If you use “@Option End With Block”, you must write End If. Thus, use of the one-line construct becomes an error.

If With Then

You must write Then with all If...Then...Else statements. For example:

If condition1 Then
  ' ...
Else If condition2 Then
  ' ...
End

If Without Then

You must not write Then with multiline If...Then...Else statements. For example:

If condition1
  ' ...
Else If condition2
  ' ...
End

Last

This @Option directive must be the last.

New

New With New

You must start New Statements with New. If you use “@Option End With Block”, you must complete the multiline construct with End New. For example:

New Files #logs, "*.log"

New Menu #file, "File"
Begin
  ' ...
End New

New Without New

You must start New Statements with the data type, not New. If you use “@Option End With Block”, you must complete the multiline construct with End plus the data type. For example:

Files #logs, "*.log"

Menu #file, "File"
Begin
  ' ...
End Menu

Optional With Equals

You must give a value to an optional parameter with the “=” operator. For example:

Method ReadData(Optional path As String = ".")
  ' ...
End

Select

Select With Case

You must write Select Case in a Select...Case statement. For example:

Select Case test
  ' ...
End

Select With Else

You must write a Case Else clause for all Select...Case statements. This is to make sure that you do something for all possible values. For example:

Select minutes
Case 0 To 29
  ' ...
Case 30 To 59
  ' ...
Case Else
  Throw InvalidRangeException(minutes)
End

Select Without Case

You must not write the keyword Case after Select in a Select...Case statement.

Unit With Name

You must write the full names of units of measure. Thus “kilometer” is correct syntax, but “km” is incorrect.

Warn

TODO

See also