private static void TestInline(string xml, string expectedText, params DiagnosticDescription[] expectedDiagnostics) { var sourceTemplate = @" /** {0} */ class {1} {{ }} /** {1} {0} */ partial class Partial {{ }} "; var trees = AllModes.Select(mode => Parse(string.Format(sourceTemplate, xml, mode), string.Format("{0}.cs", mode), GetOptions(mode))); var comp = CreateStandardCompilation(trees, assemblyName: "Test"); comp.VerifyDiagnostics(expectedDiagnostics); var actualText = GetDocumentationCommentText(comp, expectedDiagnostics: null); Assert.Equal(expectedText, actualText); }
private void TestIncluded(string xml, string xpath, string expectedTextTemplate, Func <string, DiagnosticDescription[]> makeExpectedDiagnostics, bool fallbackToErrorCodeOnlyForNonEnglish = false) { var xmlFile = Temp.CreateFile(extension: ".xml").WriteAllText(xml); var xmlFilePath = xmlFile.Path; string includeElement = string.Format(@"<include file='{0}' path='{1}' />", xmlFilePath, xpath); var sourceTemplate = @" /// {0} class {1} {{ }} /// {1}: {0} partial class Partial {{ }} "; var trees = AllModes.Select(mode => Parse(string.Format(sourceTemplate, includeElement, mode), string.Format("{0}.cs", mode), GetOptions(mode))); var comp = CreateStandardCompilation( trees, options: TestOptions.ReleaseDll.WithXmlReferenceResolver(XmlFileResolver.Default), assemblyName: "Test"); comp.GetDiagnostics().Verify(fallbackToErrorCodeOnlyForNonEnglish: fallbackToErrorCodeOnlyForNonEnglish, expected: makeExpectedDiagnostics(includeElement)); var actualText = GetDocumentationCommentText(comp, expectedDiagnostics: null); var expectedText = string.Format(expectedTextTemplate, TestHelpers.AsXmlCommentText(xmlFilePath)); Assert.Equal(expectedText, actualText); }
private void TestIncluded(string xml, string xpath, string expectedTextTemplate, Func <string, DiagnosticDescription[]> makeExpectedDiagnostics) { var xmlFile = Temp.CreateFile(extension: ".xml").WriteAllText(xml); var xmlFilePath = xmlFile.Path; string includeElement = string.Format(@"<include file='{0}' path='{1}' />", xmlFilePath, xpath); var sourceTemplate = @" /// {0} class {1} {{ }} /// {1}: {0} partial class Partial {{ }} "; var trees = AllModes.Select(mode => Parse(string.Format(sourceTemplate, includeElement, mode), string.Format("{0}.cs", mode), GetOptions(mode))); var comp = CreateCompilationWithMscorlib( trees, compOptions: TestOptions.Dll.WithXmlReferenceResolver(XmlFileResolver.Default), assemblyName: "Test"); comp.VerifyDiagnostics(makeExpectedDiagnostics(includeElement)); var actualText = GetDocumentationCommentText(comp, expectedDiagnostics: null); var expectedText = string.Format(expectedTextTemplate, xmlFilePath); Assert.Equal(expectedText, actualText); }