How to customize RapidScan
Everything you need to know to create custom configuration files for RapidScan

How RapidScan Works

RapidScan uses configuration files that associate file extensions to a set of attributes including: Is it binary? Does it have interesting content? What kind of content? (project, code, markup, etc.) To what kind of language is it associated? How to tell content lines apart from comments and blank lines? How to ignore blocks that are not part of the language? (comments or strings)

Configuration file format

The RapidScan configuration files have extension cfg and contain a json with the following format:

Sample configuration file:

1
{
2
"Name": "C Sharp",
3
"ContentType": "Code",
4
"SourceExtensions": [
5
"cs"
6
],
7
"BinaryExtensions": [
8
9
],
10
"CaseSensitive": "true",
11
"SeparatorChars": " \t\r\n",
12
"SymbolChars": "-+/*{}[]()<>~!#$%^&=`'\".,;:?\\|",
13
"WordChars": "@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_ªµºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàâãåæçèêìîðñòôõøùûýþÿ",
14
"IgnoreBlockDescriptors": [
15
{
16
"Start": "/*",
17
"End": "*/",
18
"Ignore": [],
19
"Kind": "Comment"
20
},
21
{
22
"Start": "\"",
23
"End": "\"",
24
"Ignore": [ "\\\"", "\\\\" ],
25
"Kind": "Content"
26
}
27
],
28
"LineComment": "//",
29
"Keywords": [
30
"abstract",
31
"as",
32
"async",
33
"await",
34
...
35
"partial",
36
"yield"
37
]
38
}
39
Copied!

File Elements:

  • Name: The Technology name that will apply for the files with the specified extensions. E.g.: "Java, "C#", "Python", etc.
  • ContentType: Specify the type of content for the files related to the specified extensions. E.g.: "Code", "Project", "Markup", "Data", etc.
  • SourceExtensions: The extensions of the files that will be associated to this configuration. E,g,: "cs", "java", "lsp", "vb", etc.
  • BinaryExtensions: Extensions that will be associated to this technology, but will be assumed as binary, so they wont be opened to count lines. Only bytes will be counted.
  • CaseSensitive: Whether the keywords are case sensitive or not.
  • SeparatorChars: List of chars to be interpreted as separators.
  • SymbolChars: List of chars to be interpreted as symbols.
  • WordChars: List of chars to be interpreted as identifiers or keywords.
  • IgnoreBlockDescriptors: List of blocks to be ignored in the code (typically block-comments or comments)
    • Start: token that starts the block. E.g.: "/*" for block comments or "\"" for strings.
    • End: token that ends the block. E.g.: "*/" for block comments or "\"" for strings.
    • Ignore: sequences of chars to be skipped, not to be confused as part of the "End" element. E.g.: inside strings a \" must not be interpreted as an end of string, unless it is preceded by an odd number of \. (see sample file above)
    • Kind: "Comment" (comment block) or "Content" (strings)
  • LineComment: the char sequence that starts a line comment.
  • Keywords: the list of all the keywords that must be counted for that language/technology. A keyword can combine word, symbol and separator characters. If a keyword contains one or more separators, the RapidScan will support any amount of separators at the corresponding locations.

Default char classifications

If a char is not specified in "SeparatorChars", "SymbolChars" or "WordChars", they will be classified by using the .Net char.IsSeparator for separators and char.IsLetterOrDigit for words. If none of them return true the character will be assumed to be a symbol.

Create your own configuration files

You can create your own configuration files to support new technologies or override the settings for existing ones. You can do that by following these steps:
  • Create a .cfg file for each Technology/Configuration you want to support. (If a technology has files with different formats, you can create different .cfg files with the same technology name.)
  • Fill up the settings as previously explained.
  • Copy the .cfg files in the following path:
    • %appdata%\Roaming\Mobilize.Net\GenericCounter (you can type %appdata% in the windows explorer, it will take you to the "appdata" folder)
Last modified 9mo ago