private void VerifyCSharpFixExpressionBody<TCodeFixProvider, TDiagnosticAnalyzer>(string oldSourceAssertion, string newSourceAssertion) where TCodeFixProvider : Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider, new() where TDiagnosticAnalyzer : Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer, new() { var oldSource = GenerateCode.EnumerableExpressionBodyAssertion(oldSourceAssertion); var newSource = GenerateCode.EnumerableExpressionBodyAssertion(newSourceAssertion); DiagnosticVerifier.VerifyCSharpFix<TCodeFixProvider, TDiagnosticAnalyzer>(oldSource, newSource); }
private void VerifyCSharpDiagnosticExpressionBody<TDiagnosticAnalyzer>(string sourceAssertion) where TDiagnosticAnalyzer : Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer, new() { var source = GenerateCode.EnumerableExpressionBodyAssertion(sourceAssertion); var type = typeof(TDiagnosticAnalyzer); var diagnosticId = (string)type.GetField("DiagnosticId").GetValue(null); var message = (string)type.GetField("Message").GetValue(null); DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new DiagnosticResult { Id = diagnosticId, Message = message, Locations = new DiagnosticResultLocation[] { new DiagnosticResultLocation("Test0.cs", 10,16) }, Severity = DiagnosticSeverity.Info }); }