C# 클래스 TestHelper.CodeFixVerifier

Superclass of all Unit tests made for diagnostics with codefixes. Contains methods used to verify correctness of codefixes
상속: DiagnosticVerifier
파일 보기 프로젝트 열기: signumsoftware/framework

공개 메소드들

메소드 설명
VerifyFix ( string oldSource, string newSource, int codeFixIndex = null, bool allowNewCompilerDiagnostics = false ) : void

General verifier for codefixes. Creates a Document from the source string, then gets diagnostics on it and applies the relevant codefixes. Then gets the string after the codefix is applied and compares it with the expected result. Note: If any codefix causes new diagnostics to show up, the test fails unless allowNewCompilerDiagnostics is set to true.

보호된 메소드들

메소드 설명
GetCSharpCodeFixProvider ( ) : Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider

Returns the codefix being tested (C#) - to be implemented in non-abstract class

비공개 메소드들

메소드 설명
ApplyFix ( Microsoft.CodeAnalysis.Document document, CodeAction codeAction ) : Microsoft.CodeAnalysis.Document

Apply the inputted CodeAction to the inputted document. Meant to be used to apply codefixes.

GetCompilerDiagnostics ( Microsoft.CodeAnalysis.Document document ) : IEnumerable

Get the existing compiler diagnostics on the inputted document.

GetNewDiagnostics ( IEnumerable diagnostics, IEnumerable newDiagnostics ) : IEnumerable

Compare two collections of Diagnostics,and return a list of any new diagnostics that appear only in the second collection. Note: Considers Diagnostics to be the same if they have the same Ids. In the case of multiple diagnostics with the same Id in a row, this method may not necessarily return the new one.

GetStringFromDocument ( Microsoft.CodeAnalysis.Document document ) : string

Given a document, turn it into a string based on the syntax root

메소드 상세

GetCSharpCodeFixProvider() 보호된 메소드

Returns the codefix being tested (C#) - to be implemented in non-abstract class
protected GetCSharpCodeFixProvider ( ) : Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider
리턴 Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider

VerifyFix() 공개 메소드

General verifier for codefixes. Creates a Document from the source string, then gets diagnostics on it and applies the relevant codefixes. Then gets the string after the codefix is applied and compares it with the expected result. Note: If any codefix causes new diagnostics to show up, the test fails unless allowNewCompilerDiagnostics is set to true.
public VerifyFix ( string oldSource, string newSource, int codeFixIndex = null, bool allowNewCompilerDiagnostics = false ) : void
oldSource string A class in the form of a string before the CodeFix was applied to it
newSource string A class in the form of a string after the CodeFix was applied to it
codeFixIndex int Index determining which codefix to apply if there are multiple
allowNewCompilerDiagnostics bool A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied
리턴 void