private static void Assert(string code, string descriptorName) { var analyzer = new CommutativityAnalyzer(); var references = new[] { MetadataReference.CreateFromFile(typeof(string).Assembly.Location), MetadataReference.CreateFromFile(typeof(Console).Assembly.Location), }; var allCode = CommutativeAttribute + code; if (descriptorName != null) { var descriptor = Descriptors.ByName(descriptorName); RoslynAssert.Diagnostics( analyzer, ExpectedDiagnostic.Create(descriptor), allCode, metadataReferences: references); } else { RoslynAssert.NoAnalyzerDiagnostics(analyzer, allCode); } }