public void CaptureEncodingAndExtension() { string input = InputTemplate_CaptureEncodingAndExtension.NormalizeNewlines(); string output = Preprocess(input); string expectedOutput = TemplatingEngineHelper.CleanCodeDom(Output_CaptureEncodingAndExtension.NormalizeNewlines(), "\n"); Assert.AreEqual(expectedOutput, output, output); }
//NOTE: we set the newline property on the code generator so that the whole files has matching newlines, // in order to match the newlines in the verbatim code blocks void Generate(string input, string expectedOutput, string newline) { DummyHost host = new DummyHost(); string className = "GeneratedTextTransformation4f504ca0"; string code = GenerateCode(host, input, className, newline); Assert.AreEqual(0, host.Errors.Count); Assert.AreEqual(expectedOutput, TemplatingEngineHelper.StripHeader(code, newline)); }
public void Preprocess_ControlBlockAfterIncludedTemplateWithClassFeatureBlock_ReturnsValidCSharpOutput() { string input = InputTemplate_ControlBlockAfterIncludedTemplateWithClassFeatureBlock.NormalizeNewlines(); DummyHost host = CreateDummyHostForControlBlockAfterIncludedTemplateWithClassFeatureBlockTest(); string expectedOutput = TemplatingEngineHelper.CleanCodeDom(Output_ControlBlockAfterIncludedTemplateWithClassFeatureBlock.NormalizeNewlines(), "\n"); string output = Preprocess(input, host); Assert.AreEqual(expectedOutput, output, output); }
public void Preprocess() { string input = "<#@ template language=\"C#\" #>\r\n" + "Test\r\n"; string expectedOutput = TemplatingEngineHelper.CleanCodeDom(OutputSample1, "\n"); string output = Preprocess(input); Assert.AreEqual(expectedOutput, output); }
public void ControlBlockAfterIncludedTemplateWithClassFeatureBlock() { string input = InputTemplate_ControlBlockAfterIncludedTemplateWithClassFeatureBlock.NormalizeNewlines(); DummyHost host = CreateDummyHostForControlBlockAfterIncludedTemplateWithClassFeatureBlockTest(); host.HostOptions.Add("UseRelativeLinePragmas", true); string expectedOutput = TemplatingEngineHelper.CleanCodeDom(Output_ControlBlockAfterIncludedTemplateWithClassFeatureBlock.NormalizeNewlines(), "\n"); string output = Preprocess(input, host); Assert.Equal(expectedOutput, output); }
//NOTE: we set the newline property on the code generator so that the whole files has matching newlines, // in order to match the newlines in the verbatim code blocks void Generate(string input, string expectedOutput, string newline) { var host = new DummyHost(); string nameSpaceName = "Microsoft.VisualStudio.TextTemplating4f504ca0"; string code = GenerateCode(host, input, nameSpaceName, newline); Assert.AreEqual(0, host.Errors.Count); var generated = TemplatingEngineHelper.CleanCodeDom(code, newline); expectedOutput = TemplatingEngineHelper.CleanCodeDom(expectedOutput, newline); Assert.AreEqual(expectedOutput, generated); }
string Preprocess(string input) { DummyHost host = new DummyHost(); string className = "PreprocessedTemplate"; string classNamespace = "Templating"; string language = null; string[] references = null; TemplatingEngine engine = new TemplatingEngine(); string output = engine.PreprocessTemplate(input, host, className, classNamespace, out language, out references); output = output.Replace("\r\n", "\n"); return(TemplatingEngineHelper.StripHeader(output, "\n")); }
static string Preprocess(string input, DummyHost host) { string className = "PreprocessedTemplate"; string classNamespace = "Templating"; var engine = new TemplatingEngine(); string output = engine.PreprocessTemplate(input, host, className, classNamespace, out _, out _); ReportErrors(host.Errors); if (output != null) { return(TemplatingEngineHelper.CleanCodeDom(output, "\n")); } return(null); }
string Preprocess(string input, DummyHost host) { string className = "PreprocessedTemplate"; string classNamespace = "Templating"; string language = null; string[] references = null; TemplatingEngine engine = new TemplatingEngine(); string output = engine.PreprocessTemplate(input, host, className, classNamespace, out language, out references); ReportErrors(host.Errors.ToCompilerErrorCollection()); if (output != null) { return(TemplatingEngineHelper.CleanCodeDom(output, "\n")); } return(null); }