C# Класс TestHelper.DiagnosticVerifier

Superclass of all Unit Tests for DiagnosticAnalyzers
Показать файл Открыть проект Примеры использования класса

Защищенные методы

Метод Описание
CreateDocument ( string source ) : Microsoft.CodeAnalysis.Document

Create a Document from a string through creating a project that contains it.

GetCSharpDiagnosticAnalyzer ( ) : Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer
GetSortedDiagnosticsFromDocuments ( Microsoft.CodeAnalysis.Document documents ) : Diagnostic[]
VerifyDiagnostic ( string source ) : void

Called to test a C# DiagnosticAnalyzer when applied on the single inputted string as a source Note: input a DiagnosticResult for each Diagnostic expected

Приватные методы

Метод Описание
CreateProject ( string sources ) : Microsoft.CodeAnalysis.Project

Create a project using the inputted strings as sources.

FormatDiagnostics ( Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer analyzer ) : string

Helper method to format a Diagnostic into an easily readable string

GetDocuments ( string sources ) : Microsoft.CodeAnalysis.Document[]

Given an array of strings as sources and a language, turn them into a project and return the documents and spans of it.

VerifyDiagnosticResults ( IEnumerable actualResults ) : void

Checks each of the actual Diagnostics found and compares them with the corresponding DiagnosticResult in the array of expected results. Diagnostics are considered equal only if the DiagnosticResultLocation, Id, Severity, and Message of the DiagnosticResult match the actual diagnostic.

Описание методов

CreateDocument() защищенный статический Метод

Create a Document from a string through creating a project that contains it.
protected static CreateDocument ( string source ) : Microsoft.CodeAnalysis.Document
source string Classes in the form of a string
Результат Microsoft.CodeAnalysis.Document

GetCSharpDiagnosticAnalyzer() защищенный Метод

protected GetCSharpDiagnosticAnalyzer ( ) : Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer
Результат Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer

GetSortedDiagnosticsFromDocuments() защищенный Метод

protected GetSortedDiagnosticsFromDocuments ( Microsoft.CodeAnalysis.Document documents ) : Diagnostic[]
documents Microsoft.CodeAnalysis.Document
Результат Diagnostic[]

VerifyDiagnostic() защищенный Метод

Called to test a C# DiagnosticAnalyzer when applied on the single inputted string as a source Note: input a DiagnosticResult for each Diagnostic expected
protected VerifyDiagnostic ( string source ) : void
source string A class in the form of a string to run the analyzer on
Результат void