ReSharper Platform SDK
 
Because ReSharper Platform SDK undefined is still in development, this documentation may not be entirely accurate and is subject to change.

Testing Lexers

Last modified: 04 July 2023

The LexerTestBase class can be used to create tests for lexers. It derives from BaseTestWithSingleProject, so it creates an in-memory ReSharper instance with a solution loaded that contains a single project. The project will consist of the file or files named in the test methods.

The input file, that gets added to the in-memory project, should be an example file in the custom language. The LexerTestBase class will create an instance of the language's ILexer, with the default implementation using the file extension to get an instance of the custom language's IProjectFileLanguageService, and then calling GetMixedLexerFactory.

The entire example file is then lexed, and the output file is compared against the gold file to ensure it matches. The output file is a stream of token types, one on each line. The value of the token type is the ToString implementation of the TokenNodeType instance, which is either the token's representation, or it's identifier (see token node types for more details on the representation and identifier).

For example, given the following CSS file - test01.css:

Then the test01.css.gold file would be: