diff --git a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpPaddingBuilder.cs b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpPaddingBuilder.cs index 774600b6eb..fe01747084 100644 --- a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpPaddingBuilder.cs +++ b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpPaddingBuilder.cs @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp { private static readonly char[] _newLineChars = { '\r', '\n' }; - private RazorEngineHost _host; + private readonly RazorEngineHost _host; public CSharpPaddingBuilder(RazorEngineHost host) { diff --git a/test/Microsoft.AspNet.Razor.Test/CSharpRazorCodeLanguageTest.cs b/test/Microsoft.AspNet.Razor.Test/CSharpRazorCodeLanguageTest.cs index 48ef1f2cca..0b180830ed 100644 --- a/test/Microsoft.AspNet.Razor.Test/CSharpRazorCodeLanguageTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/CSharpRazorCodeLanguageTest.cs @@ -41,15 +41,5 @@ namespace Microsoft.AspNet.Razor.Test Assert.Equal("Baz", generator.SourceFileName); Assert.Same(host, generator.Host); } - - [Fact] - public void CodeDomProviderTypeReturnsVBCodeProvider() - { - // Arrange - RazorCodeLanguage service = new CSharpRazorCodeLanguage(); - - // Assert - Assert.Equal(typeof(CSharpCodeProvider), service.CodeDomProviderType); - } } } diff --git a/test/Microsoft.AspNet.Razor.Test/CodeCompileUnitExtensions.cs b/test/Microsoft.AspNet.Razor.Test/CodeCompileUnitExtensions.cs deleted file mode 100644 index c5cd9f6661..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/CodeCompileUnitExtensions.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. - -using System.CodeDom; -using System.CodeDom.Compiler; -using System.IO; -using System.Text; - -namespace Microsoft.AspNet.Razor.Test -{ - internal static class CodeCompileUnitExtensions - { - public static string GenerateCode(this CodeCompileUnit ccu) where T : CodeDomProvider, new() - { - StringBuilder output = new StringBuilder(); - using (StringWriter writer = new StringWriter(output)) - { - T provider = new T(); - provider.GenerateCodeFromCompileUnit(ccu, writer, new CodeGeneratorOptions() { IndentString = " " }); - } - - return output.ToString(); - } - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/Editor/RazorEditorParserTest.cs b/test/Microsoft.AspNet.Razor.Test/Editor/RazorEditorParserTest.cs index f4cfe31f30..885b579ee4 100644 --- a/test/Microsoft.AspNet.Razor.Test/Editor/RazorEditorParserTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Editor/RazorEditorParserTest.cs @@ -134,13 +134,11 @@ namespace Microsoft.AspNet.Razor.Test.Editor parser.CheckForStructureChanges(new TextChange(0, 0, new StringTextBuffer(String.Empty), input.Length, input)); // Assert - MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait); - - string generatedCode = capturedArgs.GeneratorResults.CCU.GenerateCode(); + MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait); Assert.Equal( SimpleCSHTMLDocumentGenerated.ReadAllText(), - MiscUtils.StripRuntimeVersion(generatedCode)); + capturedArgs.GeneratorResults.GeneratedCode); } } diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs index 3bccf09b43..2f084353cf 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs @@ -2,8 +2,11 @@ using System; using System.Collections.Generic; +using System.IO; using Microsoft.AspNet.Razor.Generator; +using Microsoft.AspNet.Razor.Generator.Compiler; using Microsoft.AspNet.Razor.Parser.SyntaxTree; +using Microsoft.AspNet.Razor.Text; using Microsoft.TestCommon; namespace Microsoft.AspNet.Razor.Test.Generator @@ -78,13 +81,20 @@ namespace Microsoft.AspNet.Razor.Test.Generator [InlineData("HelpersMissingOpenParen")] [InlineData("NestedHelpers")] [InlineData("InlineBlocks")] - [InlineData("NestedHelpers")] [InlineData("LayoutDirective")] [InlineData("ConditionalAttributes")] [InlineData("ResolveUrl")] public void CSharpCodeGeneratorCorrectlyGeneratesRunTimeCode(string testType) { - RunTest(testType); + if (!Directory.Exists("./tests")) + { + Directory.CreateDirectory("./tests"); + } + + RunTest(testType, onResults: (results) => + { + File.WriteAllText(String.Format("./tests/{0}.cs", testType), results.GeneratedCode); + }); } [Fact] @@ -94,25 +104,27 @@ namespace Microsoft.AspNet.Razor.Test.Generator "SimpleUnspacedIf.DesignTime.Tabs", designTimeMode: true, tabTest: TabTest.Tabs, - expectedDesignTimePragmas: new List() + expectedDesignTimePragmas: new List() { - /* 01 */ new GeneratedCodeMapping(1, 2, 1, 15), - /* 02 */ new GeneratedCodeMapping(3, 13, 7, 3), + BuildLineMapping(1, 0,449, 20, 1, 15), + BuildLineMapping(27, 2, 12, 538, 27, 6, 3) }); } [Fact] public void CSharpCodeGeneratorCorrectlyGeneratesMappingsForRazorCommentsAtDesignTime() { - RunTest("RazorComments", "RazorComments.DesignTime", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(4, 3, 3, 6), - /* 02 */ new GeneratedCodeMapping(5, 40, 39, 22), - /* 03 */ new GeneratedCodeMapping(6, 50, 49, 58), - /* 04 */ new GeneratedCodeMapping(12, 3, 3, 24), - /* 05 */ new GeneratedCodeMapping(13, 46, 46, 3), - /* 06 */ new GeneratedCodeMapping(15, 3, 7, 1), - /* 07 */ new GeneratedCodeMapping(15, 8, 8, 1) + RunTest("RazorComments", "RazorComments.DesignTime", designTimeMode: true, tabTest: TabTest.NoTabs, + expectedDesignTimePragmas: new List() + { + BuildLineMapping(81, 3, 441, 20, 2, 6), + BuildLineMapping(122, 4, 551, 26, 39, 22), + BuildLineMapping(173, 5, 687, 32, 49, 58), + BuildLineMapping(238, 11, 811, 40, 2, 24), + BuildLineMapping(310, 12, 966, 46, 45, 3), + BuildLineMapping(323, 14, 1070, 52, 2, 1), + BuildLineMapping(328, 14, 1142, 56, 7, 1), + }); } @@ -128,16 +140,268 @@ namespace Microsoft.AspNet.Razor.Test.Generator OpenedIf(withTabs: false); } + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesImportStatementsAtDesignTime() + { + RunTest("Imports", "Imports.DesignTime", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List() + { + BuildLineMapping(1, 0, 1, 51, 3, 0, 15), + BuildLineMapping(19, 1, 1, 130, 8, 0, 32), + BuildLineMapping(54, 2, 1, 226, 13, 0, 12), + BuildLineMapping(99, 4, 702, 35, 29, 21), + BuildLineMapping(161, 5, 850, 41, 35, 20), + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesFunctionsBlocksAtDesignTime() + { + RunTest("FunctionsBlock", + "FunctionsBlock.DesignTime", + designTimeMode: true, + tabTest: TabTest.NoTabs, + expectedDesignTimePragmas: new List() + { + BuildLineMapping(12, 0, 168, 8, 12, 4), + BuildLineMapping(33, 4, 246, 13, 12, 104), + BuildLineMapping(167, 11, 744, 34, 25, 11) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesFunctionsBlocksAtDesignTimeTabs() + { + RunTest("FunctionsBlock", + "FunctionsBlock.DesignTime.Tabs", + designTimeMode: true, + tabTest: TabTest.Tabs, + expectedDesignTimePragmas: new List() + { + BuildLineMapping(12, 0, 12, 159, 8, 3, 4), + BuildLineMapping(33, 4, 12, 228, 13, 3, 104), + BuildLineMapping(167, 11, 25, 708, 34, 7, 11) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesMinimalFunctionsBlocksAtDesignTimeTabs() + { + RunTest("FunctionsBlockMinimal", + "FunctionsBlockMinimal.DesignTime.Tabs", + designTimeMode: true, + tabTest: TabTest.Tabs, + expectedDesignTimePragmas: new List() + { + BuildLineMapping(16, 2, 12, 176, 8, 6, 55) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesHiddenSpansWithinCode() + { + RunTest("HiddenSpansInCode", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List + { + BuildLineMapping(2, 0, 453, 20, 2, 6), + BuildLineMapping(9, 1, 533, 26, 5, 5) + }); + } + + [Fact] + public void CSharpCodeGeneratorGeneratesCodeWithParserErrorsInDesignTimeMode() + { + RunTest("ParserError", designTimeMode: true, expectedDesignTimePragmas: new List() + { + BuildLineMapping(2, 0, 435, 20, 2, 31) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesInheritsAtRuntime() + { + RunTest("Inherits", baselineName: "Inherits.Runtime"); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesInheritsAtDesigntime() + { + RunTest("Inherits", baselineName: "Inherits.Designtime", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List() + { + BuildLineMapping(20, 2, 286, 11, 10, 25), + BuildLineMapping(1, 0, 591, 25, 1, 5) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForUnfinishedExpressionsInCode() + { + RunTest("UnfinishedExpressionInCode", tabTest: TabTest.NoTabs, designTimeMode: true, expectedDesignTimePragmas: new List() + { + BuildLineMapping(2, 0, 480, 20, 2, 2), + BuildLineMapping(5, 1, 579, 26, 1, 9), + BuildLineMapping(14, 1, 689, 31, 10, 2) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForUnfinishedExpressionsInCodeTabs() + { + RunTest("UnfinishedExpressionInCode", + "UnfinishedExpressionInCode.Tabs", + tabTest: TabTest.Tabs, + designTimeMode: true, expectedDesignTimePragmas: new List() + { + BuildLineMapping(2, 0, 480, 20, 2, 2), + BuildLineMapping(5, 1, 579, 26, 1, 9), + BuildLineMapping(14, 1, 10, 683, 31, 4, 2) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasMarkupAndExpressions() + { + RunTest("DesignTime", + designTimeMode: true, + tabTest: TabTest.NoTabs, + expectedDesignTimePragmas: new List() + { + BuildLineMapping(222, 16, 8, 182, 9, 0, 7), + BuildLineMapping(229, 16, 323, 14, 15, 26), + BuildLineMapping(265, 18, 430, 21, 18, 9), + BuildLineMapping(274, 20, 523, 29, 0, 1), + BuildLineMapping(20, 1, 881, 46, 13, 36), + BuildLineMapping(74, 2, 1021, 53, 22, 1), + BuildLineMapping(79, 2, 1124, 58, 27, 15), + BuildLineMapping(113, 7, 1223, 65, 2, 12), + BuildLineMapping(129, 8, 1331, 71, 1, 4), + BuildLineMapping(142, 8, 1498, 77, 14, 3), + BuildLineMapping(153, 8, 1635, 84, 25, 1), + BuildLineMapping(204, 13, 1786, 91, 5, 3) + }); + } + + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForImplicitExpressionStartedAtEOF() + { + RunTest("ImplicitExpressionAtEOF", designTimeMode: true, expectedDesignTimePragmas: new List() + { + BuildLineMapping(19, 2, 490, 21, 1, 0) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForExplicitExpressionStartedAtEOF() + { + RunTest("ExplicitExpressionAtEOF", designTimeMode: true, expectedDesignTimePragmas: new List() + { + BuildLineMapping(20, 2, 491, 21, 2, 0) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForCodeBlockStartedAtEOF() + { + RunTest("CodeBlockAtEOF", designTimeMode: true, expectedDesignTimePragmas: new List() + { + BuildLineMapping(2, 0, 444, 20, 2, 0) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyImplicitExpression() + { + RunTest("EmptyImplicitExpression", designTimeMode: true, expectedDesignTimePragmas: new List() + { + BuildLineMapping(19, 2, 490, 21, 1, 0) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyImplicitExpressionInCode() + { + RunTest("EmptyImplicitExpressionInCode", tabTest: TabTest.NoTabs, designTimeMode: true, expectedDesignTimePragmas: new List() + { + BuildLineMapping(2, 0, 489, 20, 2, 6), + BuildLineMapping(9, 1, 601, 27, 5, 0), + BuildLineMapping(9, 1, 700, 32, 5, 2) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyImplicitExpressionInCodeTabs() + { + RunTest("EmptyImplicitExpressionInCode", + "EmptyImplicitExpressionInCode.Tabs", + tabTest: TabTest.Tabs, + designTimeMode: true, expectedDesignTimePragmas: new List() + { + BuildLineMapping(2, 0, 489, 20, 2, 6), + BuildLineMapping(9, 1, 5, 598, 27, 2, 0), + BuildLineMapping(9, 1, 5, 694, 32, 2, 2) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyExplicitExpression() + { + RunTest("EmptyExplicitExpression", designTimeMode: true, expectedDesignTimePragmas: new List() + { + BuildLineMapping(20, 2, 491, 21, 2, 0) + }); + } + + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyCodeBlock() + { + RunTest("EmptyCodeBlock", designTimeMode: true, expectedDesignTimePragmas: new List() + { + BuildLineMapping(20, 2, 444, 20, 2, 0) + }); + } + + [Fact] + public void CSharpCodeGeneratorDoesNotRenderLinePragmasIfGenerateLinePragmasIsSetToFalse() + { + RunTest("NoLinePragmas", generatePragmas: false); + } + + [Fact] + public void CSharpCodeGeneratorRendersHelpersBlockCorrectlyWhenInstanceHelperRequested() + { + RunTest("Helpers", baselineName: "Helpers.Instance", hostConfig: h => h.StaticHelpers = false); + } + + // TODO: This should be re-added once instrumentation support has been added + //[Fact] + //public void CSharpCodeGeneratorCorrectlyInstrumentsRazorCodeWhenInstrumentationRequested() + //{ + // RunTest("Instrumented", hostConfig: host => + // { + // host.EnableInstrumentation = true; + // host.InstrumentedSourceFilePath = String.Format("~/{0}.cshtml", host.DefaultClassName); + // }); + //} + + [Fact] + public void CSharpCodeGeneratorGeneratesUrlsCorrectlyWithCommentsAndQuotes() + { + RunTest("HtmlCommentWithQuote_Single", + tabTest: TabTest.NoTabs); + + RunTest("HtmlCommentWithQuote_Double", + tabTest: TabTest.NoTabs); + } + private void OpenedIf(bool withTabs) { - int tabOffsetForMapping = 0; + int tabOffsetForMapping = 7; // where the test is running with tabs, the offset into the CS buffer changes for the whitespace mapping // with spaces we get 7xspace -> offset of 8 (column = offset+1) // with tabs we get tab + 3 spaces -> offset of 4 chars + 1 = 5 if (withTabs) { - tabOffsetForMapping = 3; + tabOffsetForMapping -= 3; } RunTest("OpenedIf", @@ -154,264 +418,26 @@ namespace Microsoft.AspNet.Razor.Test.Generator new TestSpan(SpanKind.Markup, 40, 47), new TestSpan(SpanKind.Code, 47, 47), }, - expectedDesignTimePragmas: new List() + expectedDesignTimePragmas: new List() { - /* 01 */ new GeneratedCodeMapping(3, 2, 1, 14), - /* 02 */ new GeneratedCodeMapping(4, 8, 8 - tabOffsetForMapping, 2), - /* 03 */ new GeneratedCodeMapping(5, 8, 8 - tabOffsetForMapping, 0), + BuildLineMapping(17, 2, 425, 20, 1, 14), + BuildLineMapping(38, 3, 7, 497 + tabOffsetForMapping, 25, tabOffsetForMapping, 2), + // Multiply the tab offset absolute index by 2 to account for the first mapping + BuildLineMapping(47, 4, 7, 557 + tabOffsetForMapping * 2, 30, tabOffsetForMapping, 0) }); } - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesImportStatementsAtDesignTime() + private static LineMapping BuildLineMapping(int documentAbsoluteIndex, int documentLineIndex, int generatedAbsoluteIndex, int generatedLineIndex, int characterOffsetIndex, int contentLength) { - RunTest("Imports", "Imports.DesignTime", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(1, 2, 1, 15), - /* 02 */ new GeneratedCodeMapping(2, 2, 1, 32), - /* 03 */ new GeneratedCodeMapping(3, 2, 1, 12), - /* 04 */ new GeneratedCodeMapping(5, 30, 30, 21), - /* 05 */ new GeneratedCodeMapping(6, 36, 36, 20), - }); + return BuildLineMapping(documentAbsoluteIndex, documentLineIndex, characterOffsetIndex, generatedAbsoluteIndex, generatedLineIndex, characterOffsetIndex, contentLength); } - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesFunctionsBlocksAtDesignTime() + private static LineMapping BuildLineMapping(int documentAbsoluteIndex, int documentLineIndex, int documentCharacterOffsetIndex, int generatedAbsoluteIndex, int generatedLineIndex, int generatedCharacterOffsetIndex, int contentLength) { - RunTest("FunctionsBlock", - "FunctionsBlock.DesignTime", - designTimeMode: true, - tabTest: TabTest.NoTabs, - expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(1, 13, 13, 4), - /* 02 */ new GeneratedCodeMapping(5, 13, 13, 104), - /* 03 */ new GeneratedCodeMapping(12, 26, 26, 11) - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesFunctionsBlocksAtDesignTimeTabs() - { - RunTest("FunctionsBlock", - "FunctionsBlock.DesignTime" + ".Tabs", - designTimeMode: true, - tabTest: TabTest.Tabs, - expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(1, 13, 4, 4), - /* 02 */ new GeneratedCodeMapping(5, 13, 4, 104), - /* 03 */ new GeneratedCodeMapping(12, 26, 14, 11) - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesMinimalFunctionsBlocksAtDesignTimeTabs() - { - RunTest("FunctionsBlockMinimal", - "FunctionsBlockMinimal.DesignTime" + ".Tabs", - designTimeMode: true, - tabTest: TabTest.Tabs, - expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(3, 13, 7, 55), - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesHiddenSpansWithinCode() - { - RunTest("HiddenSpansInCode", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List - { - /* 01 */ new GeneratedCodeMapping(1, 3, 3, 6), - /* 02 */ new GeneratedCodeMapping(2, 6, 6, 5) - }); - } - - [Fact] - public void CSharpCodeGeneratorGeneratesCodeWithParserErrorsInDesignTimeMode() - { - RunTest("ParserError", designTimeMode: true, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(1, 3, 3, 31) - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesInheritsAtRuntime() - { - RunTest("Inherits", baselineName: "Inherits.Runtime"); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesInheritsAtDesigntime() - { - RunTest("Inherits", baselineName: "Inherits.Designtime", designTimeMode: true, tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(1, 2, 7, 5), - /* 02 */ new GeneratedCodeMapping(3, 11, 11, 25), - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForUnfinishedExpressionsInCode() - { - RunTest("UnfinishedExpressionInCode", tabTest: TabTest.NoTabs, designTimeMode: true, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(1, 3, 3, 2), - /* 02 */ new GeneratedCodeMapping(2, 2, 7, 9), - /* 03 */ new GeneratedCodeMapping(2, 11, 11, 2) - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForUnfinishedExpressionsInCodeTabs() - { - RunTest("UnfinishedExpressionInCode", - "UnfinishedExpressionInCode.Tabs", - tabTest: TabTest.Tabs, - designTimeMode: true, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(1, 3, 3, 2), - /* 02 */ new GeneratedCodeMapping(2, 2, 7, 9), - /* 03 */ new GeneratedCodeMapping(2, 11, 5, 2) - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasMarkupAndExpressions() - { - RunTest("DesignTime", - designTimeMode: true, - tabTest: TabTest.NoTabs, - expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(2, 14, 13, 36), - /* 02 */ new GeneratedCodeMapping(3, 23, 23, 1), - /* 03 */ new GeneratedCodeMapping(3, 28, 28, 15), - /* 04 */ new GeneratedCodeMapping(8, 3, 7, 12), - /* 05 */ new GeneratedCodeMapping(9, 2, 7, 4), - /* 06 */ new GeneratedCodeMapping(9, 15, 15, 3), - /* 07 */ new GeneratedCodeMapping(9, 26, 26, 1), - /* 08 */ new GeneratedCodeMapping(14, 6, 7, 3), - /* 09 */ new GeneratedCodeMapping(17, 9, 24, 7), - /* 10 */ new GeneratedCodeMapping(17, 16, 16, 26), - /* 11 */ new GeneratedCodeMapping(19, 19, 19, 9), - /* 12 */ new GeneratedCodeMapping(21, 1, 1, 1) - }); - } - - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForImplicitExpressionStartedAtEOF() - { - RunTest("ImplicitExpressionAtEOF", designTimeMode: true, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(3, 2, 7, 0) - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForExplicitExpressionStartedAtEOF() - { - RunTest("ExplicitExpressionAtEOF", designTimeMode: true, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(3, 3, 7, 0) - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForCodeBlockStartedAtEOF() - { - RunTest("CodeBlockAtEOF", designTimeMode: true, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(1, 3, 3, 0) - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyImplicitExpression() - { - RunTest("EmptyImplicitExpression", designTimeMode: true, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(3, 2, 7, 0) - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyImplicitExpressionInCode() - { - RunTest("EmptyImplicitExpressionInCode", tabTest: TabTest.NoTabs, designTimeMode: true, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(1, 3, 3, 6), - /* 02 */ new GeneratedCodeMapping(2, 6, 7, 0), - /* 03 */ new GeneratedCodeMapping(2, 6, 6, 2) - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyImplicitExpressionInCodeTabs() - { - RunTest("EmptyImplicitExpressionInCode", - "EmptyImplicitExpressionInCode.Tabs", - tabTest: TabTest.Tabs, - designTimeMode: true, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(1, 3, 3, 6), - /* 02 */ new GeneratedCodeMapping(2, 6, 7, 0), - /* 03 */ new GeneratedCodeMapping(2, 6, 3, 2) - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyExplicitExpression() - { - RunTest("EmptyExplicitExpression", designTimeMode: true, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(3, 3, 7, 0) - }); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasForEmptyCodeBlock() - { - RunTest("EmptyCodeBlock", designTimeMode: true, expectedDesignTimePragmas: new List() - { - /* 01 */ new GeneratedCodeMapping(3, 3, 3, 0) - }); - } - - [Fact] - public void CSharpCodeGeneratorDoesNotRenderLinePragmasIfGenerateLinePragmasIsSetToFalse() - { - RunTest("NoLinePragmas", generatePragmas: false); - } - - [Fact] - public void CSharpCodeGeneratorRendersHelpersBlockCorrectlyWhenInstanceHelperRequested() - { - RunTest("Helpers", baselineName: "Helpers.Instance", hostConfig: h => h.StaticHelpers = false); - } - - [Fact] - public void CSharpCodeGeneratorCorrectlyInstrumentsRazorCodeWhenInstrumentationRequested() - { - RunTest("Instrumented", hostConfig: host => - { - host.EnableInstrumentation = true; - host.InstrumentedSourceFilePath = String.Format("~/{0}.cshtml", host.DefaultClassName); - }); - } - - [Fact] - public void CSharpCodeGeneratorGeneratesUrlsCorrectlyWithCommentsAndQuotes() - { - RunTest("HtmlCommentWithQuote_Single", - tabTest: TabTest.NoTabs); - - RunTest("HtmlCommentWithQuote_Double", - tabTest: TabTest.NoTabs); - + return new LineMapping( + documentLocation: new MappingLocation(new SourceLocation(documentAbsoluteIndex, documentLineIndex, documentCharacterOffsetIndex), contentLength), + generatedLocation: new MappingLocation(new SourceLocation(generatedAbsoluteIndex, generatedLineIndex, generatedCharacterOffsetIndex), contentLength) + ); } } } diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpCodeBuilderTests.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpCodeBuilderTests.cs index a5fd717cd1..378337aae3 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpCodeBuilderTests.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpCodeBuilderTests.cs @@ -22,18 +22,19 @@ namespace Microsoft.AspNet.Razor.Test.Generator.CodeTree // Act CodeBuilderResult result = codeBuilder.Build(); - // Assert Assert.Equal(@"namespace TestNamespace { #line 1 """" -using FakeNamespace1; +using FakeNamespace1 #line default #line hidden + ; #line 1 """" -using FakeNamespace2.SubNamespace; +using FakeNamespace2.SubNamespace #line default #line hidden + ; public class TestClass { diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpPaddingBuilderTests.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpPaddingBuilderTests.cs index 520b9e6e38..5981c9e81f 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpPaddingBuilderTests.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpPaddingBuilderTests.cs @@ -6,7 +6,7 @@ using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.TestCommon; -namespace Microsoft.AspNet.Razor.Test.Generator.CodeTree +namespace Microsoft.AspNet.Razor.Test.Generator { public class CSharpPaddingBuilderTests { @@ -179,22 +179,6 @@ namespace Microsoft.AspNet.Razor.Test.Generator.CodeTree Assert.Equal(expectedPadding, padding); Assert.Equal(numTabs + numSpaces + code.Length, padded.Length); - - if (numTabs > 0 || numSpaces > 0) - { - Assert.True(padded.Length > numTabs + numSpaces, "padded string too short"); - } - - for (int i = 0; i < numTabs; i++) - { - Assert.Equal('\t', padded[i]); - } - - for (int i = numTabs; i < numTabs + numSpaces; i++) - { - Assert.Equal(' ', padded[i]); - } - Assert.Equal(numSpaces + numTabs, padding.Length); } diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CodeTreeGenerationTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CodeTreeGenerationTest.cs index 7298a79c51..0f9ca17574 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CodeTreeGenerationTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CodeTreeGenerationTest.cs @@ -1,6 +1,10 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. +using System; +using System.CodeDom.Compiler; using System.IO; +using System.Text; +using Microsoft.CSharp; using Microsoft.TestCommon; namespace Microsoft.AspNet.Razor.Test.Generator @@ -10,11 +14,19 @@ namespace Microsoft.AspNet.Razor.Test.Generator [Fact] public void CodeTreeComparisonTest() { - RunTest("CodeTree", onResults: (results, codDOMOutput) => + RunTest("CodeTree", onResults: (results) => { - CodeTreeOutputValidator.ValidateResults(results.GeneratedCode, codDOMOutput, results.DesignTimeLineMappings, results.OLDDesignTimeLineMappings); - File.WriteAllText("./testfile_ct.cs", results.GeneratedCode); - File.WriteAllText("./testfile_cd.cs", codDOMOutput); + CodeDomProvider codeProvider = (CodeDomProvider)Activator.CreateInstance(typeof(CSharpCodeProvider)); + + CodeGeneratorOptions options = new CodeGeneratorOptions(); + var output = new StringBuilder(); + using (var writer = new StringWriter(output)) + { + codeProvider.GenerateCodeFromCompileUnit(results.CCU, writer, options); + } + string codeDOMOutput = output.ToString(); + + CodeTreeOutputValidator.ValidateResults(results.GeneratedCode, codeDOMOutput, results.DesignTimeLineMappings, results.OLDDesignTimeLineMappings); }, designTimeMode: true); } } diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/GeneratedCodeMappingTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/GeneratedCodeMappingTest.cs deleted file mode 100644 index e9c85f661a..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/Generator/GeneratedCodeMappingTest.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. - -using Microsoft.AspNet.Razor.Generator; -using Microsoft.TestCommon; - -namespace Microsoft.AspNet.Razor.Test.Generator -{ - public class GeneratedCodeMappingTest - { - [Fact] - public void GeneratedCodeMappingsAreEqualIfDataIsEqual() - { - GeneratedCodeMapping left = new GeneratedCodeMapping(12, 34, 56, 78); - GeneratedCodeMapping right = new GeneratedCodeMapping(12, 34, 56, 78); - Assert.True(left == right); - Assert.True(left.Equals(right)); - Assert.True(right.Equals(left)); - Assert.True(Equals(left, right)); - } - - [Fact] - public void GeneratedCodeMappingsAreNotEqualIfCodeLengthIsNotEqual() - { - GeneratedCodeMapping left = new GeneratedCodeMapping(12, 34, 56, 87); - GeneratedCodeMapping right = new GeneratedCodeMapping(12, 34, 56, 78); - Assert.False(left == right); - Assert.False(left.Equals(right)); - Assert.False(right.Equals(left)); - Assert.False(Equals(left, right)); - } - - [Fact] - public void GeneratedCodeMappingsAreNotEqualIfStartGeneratedColumnIsNotEqual() - { - GeneratedCodeMapping left = new GeneratedCodeMapping(12, 34, 56, 87); - GeneratedCodeMapping right = new GeneratedCodeMapping(12, 34, 65, 87); - Assert.False(left == right); - Assert.False(left.Equals(right)); - Assert.False(right.Equals(left)); - Assert.False(Equals(left, right)); - } - - [Fact] - public void GeneratedCodeMappingsAreNotEqualIfStartColumnIsNotEqual() - { - GeneratedCodeMapping left = new GeneratedCodeMapping(12, 34, 56, 87); - GeneratedCodeMapping right = new GeneratedCodeMapping(12, 43, 56, 87); - Assert.False(left == right); - Assert.False(left.Equals(right)); - Assert.False(right.Equals(left)); - Assert.False(Equals(left, right)); - } - - [Fact] - public void GeneratedCodeMappingsAreNotEqualIfStartLineIsNotEqual() - { - GeneratedCodeMapping left = new GeneratedCodeMapping(12, 34, 56, 87); - GeneratedCodeMapping right = new GeneratedCodeMapping(21, 34, 56, 87); - Assert.False(left == right); - Assert.False(left.Equals(right)); - Assert.False(right.Equals(left)); - Assert.False(Equals(left, right)); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/LineMappingTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/LineMappingTest.cs new file mode 100644 index 0000000000..bb9e8ec32f --- /dev/null +++ b/test/Microsoft.AspNet.Razor.Test/Generator/LineMappingTest.cs @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. + +using Microsoft.AspNet.Razor.Generator; +using Microsoft.AspNet.Razor.Generator.Compiler; +using Microsoft.AspNet.Razor.Text; +using Microsoft.TestCommon; + +namespace Microsoft.AspNet.Razor.Test.Generator +{ + public class LineMappingTest + { + [Fact] + public void GeneratedCodeMappingsAreEqualIfDataIsEqual() + { + // Arrange + var left = new LineMapping( + new MappingLocation(new SourceLocation(1, 2, 3), 4), + new MappingLocation(new SourceLocation(5, 6, 7), 8) + ); + var right = new LineMapping( + new MappingLocation(new SourceLocation(1, 2, 3), 4), + new MappingLocation(new SourceLocation(5, 6, 7), 8) + ); + + // Assert + Assert.True(left == right); + Assert.True(left.Equals(right)); + Assert.True(right.Equals(left)); + Assert.True(Equals(left, right)); + } + + [Fact] + public void GeneratedCodeMappingsAreNotEqualIfCodeLengthIsNotEqual() + { + // Arrange + var left = new LineMapping( + new MappingLocation(new SourceLocation(1, 2, 3), 4), + new MappingLocation(new SourceLocation(5, 6, 7), 8) + ); + var right = new LineMapping( + new MappingLocation(new SourceLocation(1, 2, 3), 5), + new MappingLocation(new SourceLocation(5, 6, 7), 9) + ); + + // Assert + AssertNotEqual(left, right); + } + + [Fact] + public void GeneratedCodeMappingsAreNotEqualIfStartGeneratedColumnIsNotEqual() + { + // Arrange + var left = new LineMapping( + new MappingLocation(new SourceLocation(1, 2, 3), 4), + new MappingLocation(new SourceLocation(5, 6, 7), 8) + ); + var right = new LineMapping( + new MappingLocation(new SourceLocation(1, 2, 3), 4), + new MappingLocation(new SourceLocation(5, 6, 8), 8) + ); + + // Assert + AssertNotEqual(left, right); + } + + [Fact] + public void GeneratedCodeMappingsAreNotEqualIfStartColumnIsNotEqual() + { + // Arrange + var left = new LineMapping( + new MappingLocation(new SourceLocation(1, 2, 3), 4), + new MappingLocation(new SourceLocation(5, 6, 8), 8) + ); + var right = new LineMapping( + new MappingLocation(new SourceLocation(1, 2, 3), 4), + new MappingLocation(new SourceLocation(5, 6, 7), 8) + ); + + // Assert + AssertNotEqual(left, right); + } + + [Fact] + public void GeneratedCodeMappingsAreNotEqualIfStartLineIsNotEqual() + { + // Arrange + var left = new LineMapping( + new MappingLocation(new SourceLocation(1, 2, 3), 4), + new MappingLocation(new SourceLocation(5, 5, 7), 8) + ); + var right = new LineMapping( + new MappingLocation(new SourceLocation(1, 1, 3), 4), + new MappingLocation(new SourceLocation(5, 6, 7), 8) + ); + + // Assert + AssertNotEqual(left, right); + } + + [Fact] + public void GeneratedCodeMappingsAreNotEqualIfAbsoluteIndexIsNotEqual() + { + // Arrange + var left = new LineMapping( + new MappingLocation(new SourceLocation(1, 2, 3), 4), + new MappingLocation(new SourceLocation(4, 6, 7), 8) + ); + var right = new LineMapping( + new MappingLocation(new SourceLocation(1, 2, 3), 4), + new MappingLocation(new SourceLocation(5, 6, 7), 9) + ); + + // Assert + AssertNotEqual(left, right); + } + + private void AssertNotEqual(LineMapping left, LineMapping right) + { + Assert.False(left == right); + Assert.False(left.Equals(right)); + Assert.False(right.Equals(left)); + Assert.False(Equals(left, right)); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/PaddingTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/PaddingTest.cs deleted file mode 100644 index 8c8b208ac2..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/Generator/PaddingTest.cs +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. - -using System.IO; -using System.Linq; -using Microsoft.AspNet.Razor.Generator; -using Microsoft.AspNet.Razor.Parser; -using Microsoft.AspNet.Razor.Parser.SyntaxTree; -using Microsoft.TestCommon; - -namespace Microsoft.AspNet.Razor.Test.Generator -{ - public class PaddingTest - { - [Fact] - public void CalculatePaddingForEmptySpanReturnsZero() - { - RazorEngineHost host = CreateHost(designTime: true); - - Span span = new Span(new SpanBuilder()); - - int padding = CodeGeneratorPaddingHelper.CalculatePadding(host, span, 0); - - Assert.Equal(0, padding); - } - - [Theory] - [InlineData(true, false, 4)] - [InlineData(true, false, 2)] - [InlineData(false, true, 4)] - [InlineData(false, true, 2)] - [InlineData(false, false, 4)] - [InlineData(false, false, 2)] - [InlineData(true, true, 4)] - [InlineData(true, true, 2)] - [InlineData(true, true, 1)] - [InlineData(true, true, 0)] - public void CalculatePaddingForEmptySpanWith4Spaces(bool designTime, bool isIndentingWithTabs, int tabSize) - { - RazorEngineHost host = CreateHost(designTime: designTime, isIndentingWithTabs: isIndentingWithTabs, tabSize: tabSize); - - Span span = GenerateSpan(@" @{", SpanKind.Code, 3, ""); - - int padding = CodeGeneratorPaddingHelper.CalculatePadding(host, span, 0); - - Assert.Equal(6, padding); - } - - [Theory] - [InlineData(true, false, 4)] - [InlineData(true, false, 2)] - [InlineData(false, true, 4)] - [InlineData(false, true, 2)] - [InlineData(false, false, 4)] - [InlineData(false, false, 2)] - [InlineData(true, true, 4)] - [InlineData(true, true, 2)] - [InlineData(true, true, 1)] - [InlineData(true, true, 0)] - public void CalculatePaddingForIfSpanWith4Spaces(bool designTime, bool isIndentingWithTabs, int tabSize) - { - RazorEngineHost host = CreateHost(designTime: designTime, isIndentingWithTabs: isIndentingWithTabs, tabSize: tabSize); - - Span span = GenerateSpan(@" @if (true)", SpanKind.Code, 2, "if (true)"); - - int padding = CodeGeneratorPaddingHelper.CalculatePadding(host, span, 1); - - Assert.Equal(4, padding); - } - - [Theory] - [InlineData(true, false, 4, 0, 4)] - [InlineData(true, false, 2, 0, 4)] - [InlineData(true, true, 4, 1, 0)] - [InlineData(true, true, 2, 2, 0)] - [InlineData(true, true, 1, 4, 0)] - [InlineData(true, true, 0, 4, 0)] - [InlineData(true, true, 3, 1, 1)] - - // in non design time mode padding falls back to spaces to keep runtime code identical to v2 code. - [InlineData(false, true, 4, 0, 5)] - [InlineData(false, true, 2, 0, 5)] - - [InlineData(false, false, 4, 0, 5)] - [InlineData(false, false, 2, 0, 5)] - public void VerifyPaddingForIfSpanWith4Spaces(bool designTime, bool isIndentingWithTabs, int tabSize, int numTabs, int numSpaces) - { - RazorEngineHost host = CreateHost(designTime: designTime, isIndentingWithTabs: isIndentingWithTabs, tabSize: tabSize); - - // no new lines involved - Span span = GenerateSpan(" @if (true)", SpanKind.Code, 2, "if (true)"); - - int generatedStart = 1; - string code = " if (true)"; - int paddingCharCount; - - string padded = CodeGeneratorPaddingHelper.PadStatement(host, code, span, ref generatedStart, out paddingCharCount); - - VerifyPadded(numTabs, numSpaces, code, padded, paddingCharCount); - - // with new lines involved - Span newLineSpan = GenerateSpan("\t
\r\n @if (true)", SpanKind.Code, 3, "if (true)"); - - string newLinePadded = CodeGeneratorPaddingHelper.PadStatement(host, code, span, ref generatedStart, out paddingCharCount); - - VerifyPadded(numTabs, numSpaces, code, newLinePadded, paddingCharCount); - } - - [Theory] - [InlineData(true, false, 4, 0, 8)] - [InlineData(true, false, 2, 0, 4)] - [InlineData(true, true, 4, 2, 0)] - [InlineData(true, true, 2, 2, 0)] - [InlineData(true, true, 1, 2, 0)] - [InlineData(true, true, 0, 2, 0)] - [InlineData(true, true, 3, 2, 0)] - - // in non design time mode padding falls back to spaces to keep runtime code identical to v2 code. - [InlineData(false, true, 4, 0, 9)] - [InlineData(false, true, 2, 0, 5)] - - [InlineData(false, false, 4, 0, 9)] - [InlineData(false, false, 2, 0, 5)] - public void VerifyPaddingForIfSpanWithTwoTabs(bool designTime, bool isIndentingWithTabs, int tabSize, int numTabs, int numSpaces) - { - RazorEngineHost host = CreateHost(designTime: designTime, isIndentingWithTabs: isIndentingWithTabs, tabSize: tabSize); - - // no new lines involved - Span span = GenerateSpan("\t\t@if (true)", SpanKind.Code, 2, "if (true)"); - - int generatedStart = 1; - string code = " if (true)"; - int paddingCharCount; - - string padded = CodeGeneratorPaddingHelper.PadStatement(host, code, span, ref generatedStart, out paddingCharCount); - - VerifyPadded(numTabs, numSpaces, code, padded, paddingCharCount); - - // with new lines involved - Span newLineSpan = GenerateSpan("\t
\r\n\t\t@if (true)", SpanKind.Code, 3, "if (true)"); - - string newLinePadded = CodeGeneratorPaddingHelper.PadStatement(host, code, span, ref generatedStart, out paddingCharCount); - - VerifyPadded(numTabs, numSpaces, code, newLinePadded, paddingCharCount); - } - - [Theory] - [InlineData(true, false, 4, 0, 8)] - [InlineData(true, false, 2, 0, 4)] - [InlineData(true, true, 4, 2, 0)] - [InlineData(true, true, 2, 2, 0)] - [InlineData(true, true, 1, 2, 0)] - [InlineData(true, true, 0, 2, 0)] - - // in non design time mode padding falls back to spaces to keep runtime code identical to v2 code. - [InlineData(false, true, 4, 0, 9)] - [InlineData(false, true, 2, 0, 5)] - - [InlineData(false, false, 4, 0, 9)] - [InlineData(false, false, 2, 0, 5)] - public void CalculatePaddingForOpenedIf(bool designTime, bool isIndentingWithTabs, int tabSize, int numTabs, int numSpaces) - { - RazorEngineHost host = CreateHost(designTime: designTime, isIndentingWithTabs: isIndentingWithTabs, tabSize: tabSize); - - string text = "\r\n\r\n\r\n\t\t@if (true) { \r\n\r\n"; - - Span span = GenerateSpan(text, SpanKind.Code, 3, "if (true) { \r\n"); - - int generatedStart = 1; - string code = " if (true) { \r\n"; - int paddingCharCount; - string padded = CodeGeneratorPaddingHelper.PadStatement(host, code, span, ref generatedStart, out paddingCharCount); - - VerifyPadded(numTabs, numSpaces, code, padded, paddingCharCount); - } - - private static void VerifyPadded(int numTabs, int numSpaces, string code, string padded, int paddingCharCount) - { - Assert.Equal(numTabs + numSpaces + code.Length, padded.Length); - - if (numTabs > 0 || numSpaces > 0) - { - Assert.True(padded.Length > numTabs + numSpaces, "padded string too short"); - } - - for (int i = 0; i < numTabs; i++) - { - Assert.Equal('\t', padded[i]); - } - - for (int i = numTabs; i < numTabs + numSpaces; i++) - { - Assert.Equal(' ', padded[i]); - } - - Assert.Equal(numSpaces + numTabs, paddingCharCount); - } - - private static RazorEngineHost CreateHost(bool designTime, bool isIndentingWithTabs = false, int tabSize = 4) - { - return new RazorEngineHost(new CSharpRazorCodeLanguage()) - { - DesignTimeMode = designTime, - IsIndentingWithTabs = isIndentingWithTabs, - TabSize = tabSize, - }; - } - - private static Span GenerateSpan(string text, SpanKind spanKind, int spanIndex, string spanText) - { - Span[] spans = GenerateSpans(text, spanKind, spanIndex, spanText); - - return spans[spanIndex]; - } - - private static Span[] GenerateSpans(string text, SpanKind spanKind, int spanIndex, string spanText) - { - Assert.True(spanIndex > 0); - - RazorParser parser = new RazorParser(new CSharpCodeParser(), new HtmlMarkupParser()); - - Span[] spans; - - using (var reader = new StringReader(text)) - { - ParserResults results = parser.Parse(reader); - spans = results.Document.Flatten().ToArray(); - } - - Assert.True(spans.Length > spanIndex); - Assert.Equal(spanKind, spans[spanIndex].Kind); - Assert.Equal(spanText, spans[spanIndex].Content); - - return spans; - } - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/RazorCodeGeneratorTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/RazorCodeGeneratorTest.cs index 580a02918b..54a4d72e26 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/RazorCodeGeneratorTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/RazorCodeGeneratorTest.cs @@ -3,8 +3,6 @@ //#define GENERATE_BASELINES using System; -using System.CodeDom; -using System.CodeDom.Compiler; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -12,6 +10,7 @@ using System.Linq; using System.Text; using System.Web.WebPages.TestUtils; using Microsoft.AspNet.Razor.Generator; +using Microsoft.AspNet.Razor.Generator.Compiler; using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Test.Utils; using Microsoft.TestCommon; @@ -36,11 +35,11 @@ namespace Microsoft.AspNet.Razor.Test.Generator string baselineName = null, bool generatePragmas = true, bool designTimeMode = false, - IList expectedDesignTimePragmas = null, + IList expectedDesignTimePragmas = null, TestSpan[] spans = null, TabTest tabTest = TabTest.Both, Action hostConfig = null, - Action onResults = null) + Action onResults = null) { bool testRun = false; @@ -91,11 +90,11 @@ namespace Microsoft.AspNet.Razor.Test.Generator string baselineName, bool generatePragmas, bool designTimeMode, - IList expectedDesignTimePragmas, + IList expectedDesignTimePragmas, TestSpan[] spans, bool withTabs, Action hostConfig, - Action onResults = null) + Action onResults = null) { // Load the test files if (baselineName == null) @@ -142,40 +141,22 @@ namespace Microsoft.AspNet.Razor.Test.Generator using (StringTextBuffer buffer = new StringTextBuffer(source)) { results = engine.GenerateCode(buffer, className: name, rootNamespace: TestRootNamespaceName, sourceFileName: generatePragmas ? String.Format("{0}.{1}", name, FileExtension) : null); - } - - // Generate code - CodeCompileUnit ccu = results.CCU; - CodeDomProvider codeProvider = (CodeDomProvider)Activator.CreateInstance(host.CodeLanguage.CodeDomProviderType); - - CodeGeneratorOptions options = new CodeGeneratorOptions(); - - // Both run-time and design-time use these settings. See: - // * $/Dev10/pu/SP_WebTools/venus/html/Razor/Impl/RazorCodeGenerator.cs:204 - // * $/Dev10/Releases/RTMRel/ndp/fx/src/xsp/System/Web/Compilation/BuildManagerHost.cs:373 - options.BlankLinesBetweenMembers = false; - options.IndentString = String.Empty; - - StringBuilder output = new StringBuilder(); - using (StringWriter writer = new StringWriter(output)) - { - codeProvider.GenerateCodeFromCompileUnit(ccu, writer, options); } - WriteBaseline(String.Format(@"test\Microsoft.AspNet.Razor.Test\TestFiles\CodeGenerator\{0}\Output\{1}.{2}", LanguageName, baselineName, BaselineExtension), MiscUtils.StripRuntimeVersion(output.ToString())); + // Only called if GENERATE_BASELINES is set, otherwise compiled out. + WriteBaseline(String.Format(@"test\Microsoft.AspNet.Razor.Test\TestFiles\CodeGenerator\{0}\Output\{1}.{2}", LanguageName, baselineName, BaselineExtension), results.GeneratedCode); #if !GENERATE_BASELINES - string textOutput = MiscUtils.StripRuntimeVersion(output.ToString()); + string textOutput = results.GeneratedCode; if (onResults != null) { - onResults(results, textOutput); + onResults(results); } //// Verify code against baseline Assert.Equal(expectedOutput, textOutput); - -#endif +#endif IEnumerable generatedSpans = results.Document.Flatten(); @@ -197,13 +178,14 @@ namespace Microsoft.AspNet.Razor.Test.Generator Assert.True(results.DesignTimeLineMappings != null && results.DesignTimeLineMappings.Count > 0); Assert.Equal(expectedDesignTimePragmas.Count, results.DesignTimeLineMappings.Count); -/* - Assert.Equal( - expectedDesignTimePragmas.ToArray(), - results.DesignTimeLineMappings - .OrderBy(p => p.Key) - .Select(p => p.Value) - .ToArray());*/ + + for (var i = 0; i < expectedDesignTimePragmas.Count; i++) + { + if(!expectedDesignTimePragmas[i].Equals(results.DesignTimeLineMappings[i])) + { + Assert.True(false, String.Format("Line mapping {0} is not equivalent.", i)); + } + } } } } @@ -211,7 +193,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator [Conditional("GENERATE_BASELINES")] private void WriteBaseline(string baselineFile, string output) { - string root = RecursiveFind("Runtime.sln", Path.GetFullPath(".")); + string root = RecursiveFind("Razor.sln", Path.GetFullPath(".")); string baselinePath = Path.Combine(root, baselineFile); // Update baseline diff --git a/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.csproj b/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.csproj index 5b55bdbe8a..067368b114 100644 --- a/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.csproj +++ b/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.csproj @@ -38,7 +38,25 @@ - + + {8b129ff9-0b8f-4e0c-8dfc-0137d8550fb7} + Microsoft.AspNet.Razor.net45 + + + {FCCC4CB7-BAF7-4A57-9F89-E5766FE536C0} + Microsoft.TestCommon + + + + + + + + + + + + @@ -53,200 +71,135 @@ - - + + + + + + + + + + + + + - - Code - - - Code - + + - - Code - - - + + + + - + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - Code - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - {8b129ff9-0b8f-4e0c-8dfc-0137d8550fb7} - Microsoft.AspNet.Razor.net45 - - - {FCCC4CB7-BAF7-4A57-9F89-E5766FE536C0} - Microsoft.TestCommon - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + @@ -257,6 +210,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -267,41 +313,11 @@ - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpBlockTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpBlockTest.cs index 9eacb07206..a40249cf83 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpBlockTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpBlockTest.cs @@ -44,8 +44,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp ), Factory.Code(" }").AsStatement()), new RazorError( - RazorResources.ParseError_Unexpected_Keyword_After_At( - "if"), + RazorResources.ParseError_Unexpected_Keyword_After_At("if"), new SourceLocation(13, 0, 13))); } @@ -107,8 +106,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp ImplicitExpressionTest("Html.En(code()", "Html.En(code()", AcceptedCharacters.Any, new RazorError( - RazorResources.ParseError_Expected_CloseBracket_Before_EOF( - "(", ")"), + RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"), new SourceLocation(8, 0, 8))); } @@ -397,7 +395,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC { const string document = "foreach(var f in Foo) { /* foo bar baz"; SingleSpanBlockTest(document, document, BlockType.Statement, SpanKind.Code, - new RazorError(String.Format(RazorResources.ParseError_BlockComment_Not_Terminated), 24, 0, 24), + new RazorError(RazorResources.ParseError_BlockComment_Not_Terminated, 24, 0, 24), new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), SourceLocation.Zero)); } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpErrorTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpErrorTest.cs index 6956c7fdbd..b25570d910 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpErrorTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpErrorTest.cs @@ -47,9 +47,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }) ), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - RazorResources.BlockName_Code, - "}", "{"), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"), SourceLocation.Zero)); } @@ -141,8 +139,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("foo bar\r\nbaz").AsExpression() ), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - RazorResources.BlockName_ExplicitExpression, ')', '('), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_ExplicitExpression, ')', '('), new SourceLocation(0, 0, 0))); } @@ -158,8 +155,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("foo bar\r\n").AsExpression() ), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - RazorResources.BlockName_ExplicitExpression, ')', '('), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_ExplicitExpression, ')', '('), new SourceLocation(0, 0, 0))); } @@ -173,8 +169,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), new RazorError( - RazorResources.ParseError_Expected_CloseBracket_Before_EOF( - "(", ")"), + RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"), new SourceLocation(4, 0, 4))); } @@ -189,8 +184,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("Foo(Bar(Baz)\r\nBiz\r\nBoz") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), - new RazorError(RazorResources.ParseError_Expected_CloseBracket_Before_EOF( - "(", ")"), + new RazorError(RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"), new SourceLocation(3, 0, 3))); } @@ -207,8 +201,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("Foo(Bar(Baz)\r\nBiz\r\n") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), - new RazorError(RazorResources.ParseError_Expected_CloseBracket_Before_EOF( - "(", ")"), + new RazorError(RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"), new SourceLocation(3, 0, 3))); } @@ -224,8 +217,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), new RazorError( - RazorResources.ParseError_Expected_CloseBracket_Before_EOF( - "[", "]"), + RazorResources.ParseError_Expected_CloseBracket_Before_EOF("[", "]"), new SourceLocation(3, 0, 3))); } @@ -243,8 +235,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), new RazorError( - RazorResources.ParseError_Expected_CloseBracket_Before_EOF( - "[", "]"), + RazorResources.ParseError_Expected_CloseBracket_Before_EOF("[", "]"), new SourceLocation(3, 0, 3))); } @@ -258,8 +249,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code(" var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - RazorResources.BlockName_Code, '}', '{'), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, '}', '{'), SourceLocation.Zero)); } @@ -272,8 +262,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code(" var foo = bar; if(foo != null) { bar(); } ").AsFunctionsBody() ), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - "functions", '}', '{'), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("functions", '}', '{'), SourceLocation.Zero)); } @@ -291,8 +280,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - "else", '}', '{'), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("else", '}', '{'), new SourceLocation(19, 0, 19))); } @@ -304,8 +292,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - "else if", '}', '{'), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("else if", '}', '{'), new SourceLocation(19, 0, 19))); } @@ -317,8 +304,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("do { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - "do", '}', '{'), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("do", '}', '{'), SourceLocation.Zero)); } @@ -330,8 +316,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("try { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - "try", '}', '{'), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("try", '}', '{'), SourceLocation.Zero)); } @@ -343,8 +328,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - "catch", '}', '{'), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("catch", '}', '{'), new SourceLocation(15, 0, 15))); } @@ -356,8 +340,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - "finally", '}', '{'), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("finally", '}', '{'), new SourceLocation(15, 0, 15))); } @@ -430,8 +413,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("if(foo)) { var bar = foo; }").AsStatement() ), new RazorError( - RazorResources.ParseError_SingleLine_ControlFlowStatements_Not_Allowed( - "{", ")"), + RazorResources.ParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", ")"), new SourceLocation(7, 0, 7))); } @@ -462,8 +444,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("if(foo bar\r\n").AsStatement() ), new RazorError( - RazorResources.ParseError_Expected_CloseBracket_Before_EOF( - "(", ")"), + RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"), new SourceLocation(2, 0, 2))); } @@ -476,8 +457,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("foreach(foo bar\r\n").AsStatement() ), new RazorError( - RazorResources.ParseError_Expected_CloseBracket_Before_EOF( - "(", ")"), + RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"), new SourceLocation(7, 0, 7))); } @@ -490,8 +470,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("do { } while(foo bar\r\n").AsStatement() ), new RazorError( - RazorResources.ParseError_Expected_CloseBracket_Before_EOF( - "(", ")"), + RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"), new SourceLocation(12, 0, 12))); } @@ -504,8 +483,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("using(foo bar\r\n").AsStatement() ), new RazorError( - RazorResources.ParseError_Expected_CloseBracket_Before_EOF( - "(", ")"), + RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"), new SourceLocation(5, 0, 5))); } @@ -522,8 +500,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code("}").AsStatement().Accepts(AcceptedCharacters.None) ), new RazorError( - RazorResources.ParseError_Expected_CloseBracket_Before_EOF( - "(", ")"), + RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"), new SourceLocation(2, 0, 2))); } @@ -608,7 +585,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.MetaCode("}").Accepts(AcceptedCharacters.None)), expectedErrors: new[] { new RazorError( - RazorResources.ParseError_Expected_CloseBracket_Before_EOF( "(", ")"), + RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"), 14, 0, 14) }); diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpExplicitExpressionTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpExplicitExpressionTest.cs index 7e4b53a6ac..5f6b82954a 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpExplicitExpressionTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpExplicitExpressionTest.cs @@ -32,9 +32,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.EmptyCSharp().AsExpression() ), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - RazorResources.BlockName_ExplicitExpression, - ")", "("), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_ExplicitExpression, ")", "("), new SourceLocation(1, 0, 1))); } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpHelperTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpHelperTest.cs index f9c229bd6c..24a3234e09 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpHelperTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpHelperTest.cs @@ -52,8 +52,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.MetaCode("}").Accepts(AcceptedCharacters.None)), Factory.EmptyHtml()), new RazorError( - RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start( - RazorResources.ErrorComponent_Newline), + RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_Newline), 7, 0, 7)); } @@ -68,8 +67,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.MetaCode("helper")), Factory.Markup("{")), new RazorError( - RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start( - RazorResources.ErrorComponent_Character("{")), + RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_Character("{")), 7, 0, 7)); } @@ -88,12 +86,10 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp .AsStatement() .AutoCompleteWith("}")))), new RazorError( - RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start( - RazorResources.ErrorComponent_Character("(")), + RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_Character("(")), 8, 0, 8), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - "helper", "}", "{"), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"), 1, 0, 1)); } @@ -108,8 +104,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None), Factory.EmptyCSharp().Hidden())), new RazorError( - RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start( - RazorResources.ErrorComponent_EndOfFile), + RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_EndOfFile), 8, 0, 8)); } @@ -123,8 +118,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.CodeTransition(), Factory.MetaCode("helper").Accepts(AcceptedCharacters.Any))), new RazorError( - RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start( - RazorResources.ErrorComponent_EndOfFile), + RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_EndOfFile), 7, 0, 7)); } @@ -141,8 +135,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Code(" \r\n").Hidden()), Factory.Markup(@" ")), new RazorError( - RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start( - RazorResources.ErrorComponent_Newline), + RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_Newline), 30, 0, 30)); } @@ -214,8 +207,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Markup("

Foo

").Accepts(AcceptedCharacters.None)), Factory.EmptyCSharp().AsStatement()))), new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - "helper", "}", "{"), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"), 1, 0, 1)); } @@ -296,8 +288,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp expectedErrors: new[] { new RazorError( - RazorResources.ParseError_Expected_EndOfBlock_Before_EOF( - "helper", "}", "{"), + RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"), new SourceLocation(1, 0, 1)) }); } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpSectionTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpSectionTest.cs index 125228b4a8..82a19805be 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpSectionTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpSectionTest.cs @@ -21,8 +21,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.CodeTransition(), Factory.MetaCode("section\r\n"))), new RazorError( - RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start( - RazorResources.ErrorComponent_EndOfFile), + RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start(RazorResources.ErrorComponent_EndOfFile), 10, 1, 0)); } @@ -52,8 +51,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.MetaCode("section \r\n")), Factory.Markup(" ")), new RazorError( - RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start( - RazorResources.ErrorComponent_EndOfFile), + RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start(RazorResources.ErrorComponent_EndOfFile), 23, 1, 4)); } @@ -82,8 +80,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.MetaCode("section ")), Factory.Markup("9 {

Foo

}")), new RazorError( - RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start( - RazorResources.ErrorComponent_Character("9")), + RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start(RazorResources.ErrorComponent_Character("9")), 9, 0, 9)); } @@ -99,7 +96,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.Markup("-bar {

Foo

}")), new RazorError(RazorResources.ParseError_MissingOpenBraceAfterSection, 12, 0, 12)); } - + [Fact] public void ParserOutputsErrorOnNestedSections() { @@ -123,8 +120,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp Factory.MetaCode("}").Accepts(AcceptedCharacters.None)), Factory.EmptyHtml()), new RazorError( - RazorResources.ParseError_Sections_Cannot_Be_Nested( - RazorResources.SectionExample_CS), + RazorResources.ParseError_Sections_Cannot_Be_Nested(RazorResources.SectionExample_CS), 23, 0, 23)); } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CsHtmlDocumentTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CsHtmlDocumentTest.cs deleted file mode 100644 index d359952558..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CsHtmlDocumentTest.cs +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNet.Razor.Parser; -using Microsoft.AspNet.Razor.Parser.SyntaxTree; -using Microsoft.AspNet.Razor.Test.Framework; -using Microsoft.AspNet.Razor.Text; -using Microsoft.AspNet.Razor.Tokenizer.Symbols; -using Microsoft.TestCommon; - -namespace Microsoft.AspNet.Razor.Test.Parser.CSharp -{ - public class CsHtmlDocumentTest : CsHtmlMarkupParserTestBase - { - [Fact] - public void UnterminatedBlockCommentCausesRazorError() - { - ParseDocumentTest("@* Foo Bar", - new MarkupBlock( - Factory.EmptyHtml(), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.Comment(" Foo Bar", HtmlSymbolType.RazorComment) - ) - ), - new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, SourceLocation.Zero)); - } - - [Fact] - public void BlockCommentInMarkupDocumentIsHandledCorrectly() - { - ParseDocumentTest("
    " + Environment.NewLine - + " @* This is a block comment
*@ foo", - new MarkupBlock( - Factory.Markup("
    \r\n "), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.Comment(" This is a block comment
", HtmlSymbolType.RazorComment), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - ), - Factory.Markup(" foo") - )); - } - - [Fact] - public void BlockCommentInMarkupBlockIsHandledCorrectly() - { - ParseBlockTest("
    " + Environment.NewLine - + " @* This is a block comment
*@ foo ", - new MarkupBlock( - Factory.Markup("
    \r\n "), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.Comment(" This is a block comment
", HtmlSymbolType.RazorComment), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - ), - Factory.Markup(" foo ").Accepts(AcceptedCharacters.None) - )); - } - - [Fact] - public void BlockCommentAtStatementStartInCodeBlockIsHandledCorrectly() - { - ParseDocumentTest("@if(Request.IsAuthenticated) {" + Environment.NewLine - + " @* User is logged in! } *@" + Environment.NewLine - + " Write(\"Hello friend!\");" + Environment.NewLine - + "}", - new MarkupBlock( - Factory.EmptyHtml(), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(Request.IsAuthenticated) {\r\n ").AsStatement(), - new CommentBlock( - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.Comment(" User is logged in! } ", CSharpSymbolType.RazorComment), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition) - ), - Factory.Code("\r\n Write(\"Hello friend!\");\r\n}").AsStatement()))); - } - - [Fact] - public void BlockCommentInStatementInCodeBlockIsHandledCorrectly() - { - ParseDocumentTest("@if(Request.IsAuthenticated) {" + Environment.NewLine - + " var foo = @* User is logged in! ; *@;" + Environment.NewLine - + " Write(\"Hello friend!\");" + Environment.NewLine - + "}", - new MarkupBlock( - Factory.EmptyHtml(), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(Request.IsAuthenticated) {\r\n var foo = ").AsStatement(), - new CommentBlock( - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.Comment(" User is logged in! ; ", CSharpSymbolType.RazorComment), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition) - ), - Factory.Code(";\r\n Write(\"Hello friend!\");\r\n}").AsStatement()))); - } - - [Fact] - public void BlockCommentInStringIsIgnored() - { - ParseDocumentTest("@if(Request.IsAuthenticated) {" + Environment.NewLine - + " var foo = \"@* User is logged in! ; *\";" + Environment.NewLine - + " Write(\"Hello friend!\");" + Environment.NewLine - + "}", - new MarkupBlock( - Factory.EmptyHtml(), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(Request.IsAuthenticated) {" + Environment.NewLine - + " var foo = \"@* User is logged in! ; *\";" + Environment.NewLine - + " Write(\"Hello friend!\");" + Environment.NewLine - + "}").AsStatement()))); - } - - [Fact] - public void BlockCommentInCSharpBlockCommentIsIgnored() - { - ParseDocumentTest("@if(Request.IsAuthenticated) {" + Environment.NewLine - + " var foo = /*@* User is logged in! */ *@ */;" + Environment.NewLine - + " Write(\"Hello friend!\");" + Environment.NewLine - + "}", - new MarkupBlock( - Factory.EmptyHtml(), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(Request.IsAuthenticated) {" + Environment.NewLine - + " var foo = /*@* User is logged in! */ *@ */;" + Environment.NewLine - + " Write(\"Hello friend!\");" + Environment.NewLine - + "}").AsStatement()))); - } - - [Fact] - public void BlockCommentInCSharpLineCommentIsIgnored() - { - ParseDocumentTest("@if(Request.IsAuthenticated) {" + Environment.NewLine - + " var foo = //@* User is logged in! */ *@;" + Environment.NewLine - + " Write(\"Hello friend!\");" + Environment.NewLine - + "}", - new MarkupBlock( - Factory.EmptyHtml(), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(Request.IsAuthenticated) {" + Environment.NewLine - + " var foo = //@* User is logged in! */ *@;" + Environment.NewLine - + " Write(\"Hello friend!\");" + Environment.NewLine - + "}").AsStatement()))); - } - - [Fact] - public void BlockCommentInImplicitExpressionIsHandledCorrectly() - { - ParseDocumentTest("@Html.Foo@*bar*@", - new MarkupBlock( - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("Html.Foo").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace) - ), - Factory.EmptyHtml(), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.Comment("bar", HtmlSymbolType.RazorComment), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - ), - Factory.EmptyHtml())); - } - - [Fact] - public void BlockCommentAfterDotOfImplicitExpressionIsHandledCorrectly() - { - ParseDocumentTest("@Html.@*bar*@", - new MarkupBlock( - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("Html").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace) - ), - Factory.Markup("."), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.Comment("bar", HtmlSymbolType.RazorComment), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - ), - Factory.EmptyHtml())); - } - - [Fact] - public void BlockCommentInParensOfImplicitExpressionIsHandledCorrectly() - { - ParseDocumentTest("@Html.Foo(@*bar*@ 4)", - new MarkupBlock( - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("Html.Foo(").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.Any), - new CommentBlock( - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.Comment("bar", CSharpSymbolType.RazorComment), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition) - ), - Factory.Code(" 4)").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace) - ), - Factory.EmptyHtml())); - } - - [Fact] - public void BlockCommentInBracketsOfImplicitExpressionIsHandledCorrectly() - { - ParseDocumentTest("@Html.Foo[@*bar*@ 4]", - new MarkupBlock( - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("Html.Foo[").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.Any), - new CommentBlock( - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.Comment("bar", CSharpSymbolType.RazorComment), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition) - ), - Factory.Code(" 4]").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharacters.NonWhiteSpace) - ), - Factory.EmptyHtml())); - } - - [Fact] - public void BlockCommentInParensOfConditionIsHandledCorrectly() - { - ParseDocumentTest("@if(@*bar*@) {}", - new MarkupBlock( - Factory.EmptyHtml(), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(").AsStatement(), - new CommentBlock( - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.Comment("bar", CSharpSymbolType.RazorComment), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition) - ), - Factory.Code(") {}").AsStatement() - ))); - } - - [Fact] - public void BlockCommentInExplicitExpressionIsHandledCorrectly() - { - ParseDocumentTest("@(1 + @*bar*@ 1)", - new MarkupBlock( - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharacters.None), - Factory.Code("1 + ").AsExpression(), - new CommentBlock( - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.Comment("bar", CSharpSymbolType.RazorComment), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharacters.None), - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition) - ), - Factory.Code(" 1").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharacters.None) - ), - Factory.EmptyHtml())); - } - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/RazorCodeLanguageTest.cs b/test/Microsoft.AspNet.Razor.Test/RazorCodeLanguageTest.cs index 48973e428f..9f61b5b655 100644 --- a/test/Microsoft.AspNet.Razor.Test/RazorCodeLanguageTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/RazorCodeLanguageTest.cs @@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Razor.Test public void ServicesPropertyContainsEntriesForCSharpCodeLanguageService() { // Assert - Assert.Equal(2, RazorCodeLanguage.Languages.Count); + Assert.Equal(1, RazorCodeLanguage.Languages.Count); Assert.IsType(RazorCodeLanguage.Languages["cshtml"]); } diff --git a/test/Microsoft.AspNet.Razor.Test/RazorEngineHostTest.cs b/test/Microsoft.AspNet.Razor.Test/RazorEngineHostTest.cs index d122f8a8e9..d9d707b652 100644 --- a/test/Microsoft.AspNet.Razor.Test/RazorEngineHostTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/RazorEngineHostTest.cs @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. -using System.CodeDom; using Microsoft.AspNet.Razor.Generator; using Microsoft.AspNet.Razor.Parser; using Microsoft.TestCommon; @@ -71,46 +70,6 @@ namespace Microsoft.AspNet.Razor.Test Assert.ThrowsArgumentNull(() => CreateHost().DecorateCodeGenerator(null), "incomingCodeGenerator"); } - [Fact] - public void PostProcessGeneratedCodeRequiresNonNullCompileUnit() - { - Assert.ThrowsArgumentNull(() => CreateHost().PostProcessGeneratedCode(codeCompileUnit: null, - generatedNamespace: new CodeNamespace(), - generatedClass: new CodeTypeDeclaration(), - executeMethod: new CodeMemberMethod()), - "codeCompileUnit"); - } - - [Fact] - public void PostProcessGeneratedCodeRequiresNonNullGeneratedNamespace() - { - Assert.ThrowsArgumentNull(() => CreateHost().PostProcessGeneratedCode(codeCompileUnit: new CodeCompileUnit(), - generatedNamespace: null, - generatedClass: new CodeTypeDeclaration(), - executeMethod: new CodeMemberMethod()), - "generatedNamespace"); - } - - [Fact] - public void PostProcessGeneratedCodeRequiresNonNullGeneratedClass() - { - Assert.ThrowsArgumentNull(() => CreateHost().PostProcessGeneratedCode(codeCompileUnit: new CodeCompileUnit(), - generatedNamespace: new CodeNamespace(), - generatedClass: null, - executeMethod: new CodeMemberMethod()), - "generatedClass"); - } - - [Fact] - public void PostProcessGeneratedCodeRequiresNonNullExecuteMethod() - { - Assert.ThrowsArgumentNull(() => CreateHost().PostProcessGeneratedCode(codeCompileUnit: new CodeCompileUnit(), - generatedNamespace: new CodeNamespace(), - generatedClass: new CodeTypeDeclaration(), - executeMethod: null), - "executeMethod"); - } - [Fact] public void DecorateCodeParserDoesNotModifyIncomingParser() { @@ -150,26 +109,6 @@ namespace Microsoft.AspNet.Razor.Test Assert.Same(expected, actual); } - [Fact] - public void PostProcessGeneratedCodeDoesNotModifyCode() - { - // Arrange - CodeCompileUnit compileUnit = new CodeCompileUnit(); - CodeNamespace ns = new CodeNamespace(); - CodeTypeDeclaration typeDecl = new CodeTypeDeclaration(); - CodeMemberMethod execMethod = new CodeMemberMethod(); - - // Act - CreateHost().PostProcessGeneratedCode(compileUnit, ns, typeDecl, execMethod); - - // Assert - Assert.Empty(compileUnit.Namespaces); - Assert.Empty(ns.Imports); - Assert.Empty(ns.Types); - Assert.Empty(typeDecl.Members); - Assert.Empty(execMethod.Statements); - } - private static RazorEngineHost CreateHost() { return new RazorEngineHost(new CSharpRazorCodeLanguage()); diff --git a/test/Microsoft.AspNet.Razor.Test/RazorTemplateEngineTest.cs b/test/Microsoft.AspNet.Razor.Test/RazorTemplateEngineTest.cs index 319125ac86..337c6dcca1 100644 --- a/test/Microsoft.AspNet.Razor.Test/RazorTemplateEngineTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/RazorTemplateEngineTest.cs @@ -167,7 +167,6 @@ namespace Microsoft.AspNet.Razor.Test Assert.Single(results.ParserErrors); Assert.NotNull(results.Document); Assert.NotNull(results.GeneratedCode); - Assert.Null(results.DesignTimeLineMappings); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Blocks.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Blocks.cs index f92286bfa6..ae54f143ba 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Blocks.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Blocks.cs @@ -1,194 +1,138 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class Blocks { -#line hidden -public Blocks() { -} -public override void Execute() { + public class Blocks + { + #line hidden + public Blocks() + { + } + public override void Execute() + { #line 1 "Blocks.cshtml" int i = 1; - - #line default #line hidden -WriteLiteral("\r\n\r\n"); - + WriteLiteral("\r\n\r\n"); #line 5 "Blocks.cshtml" while(i <= 10) { - - #line default #line hidden -WriteLiteral("

Hello from C#, #"); - + WriteLiteral("

Hello from C#, #"); + Write( #line 6 "Blocks.cshtml" - Write(i); - - + i #line default #line hidden -WriteLiteral("

\r\n"); - - + ); + WriteLiteral("

\r\n"); #line 7 "Blocks.cshtml" i += 1; } - - #line default #line hidden -WriteLiteral("\r\n"); - + WriteLiteral("\r\n"); #line 10 "Blocks.cshtml" if(i == 11) { - - #line default #line hidden -WriteLiteral("

We wrote 10 lines!

\r\n"); - + WriteLiteral("

We wrote 10 lines!

\r\n"); #line 12 "Blocks.cshtml" } - - #line default #line hidden -WriteLiteral("\r\n"); - + WriteLiteral("\r\n"); #line 14 "Blocks.cshtml" switch(i) { case 11: - - #line default #line hidden -WriteLiteral("

No really, we wrote 10 lines!

\r\n"); - + WriteLiteral("

No really, we wrote 10 lines!

\r\n"); #line 17 "Blocks.cshtml" break; default: - - #line default #line hidden -WriteLiteral("

Actually, we didn\'t...

\r\n"); - + WriteLiteral("

Actually, we didn\'t...

\r\n"); #line 20 "Blocks.cshtml" break; } - - #line default #line hidden -WriteLiteral("\r\n"); - + WriteLiteral("\r\n"); #line 23 "Blocks.cshtml" for(int j = 1; j <= 10; j += 2) { - - #line default #line hidden -WriteLiteral("

Hello again from C#, #"); - + WriteLiteral("

Hello again from C#, #"); + Write( #line 24 "Blocks.cshtml" - Write(j); - - + j #line default #line hidden -WriteLiteral("

\r\n"); - - + ); + WriteLiteral("

\r\n"); #line 25 "Blocks.cshtml" } - - #line default #line hidden -WriteLiteral("\r\n"); - + WriteLiteral("\r\n"); #line 27 "Blocks.cshtml" try { - - #line default #line hidden -WriteLiteral("

That time, we wrote 5 lines!

\r\n"); - + WriteLiteral("

That time, we wrote 5 lines!

\r\n"); #line 29 "Blocks.cshtml" } catch(Exception ex) { - - #line default #line hidden -WriteLiteral("

Oh no! An error occurred: "); - + WriteLiteral("

Oh no! An error occurred: "); + Write( #line 30 "Blocks.cshtml" - Write(ex.Message); - - + ex.Message #line default #line hidden -WriteLiteral("

\r\n"); - - + ); + WriteLiteral("

\r\n"); #line 31 "Blocks.cshtml" } - - #line default #line hidden -WriteLiteral("\r\n

i is now "); - + WriteLiteral("\r\n

i is now "); + Write( #line 33 "Blocks.cshtml" - Write(i); - - + i #line default #line hidden -WriteLiteral("

\r\n\r\n"); - - + ); + WriteLiteral("

\r\n\r\n"); #line 35 "Blocks.cshtml" lock(new object()) { - - #line default #line hidden -WriteLiteral("

This block is locked, for your security!

\r\n"); - + WriteLiteral("

This block is locked, for your security!

\r\n"); #line 37 "Blocks.cshtml" } - #line default #line hidden -} -} + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/CodeBlock.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/CodeBlock.cs index a47b997e99..86f3d82880 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/CodeBlock.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/CodeBlock.cs @@ -1,31 +1,24 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class CodeBlock { -#line hidden -public CodeBlock() { -} -public override void Execute() { + public class CodeBlock + { + #line hidden + public CodeBlock() + { + } + public override void Execute() + { #line 1 "CodeBlock.cshtml" for(int i = 1; i <= 10; i++) { Output.Write("

Hello from C#, #" + i.ToString() + "

"); } - - #line default #line hidden -} -} + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/CodeBlockAtEOF.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/CodeBlockAtEOF.cs index 1563d2e041..ec5def9a51 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/CodeBlockAtEOF.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/CodeBlockAtEOF.cs @@ -1,27 +1,27 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class CodeBlockAtEOF { -#line hidden -public CodeBlockAtEOF() { -} -public override void Execute() { + public class CodeBlockAtEOF + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public CodeBlockAtEOF() + { + } + public override void Execute() + { #line 1 "CodeBlockAtEOF.cshtml" - #line default #line hidden -} -} + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/CodeTree.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/CodeTree.cs index a1bad988cc..6cdad2c74f 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/CodeTree.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/CodeTree.cs @@ -1,12 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Microsoft.AspNet.Razor.Test.TestFiles.CodeGenerator.CS.Output +namespace TestOutput { + using System; + public class CodeTree { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public CodeTree() + { + } + + public override void Execute() + { + } } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Comments.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Comments.cs deleted file mode 100644 index 61e70fcb2b..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Comments.cs +++ /dev/null @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { -using System; - -public class Comments { -public override void Execute() { - - -#line 1 "Comments.cshtml" - //This is not going to be rendered - - -#line default -#line hidden -WriteLiteral("

This is going to be rendered

\r\n"); - - - -#line 3 "Comments.cshtml" - /* Neither is this - nor this - nor this */ - -#line default -#line hidden - -} -} -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ConditionalAttributes.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ConditionalAttributes.cs index 90d8a9a577..2dfc8bb774 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ConditionalAttributes.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ConditionalAttributes.cs @@ -1,197 +1,108 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class ConditionalAttributes { -#line hidden -public ConditionalAttributes() { -} -public override void Execute() { + public class ConditionalAttributes + { + #line hidden + public ConditionalAttributes() + { + } + public override void Execute() + { #line 1 "ConditionalAttributes.cshtml" var ch = true; var cls = "bar"; - - #line default #line hidden -WriteLiteral(" \r\n"); - -WriteLiteral(" \r\n ( #line 5 "ConditionalAttributes.cshtml" -, Tuple.Create(Tuple.Create("", 82), Tuple.Create(cls - + cls #line default #line hidden -, 82), false) -); - -WriteLiteral(" />\r\n"); - -WriteLiteral(" \r\n ( #line 6 "ConditionalAttributes.cshtml" -, Tuple.Create(Tuple.Create(" ", 109), Tuple.Create(cls - + cls #line default #line hidden -, 110), false) -); - -WriteLiteral(" />\r\n"); - -WriteLiteral(" \r\n ( #line 7 "ConditionalAttributes.cshtml" -, Tuple.Create(Tuple.Create("", 134), Tuple.Create(cls - + cls #line default #line hidden -, 134), false) -, Tuple.Create(Tuple.Create(" ", 138), Tuple.Create("foo", 139), true) -); - -WriteLiteral(" />\r\n"); - -WriteLiteral(" \r\n ( #line 8 "ConditionalAttributes.cshtml" -, Tuple.Create(Tuple.Create("", 184), Tuple.Create(ch - + ch #line default #line hidden -, 184), false) -); - -WriteLiteral(" />\r\n"); - -WriteLiteral(" \r\n ( #line 9 "ConditionalAttributes.cshtml" -, Tuple.Create(Tuple.Create(" ", 232), Tuple.Create(ch - + ch #line default #line hidden -, 233), false) -); - -WriteLiteral(" />\r\n"); - -WriteLiteral(" (new Template(__razor_attribute_value_writer => { - - + , 233), false)); + WriteLiteral(" />\r\n (new Template((__razor_attribute_value_writer) => { #line 10 "ConditionalAttributes.cshtml" if(cls != null) { - #line default #line hidden + WriteTo(__razor_attribute_value_writer, #line 10 "ConditionalAttributes.cshtml" -WriteTo(__razor_attribute_value_writer, cls); - - + cls #line default #line hidden - + ); #line 10 "ConditionalAttributes.cshtml" } - #line default #line hidden -}), 256), false) -); - -WriteLiteral(" />\r\n"); - -WriteLiteral(" (Href("~/Foo") -, 300), false) -); - -WriteLiteral(" />\r\n"); - -WriteLiteral(" \r\n (Href("~/Foo"), 300), false)); + WriteLiteral(" />\r\n ( #line 12 "ConditionalAttributes.cshtml" -, Tuple.Create(Tuple.Create("", 328), Tuple.Create(Url.Content("~/Scripts/jquery-1.6.2.min.js") - + Url.Content("~/Scripts/jquery-1.6.2.min.js") #line default #line hidden -, 328), false) -); - -WriteLiteral(" type=\"text/javascript\""); - -WriteLiteral(">\r\n"); - -WriteLiteral(" \r\n ( #line 13 "ConditionalAttributes.cshtml" -, Tuple.Create(Tuple.Create("", 426), Tuple.Create(Url.Content("~/Scripts/modernizr-2.0.6-development-only.js") - + Url.Content("~/Scripts/modernizr-2.0.6-development-only.js") #line default #line hidden -, 426), false) -); - -WriteLiteral(" type=\"text/javascript\""); - -WriteLiteral(">\r\n"); - -WriteLiteral(" \r\n"); - - + , 426), false)); + WriteLiteral(" type=\"text/javascript\">\r\n \r\n"); #line 15 "ConditionalAttributes.cshtml" - - #line default #line hidden -} -} + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/DesignTime.Tabs.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/DesignTime.Tabs.cs deleted file mode 100644 index d727ecd786..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/DesignTime.Tabs.cs +++ /dev/null @@ -1,110 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { -using System; - -public class DesignTime { -private static object @__o; -#line hidden -#line 9 "DesignTime.cshtml" -public static Template Foo() { -#line default -#line hidden -return new Template(__razor_helper_writer => { - -#line 10 "DesignTime.cshtml" - - if(true) { - - -#line default -#line hidden - -#line 11 "DesignTime.cshtml" - - } - - -#line default -#line hidden -}); - -#line 12 "DesignTime.cshtml" -} -#line default -#line hidden - -public DesignTime() { -} -public override void Execute() { - -#line 1 "DesignTime.cshtml" - for(int i = 1; i <= 10; i++) { - - -#line default -#line hidden - -#line 2 "DesignTime.cshtml" - __o = i; - - -#line default -#line hidden - -#line 3 "DesignTime.cshtml" - - } - -#line default -#line hidden - -#line 4 "DesignTime.cshtml" -__o = Foo(Bar.Baz); - - -#line default -#line hidden - -#line 5 "DesignTime.cshtml" -__o = Foo(item => new Template(__razor_template_writer => { - - -#line default -#line hidden - -#line 6 "DesignTime.cshtml" - __o = baz; - - -#line default -#line hidden - -#line 7 "DesignTime.cshtml" - })); - - -#line default -#line hidden -DefineSection("Footer", () => { - - -#line 8 "DesignTime.cshtml" -__o = bar; - - -#line default -#line hidden -}); - -} -} -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/DesignTime.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/DesignTime.cs index bcaded8858..18f2cf4e13 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/DesignTime.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/DesignTime.cs @@ -1,110 +1,100 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class DesignTime { -private static object @__o; -#line hidden -#line 9 "DesignTime.cshtml" -public static Template Foo() { + public class DesignTime + { + private static object @__o; + public static Template +#line 17 "DesignTime.cshtml" +Foo() { #line default #line hidden -return new Template(__razor_helper_writer => { - -#line 10 "DesignTime.cshtml" + return new Template((__razor_helper_writer) => { +#line 17 "DesignTime.cshtml" if(true) { - #line default #line hidden -#line 11 "DesignTime.cshtml" +#line 19 "DesignTime.cshtml" } - - #line default #line hidden -}); -#line 12 "DesignTime.cshtml" + } + ); +#line 21 "DesignTime.cshtml" } #line default #line hidden -public DesignTime() { -} -public override void Execute() { - -#line 1 "DesignTime.cshtml" - for(int i = 1; i <= 10; i++) { - - -#line default -#line hidden + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public DesignTime() + { + } + public override void Execute() + { #line 2 "DesignTime.cshtml" - __o = i; - - + for(int i = 1; i <= 10; i++) { + #line default #line hidden + __o = +#line 3 "DesignTime.cshtml" + i +#line default +#line hidden + ; #line 3 "DesignTime.cshtml" } - #line default #line hidden -#line 4 "DesignTime.cshtml" -__o = Foo(Bar.Baz); - - -#line default -#line hidden - -#line 5 "DesignTime.cshtml" -__o = Foo(item => new Template(__razor_template_writer => { - - -#line default -#line hidden - -#line 6 "DesignTime.cshtml" - __o = baz; - - -#line default -#line hidden - -#line 7 "DesignTime.cshtml" - })); - - -#line default -#line hidden -DefineSection("Footer", () => { - - + __o = #line 8 "DesignTime.cshtml" -__o = bar; - - + Foo(Bar.Baz) #line default #line hidden -}); - -} -} + ; + __o = +#line 9 "DesignTime.cshtml" + Foo( +#line default +#line hidden + item => new Template((__razor_template_writer) => { + __o = +#line 9 "DesignTime.cshtml" + baz +#line default +#line hidden + ; + } + ) +#line 9 "DesignTime.cshtml" + ) +#line default +#line hidden + ; + DefineSection("Footer", () => { + __o = +#line 14 "DesignTime.cshtml" + bar +#line default +#line hidden + ; + } + ); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyCodeBlock.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyCodeBlock.cs index 5aa9721678..d6564bdfc6 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyCodeBlock.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyCodeBlock.cs @@ -1,27 +1,27 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; + public class EmptyCodeBlock + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public EmptyCodeBlock() + { + } -public class EmptyCodeBlock { -#line hidden -public EmptyCodeBlock() { -} -public override void Execute() { - -#line 1 "EmptyCodeBlock.cshtml" + public override void Execute() + { +#line 3 "EmptyCodeBlock.cshtml" - #line default #line hidden -} -} + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyExplicitExpression.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyExplicitExpression.cs index bac2bc5d60..a3faf577b4 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyExplicitExpression.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyExplicitExpression.cs @@ -1,29 +1,28 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { -using System; - -public class EmptyExplicitExpression { -private static object @__o; -#line hidden -public EmptyExplicitExpression() { -} -public override void Execute() { - -#line 1 "EmptyExplicitExpression.cshtml" -__o = ; +namespace TestOutput +{ + using System; + public class EmptyExplicitExpression + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public EmptyExplicitExpression() + { + } + public override void Execute() + { + __o = +#line 3 "EmptyExplicitExpression.cshtml" + #line default #line hidden -} -} + ; + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyImplicitExpression.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyImplicitExpression.cs index bf8cdefa37..fd847e56a5 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyImplicitExpression.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyImplicitExpression.cs @@ -1,29 +1,28 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { -using System; - -public class EmptyImplicitExpression { -private static object @__o; -#line hidden -public EmptyImplicitExpression() { -} -public override void Execute() { - -#line 1 "EmptyImplicitExpression.cshtml" -__o = ; +namespace TestOutput +{ + using System; + public class EmptyImplicitExpression + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public EmptyImplicitExpression() + { + } + public override void Execute() + { + __o = +#line 3 "EmptyImplicitExpression.cshtml" + #line default #line hidden -} -} + ; + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyImplicitExpressionInCode.Tabs.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyImplicitExpressionInCode.Tabs.cs index 63851ecfb9..3e35ccefe1 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyImplicitExpressionInCode.Tabs.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyImplicitExpressionInCode.Tabs.cs @@ -1,43 +1,39 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class EmptyImplicitExpressionInCode { -private static object @__o; -#line hidden -public EmptyImplicitExpressionInCode() { -} -public override void Execute() { + public class EmptyImplicitExpressionInCode + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public EmptyImplicitExpressionInCode() + { + } + public override void Execute() + { #line 1 "EmptyImplicitExpressionInCode.cshtml" - #line default #line hidden + __o = #line 2 "EmptyImplicitExpressionInCode.cshtml" -__o = ; - - -#line default -#line hidden - -#line 3 "EmptyImplicitExpressionInCode.cshtml" - - #line default #line hidden -} -} + ; +#line 2 "EmptyImplicitExpressionInCode.cshtml" + +#line default +#line hidden + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyImplicitExpressionInCode.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyImplicitExpressionInCode.cs index 3c8deb41a0..740bc283bd 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyImplicitExpressionInCode.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/EmptyImplicitExpressionInCode.cs @@ -1,43 +1,39 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class EmptyImplicitExpressionInCode { -private static object @__o; -#line hidden -public EmptyImplicitExpressionInCode() { -} -public override void Execute() { + public class EmptyImplicitExpressionInCode + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public EmptyImplicitExpressionInCode() + { + } + public override void Execute() + { #line 1 "EmptyImplicitExpressionInCode.cshtml" - #line default #line hidden + __o = #line 2 "EmptyImplicitExpressionInCode.cshtml" -__o = ; - - -#line default -#line hidden - -#line 3 "EmptyImplicitExpressionInCode.cshtml" - - #line default #line hidden -} -} + ; +#line 2 "EmptyImplicitExpressionInCode.cshtml" + +#line default +#line hidden + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ExplicitExpression.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ExplicitExpression.cs index 95651766c6..96cb3055fd 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ExplicitExpression.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ExplicitExpression.cs @@ -1,30 +1,23 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { -using System; - -public class ExplicitExpression { -#line hidden -public ExplicitExpression() { -} -public override void Execute() { -WriteLiteral("1 + 1 = "); +namespace TestOutput +{ + using System; + public class ExplicitExpression + { + #line hidden + public ExplicitExpression() + { + } + public override void Execute() + { + WriteLiteral("1 + 1 = "); + Write( #line 1 "ExplicitExpression.cshtml" - Write(1+1); - - + 1+1 #line default #line hidden -} -} + ); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ExplicitExpressionAtEOF.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ExplicitExpressionAtEOF.cs index 941af4e02c..dfd8e063f3 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ExplicitExpressionAtEOF.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ExplicitExpressionAtEOF.cs @@ -1,29 +1,28 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { -using System; - -public class ExplicitExpressionAtEOF { -private static object @__o; -#line hidden -public ExplicitExpressionAtEOF() { -} -public override void Execute() { - -#line 1 "ExplicitExpressionAtEOF.cshtml" -__o = ; +namespace TestOutput +{ + using System; + public class ExplicitExpressionAtEOF + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public ExplicitExpressionAtEOF() + { + } + public override void Execute() + { + __o = +#line 3 "ExplicitExpressionAtEOF.cshtml" + #line default #line hidden -} -} + ; + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ExpressionsInCode.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ExpressionsInCode.cs index 4171f401a7..1f49e4a25a 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ExpressionsInCode.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ExpressionsInCode.cs @@ -1,89 +1,68 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class ExpressionsInCode { -#line hidden -public ExpressionsInCode() { -} -public override void Execute() { + public class ExpressionsInCode + { + #line hidden + public ExpressionsInCode() + { + } + public override void Execute() + { #line 1 "ExpressionsInCode.cshtml" object foo = null; string bar = "Foo"; - - #line default #line hidden -WriteLiteral("\r\n\r\n"); - + WriteLiteral("\r\n\r\n"); #line 6 "ExpressionsInCode.cshtml" if(foo != null) { - #line default #line hidden + Write( #line 7 "ExpressionsInCode.cshtml" -Write(foo); - - + foo #line default #line hidden - + ); #line 7 "ExpressionsInCode.cshtml" } else { - - #line default #line hidden -WriteLiteral("

Foo is Null!

\r\n"); - + WriteLiteral("

Foo is Null!

\r\n"); #line 10 "ExpressionsInCode.cshtml" } - - #line default #line hidden -WriteLiteral("\r\n

\r\n"); - + WriteLiteral("\r\n

\r\n"); #line 13 "ExpressionsInCode.cshtml" if(!String.IsNullOrEmpty(bar)) { - #line default #line hidden + Write( #line 14 "ExpressionsInCode.cshtml" -Write(bar.Replace("F", "B")); - - + bar.Replace("F", "B") #line default #line hidden - + ); #line 14 "ExpressionsInCode.cshtml" } - - #line default #line hidden -WriteLiteral("

"); -} -} + WriteLiteral("

"); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock.DesignTime.Tabs.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock.DesignTime.Tabs.cs index 442d6a0641..890e146d1b 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock.DesignTime.Tabs.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock.DesignTime.Tabs.cs @@ -1,46 +1,41 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class FunctionsBlock { -private static object @__o; -#line hidden + public class FunctionsBlock + { + private static object @__o; #line 1 "FunctionsBlock.cshtml" - #line default #line hidden - -#line 2 "FunctionsBlock.cshtml" +#line 5 "FunctionsBlock.cshtml" Random _rand = new Random(); private int RandomInt() { return _rand.Next(); } - #line default #line hidden + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public FunctionsBlock() + { + } -public FunctionsBlock() { -} -public override void Execute() { - -#line 3 "FunctionsBlock.cshtml" - __o = RandomInt(); - - + public override void Execute() + { + __o = +#line 12 "FunctionsBlock.cshtml" + RandomInt() #line default #line hidden -} -} + ; + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock.DesignTime.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock.DesignTime.cs index 534039f889..e776b905a1 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock.DesignTime.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock.DesignTime.cs @@ -1,46 +1,41 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class FunctionsBlock { -private static object @__o; -#line hidden + public class FunctionsBlock + { + private static object @__o; #line 1 "FunctionsBlock.cshtml" - #line default #line hidden - -#line 2 "FunctionsBlock.cshtml" +#line 5 "FunctionsBlock.cshtml" Random _rand = new Random(); private int RandomInt() { return _rand.Next(); } - #line default #line hidden + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public FunctionsBlock() + { + } -public FunctionsBlock() { -} -public override void Execute() { - -#line 3 "FunctionsBlock.cshtml" - __o = RandomInt(); - - + public override void Execute() + { + __o = +#line 12 "FunctionsBlock.cshtml" + RandomInt() #line default #line hidden -} -} + ; + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock.cs index 0b9f2a378d..7e5c31a9e0 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock.cs @@ -1,49 +1,37 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class FunctionsBlock { -#line hidden + public class FunctionsBlock + { #line 1 "FunctionsBlock.cshtml" - #line default #line hidden - #line 5 "FunctionsBlock.cshtml" Random _rand = new Random(); private int RandomInt() { return _rand.Next(); } - #line default #line hidden + #line hidden + public FunctionsBlock() + { + } -public FunctionsBlock() { -} -public override void Execute() { -WriteLiteral("\r\n"); - -WriteLiteral("\r\nHere\'s a random number: "); - - + public override void Execute() + { + WriteLiteral("\r\n"); + WriteLiteral("\r\nHere\'s a random number: "); + Write( #line 12 "FunctionsBlock.cshtml" - Write(RandomInt()); - - + RandomInt() #line default #line hidden -} -} + ); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlockMinimal.DesignTime.Tabs.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlockMinimal.DesignTime.Tabs.cs index 6384a74cf0..0aca153aba 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlockMinimal.DesignTime.Tabs.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlockMinimal.DesignTime.Tabs.cs @@ -1,30 +1,29 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class FunctionsBlockMinimal { -#line hidden -#line 1 "FunctionsBlockMinimal.cshtml" + public class FunctionsBlockMinimal + { + private static object @__o; +#line 3 "FunctionsBlockMinimal.cshtml" string foo(string input) { return input + "!"; } - #line default #line hidden + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public FunctionsBlockMinimal() + { + } -public FunctionsBlockMinimal() { -} -public override void Execute() { -} -} + public override void Execute() + { + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock_Tabs.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock_Tabs.cs index 863fdda875..645657b3be 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock_Tabs.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/FunctionsBlock_Tabs.cs @@ -1,49 +1,37 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class FunctionsBlock_Tabs { -#line hidden + public class FunctionsBlock_Tabs + { #line 1 "FunctionsBlock_Tabs.cshtml" - #line default #line hidden - #line 5 "FunctionsBlock_Tabs.cshtml" Random _rand = new Random(); private int RandomInt() { return _rand.Next(); } - #line default #line hidden + #line hidden + public FunctionsBlock_Tabs() + { + } -public FunctionsBlock_Tabs() { -} -public override void Execute() { -WriteLiteral("\r\n"); - -WriteLiteral("\r\nHere\'s a random number: "); - - + public override void Execute() + { + WriteLiteral("\r\n"); + WriteLiteral("\r\nHere\'s a random number: "); + Write( #line 12 "FunctionsBlock_Tabs.cshtml" - Write(RandomInt()); - - + RandomInt() #line default #line hidden -} -} + ); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.Instance.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.Instance.cs index 4664e58839..229b4fb9d2 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.Instance.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.Instance.cs @@ -1,106 +1,86 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class Helpers { -#line hidden + public class Helpers + { + public Template #line 1 "Helpers.cshtml" -public Template Bold(string s) { +Bold(string s) { #line default #line hidden -return new Template(__razor_helper_writer => { - + return new Template((__razor_helper_writer) => { #line 1 "Helpers.cshtml" s = s.ToUpper(); - - #line default #line hidden -WriteLiteralTo(__razor_helper_writer, " "); - + WriteLiteralTo(__razor_helper_writer, " "); + WriteTo(__razor_helper_writer, #line 3 "Helpers.cshtml" -WriteTo(__razor_helper_writer, s); - - + s #line default #line hidden -WriteLiteralTo(__razor_helper_writer, "\r\n"); - - + ); + WriteLiteralTo(__razor_helper_writer, "\r\n"); #line 4 "Helpers.cshtml" - - #line default #line hidden -}); + } + ); #line 4 "Helpers.cshtml" } #line default #line hidden + public Template #line 6 "Helpers.cshtml" -public Template Italic(string s) { +Italic(string s) { #line default #line hidden -return new Template(__razor_helper_writer => { - + return new Template((__razor_helper_writer) => { #line 6 "Helpers.cshtml" s = s.ToUpper(); - - #line default #line hidden -WriteLiteralTo(__razor_helper_writer, " "); - + WriteLiteralTo(__razor_helper_writer, " "); + WriteTo(__razor_helper_writer, #line 8 "Helpers.cshtml" -WriteTo(__razor_helper_writer, s); - - + s #line default #line hidden -WriteLiteralTo(__razor_helper_writer, "\r\n"); - - + ); + WriteLiteralTo(__razor_helper_writer, "\r\n"); #line 9 "Helpers.cshtml" - - #line default #line hidden -}); + } + ); #line 9 "Helpers.cshtml" } #line default #line hidden -public Helpers() { -} -public override void Execute() { -WriteLiteral("\r\n"); - -WriteLiteral("\r\n"); - + #line hidden + public Helpers() + { + } + public override void Execute() + { + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + Write( #line 11 "Helpers.cshtml" -Write(Bold("Hello")); - - + Bold("Hello") #line default #line hidden -} -} + ); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.cs index 7e6c4eab06..ba1d40df50 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.cs @@ -1,106 +1,86 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class Helpers { -#line hidden + public class Helpers + { + public static Template #line 1 "Helpers.cshtml" -public static Template Bold(string s) { +Bold(string s) { #line default #line hidden -return new Template(__razor_helper_writer => { - + return new Template((__razor_helper_writer) => { #line 1 "Helpers.cshtml" s = s.ToUpper(); - - #line default #line hidden -WriteLiteralTo(__razor_helper_writer, " "); - + WriteLiteralTo(__razor_helper_writer, " "); + WriteTo(__razor_helper_writer, #line 3 "Helpers.cshtml" -WriteTo(__razor_helper_writer, s); - - + s #line default #line hidden -WriteLiteralTo(__razor_helper_writer, "\r\n"); - - + ); + WriteLiteralTo(__razor_helper_writer, "\r\n"); #line 4 "Helpers.cshtml" - - #line default #line hidden -}); + } + ); #line 4 "Helpers.cshtml" } #line default #line hidden + public static Template #line 6 "Helpers.cshtml" -public static Template Italic(string s) { +Italic(string s) { #line default #line hidden -return new Template(__razor_helper_writer => { - + return new Template((__razor_helper_writer) => { #line 6 "Helpers.cshtml" s = s.ToUpper(); - - #line default #line hidden -WriteLiteralTo(__razor_helper_writer, " "); - + WriteLiteralTo(__razor_helper_writer, " "); + WriteTo(__razor_helper_writer, #line 8 "Helpers.cshtml" -WriteTo(__razor_helper_writer, s); - - + s #line default #line hidden -WriteLiteralTo(__razor_helper_writer, "\r\n"); - - + ); + WriteLiteralTo(__razor_helper_writer, "\r\n"); #line 9 "Helpers.cshtml" - - #line default #line hidden -}); + } + ); #line 9 "Helpers.cshtml" } #line default #line hidden -public Helpers() { -} -public override void Execute() { -WriteLiteral("\r\n"); - -WriteLiteral("\r\n"); - + #line hidden + public Helpers() + { + } + public override void Execute() + { + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + Write( #line 11 "Helpers.cshtml" -Write(Bold("Hello")); - - + Bold("Hello") #line default #line hidden -} -} + ); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingCloseParen.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingCloseParen.cs index e434440814..7a5547bfb2 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingCloseParen.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingCloseParen.cs @@ -1,66 +1,55 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class HelpersMissingCloseParen { -#line hidden + public class HelpersMissingCloseParen + { + public static Template #line 1 "HelpersMissingCloseParen.cshtml" -public static Template Bold(string s) { +Bold(string s) { #line default #line hidden -return new Template(__razor_helper_writer => { - + return new Template((__razor_helper_writer) => { #line 1 "HelpersMissingCloseParen.cshtml" s = s.ToUpper(); - - #line default #line hidden -WriteLiteralTo(__razor_helper_writer, " "); - + WriteLiteralTo(__razor_helper_writer, " "); + WriteTo(__razor_helper_writer, #line 3 "HelpersMissingCloseParen.cshtml" -WriteTo(__razor_helper_writer, s); - - + s #line default #line hidden -WriteLiteralTo(__razor_helper_writer, "\r\n"); - - + ); + WriteLiteralTo(__razor_helper_writer, "\r\n"); #line 4 "HelpersMissingCloseParen.cshtml" - - #line default #line hidden -}); + } + ); #line 4 "HelpersMissingCloseParen.cshtml" } #line default #line hidden + public static Template #line 6 "HelpersMissingCloseParen.cshtml" -public static Template Italic(string s +Italic(string s @Bold("Hello") #line default #line hidden -public HelpersMissingCloseParen() { -} -public override void Execute() { -WriteLiteral("\r\n"); + #line hidden + public HelpersMissingCloseParen() + { + } -} -} + public override void Execute() + { + WriteLiteral("\r\n"); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingName.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingName.cs deleted file mode 100644 index aa0ea14602..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingName.cs +++ /dev/null @@ -1,21 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { -using System; - -public class HelpersMissingName { -#line hidden -public HelpersMissingName() { -} -public override void Execute() { -} -} -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenBrace.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenBrace.cs index aef9e881ee..08920d1b6b 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenBrace.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenBrace.cs @@ -1,72 +1,60 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class HelpersMissingOpenBrace { -#line hidden + public class HelpersMissingOpenBrace + { + public static Template #line 1 "HelpersMissingOpenBrace.cshtml" -public static Template Bold(string s) { +Bold(string s) { #line default #line hidden -return new Template(__razor_helper_writer => { - + return new Template((__razor_helper_writer) => { #line 1 "HelpersMissingOpenBrace.cshtml" s = s.ToUpper(); - - #line default #line hidden -WriteLiteralTo(__razor_helper_writer, " "); - + WriteLiteralTo(__razor_helper_writer, " "); + WriteTo(__razor_helper_writer, #line 3 "HelpersMissingOpenBrace.cshtml" -WriteTo(__razor_helper_writer, s); - - + s #line default #line hidden -WriteLiteralTo(__razor_helper_writer, "\r\n"); - - + ); + WriteLiteralTo(__razor_helper_writer, "\r\n"); #line 4 "HelpersMissingOpenBrace.cshtml" - - #line default #line hidden -}); + } + ); #line 4 "HelpersMissingOpenBrace.cshtml" } #line default #line hidden + public static Template #line 6 "HelpersMissingOpenBrace.cshtml" -public static Template Italic(string s) +Italic(string s) #line default #line hidden -public HelpersMissingOpenBrace() { -} -public override void Execute() { -WriteLiteral("\r\n"); - + #line hidden + public HelpersMissingOpenBrace() + { + } + public override void Execute() + { + WriteLiteral("\r\n"); + Write( #line 7 "HelpersMissingOpenBrace.cshtml" -Write(Italic(s)); - - + Italic(s) #line default #line hidden -} -} + ); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenParen.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenParen.cs index b4f46de6a0..0519b52e7a 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenParen.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenParen.cs @@ -1,72 +1,60 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class HelpersMissingOpenParen { -#line hidden + public class HelpersMissingOpenParen + { + public static Template #line 1 "HelpersMissingOpenParen.cshtml" -public static Template Bold(string s) { +Bold(string s) { #line default #line hidden -return new Template(__razor_helper_writer => { - + return new Template((__razor_helper_writer) => { #line 1 "HelpersMissingOpenParen.cshtml" s = s.ToUpper(); - - #line default #line hidden -WriteLiteralTo(__razor_helper_writer, " "); - + WriteLiteralTo(__razor_helper_writer, " "); + WriteTo(__razor_helper_writer, #line 3 "HelpersMissingOpenParen.cshtml" -WriteTo(__razor_helper_writer, s); - - + s #line default #line hidden -WriteLiteralTo(__razor_helper_writer, "\r\n"); - - + ); + WriteLiteralTo(__razor_helper_writer, "\r\n"); #line 4 "HelpersMissingOpenParen.cshtml" - - #line default #line hidden -}); + } + ); #line 4 "HelpersMissingOpenParen.cshtml" } #line default #line hidden + public static Template #line 6 "HelpersMissingOpenParen.cshtml" -public static Template Italic +Italic #line default #line hidden -public HelpersMissingOpenParen() { -} -public override void Execute() { -WriteLiteral("\r\n"); - + #line hidden + public HelpersMissingOpenParen() + { + } + public override void Execute() + { + WriteLiteral("\r\n"); + Write( #line 7 "HelpersMissingOpenParen.cshtml" -Write(Bold("Hello")); - - + Bold("Hello") #line default #line hidden -} -} + ); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HiddenSpansInCode.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HiddenSpansInCode.cs index 31c1da097f..af30784465 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HiddenSpansInCode.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HiddenSpansInCode.cs @@ -1,35 +1,33 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class HiddenSpansInCode { -#line hidden -public HiddenSpansInCode() { -} -public override void Execute() { + public class HiddenSpansInCode + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public HiddenSpansInCode() + { + } + public override void Execute() + { #line 1 "HiddenSpansInCode.cshtml" - #line default #line hidden #line 2 "HiddenSpansInCode.cshtml" @Da - - #line default #line hidden -} -} + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HtmlCommentWithQuote_Double.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HtmlCommentWithQuote_Double.cs index 115da3dfff..d6e33b3324 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HtmlCommentWithQuote_Double.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HtmlCommentWithQuote_Double.cs @@ -1,30 +1,19 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; + public class HtmlCommentWithQuote_Double + { + #line hidden + public HtmlCommentWithQuote_Double() + { + } -public class HtmlCommentWithQuote_Double { -#line hidden -public HtmlCommentWithQuote_Double() { -} -public override void Execute() { -WriteLiteral("\r\n(Href("~/images/submit.png") -, 22), false) -); - -WriteLiteral(" />"); - -} -} + public override void Execute() + { + WriteLiteral("\r\n(Href("~/images/submit.png"), 22), false)); + WriteLiteral(" />"); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HtmlCommentWithQuote_Single.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HtmlCommentWithQuote_Single.cs index df58ff1e3a..30e6d8564b 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HtmlCommentWithQuote_Single.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HtmlCommentWithQuote_Single.cs @@ -1,30 +1,19 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; + public class HtmlCommentWithQuote_Single + { + #line hidden + public HtmlCommentWithQuote_Single() + { + } -public class HtmlCommentWithQuote_Single { -#line hidden -public HtmlCommentWithQuote_Single() { -} -public override void Execute() { -WriteLiteral("\r\n(Href("~/images/submit.png") -, 22), false) -); - -WriteLiteral(" />"); - -} -} + public override void Execute() + { + WriteLiteral("\r\n(Href("~/images/submit.png"), 22), false)); + WriteLiteral(" />"); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ImplicitExpression.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ImplicitExpression.cs index 6d9870377c..7a0c76d87a 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ImplicitExpression.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ImplicitExpression.cs @@ -1,45 +1,34 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class ImplicitExpression { -#line hidden -public ImplicitExpression() { -} -public override void Execute() { + public class ImplicitExpression + { + #line hidden + public ImplicitExpression() + { + } + public override void Execute() + { #line 1 "ImplicitExpression.cshtml" for(int i = 1; i <= 10; i++) { - - #line default #line hidden -WriteLiteral("

This is item #"); - + WriteLiteral("

This is item #"); + Write( #line 2 "ImplicitExpression.cshtml" - Write(i); - - + i #line default #line hidden -WriteLiteral("

\r\n"); - - + ); + WriteLiteral("

\r\n"); #line 3 "ImplicitExpression.cshtml" } - #line default #line hidden -} -} + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ImplicitExpressionAtEOF.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ImplicitExpressionAtEOF.cs index 0eff69ae22..880a90e731 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ImplicitExpressionAtEOF.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ImplicitExpressionAtEOF.cs @@ -1,29 +1,28 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { -using System; - -public class ImplicitExpressionAtEOF { -private static object @__o; -#line hidden -public ImplicitExpressionAtEOF() { -} -public override void Execute() { - -#line 1 "ImplicitExpressionAtEOF.cshtml" -__o = ; +namespace TestOutput +{ + using System; + public class ImplicitExpressionAtEOF + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public ImplicitExpressionAtEOF() + { + } + public override void Execute() + { + __o = +#line 3 "ImplicitExpressionAtEOF.cshtml" + #line default #line hidden -} -} + ; + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Imports.DesignTime.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Imports.DesignTime.cs index 082da73bbd..dcd59bae68 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Imports.DesignTime.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Imports.DesignTime.cs @@ -1,53 +1,48 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { - -#line 3 "Imports.cshtml" -using System; - -#line default -#line hidden - +namespace TestOutput +{ #line 1 "Imports.cshtml" -using System.IO; - +using System.IO #line default #line hidden - + ; #line 2 "Imports.cshtml" -using Foo = System.Text.Encoding; - +using Foo = System.Text.Encoding #line default #line hidden - -public class Imports { -private static object @__o; -#line hidden -public Imports() { -} -public override void Execute() { - -#line 4 "Imports.cshtml" - __o = typeof(Path).FullName; - - + ; +#line 3 "Imports.cshtml" +using System #line default #line hidden + ; + public class Imports + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public Imports() + { + } + + public override void Execute() + { + __o = #line 5 "Imports.cshtml" - __o = typeof(Foo).FullName; - - + typeof(Path).FullName #line default #line hidden -} -} + ; + __o = +#line 6 "Imports.cshtml" + typeof(Foo).FullName +#line default +#line hidden + ; + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Imports.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Imports.cs index 58105a3b10..ff7fea355a 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Imports.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Imports.cs @@ -1,58 +1,45 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { - -#line 3 "Imports.cshtml" -using System; - -#line default -#line hidden - +namespace TestOutput +{ #line 1 "Imports.cshtml" -using System.IO; - +using System.IO #line default #line hidden - + ; #line 2 "Imports.cshtml" -using Foo = System.Text.Encoding; - +using Foo = System.Text.Encoding #line default #line hidden - -public class Imports { + ; +#line 3 "Imports.cshtml" +using System +#line default #line hidden -public Imports() { -} -public override void Execute() { -WriteLiteral("\r\n

Path\'s full type name is "); + ; + public class Imports + { + #line hidden + public Imports() + { + } + public override void Execute() + { + WriteLiteral("\r\n

Path\'s full type name is "); + Write( #line 5 "Imports.cshtml" - Write(typeof(Path).FullName); - - + typeof(Path).FullName #line default #line hidden -WriteLiteral("

\r\n

Foo\'s actual full type name is "); - - + ); + WriteLiteral("

\r\n

Foo\'s actual full type name is "); + Write( #line 6 "Imports.cshtml" - Write(typeof(Foo).FullName); - - + typeof(Foo).FullName #line default #line hidden -WriteLiteral("

"); - -} -} + ); + WriteLiteral("

"); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Inherits.Designtime.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Inherits.Designtime.cs index 44af46d987..697b0fd7b0 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Inherits.Designtime.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Inherits.Designtime.cs @@ -1,40 +1,32 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class Inherits : foo.bar>.boz bar { -private static object @__o; -#line hidden -public Inherits() { -} -private void @__RazorDesignTimeHelpers__() { -#pragma warning disable 219 - -#line 2 "Inherits.cshtml" + public class Inherits : foo.bar>.boz bar + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 +#line 3 "Inherits.cshtml" foo.bar>.boz bar __inheritsHelper = null; - - #line default #line hidden -#pragma warning restore 219 -} -public override void Execute() { + #pragma warning restore 219 + } + #line hidden + public Inherits() + { + } + public override void Execute() + { + __o = #line 1 "Inherits.cshtml" -__o = foo(); - - + foo() #line default #line hidden -} -} + ; + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Inherits.Runtime.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Inherits.Runtime.cs index 77e3633eac..e0601378ab 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Inherits.Runtime.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Inherits.Runtime.cs @@ -1,30 +1,23 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class Inherits : foo.bar>.boz bar { -#line hidden -public Inherits() { -} -public override void Execute() { + public class Inherits : foo.bar>.boz bar + { + #line hidden + public Inherits() + { + } + public override void Execute() + { + Write( #line 1 "Inherits.cshtml" -Write(foo()); - - + foo() #line default #line hidden -WriteLiteral("\r\n\r\n"); - -} -} + ); + WriteLiteral("\r\n\r\n"); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/InlineBlocks.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/InlineBlocks.cs index 4dbd24e98b..b21b59f216 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/InlineBlocks.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/InlineBlocks.cs @@ -1,87 +1,66 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class InlineBlocks { -#line hidden + public class InlineBlocks + { + public static Template #line 1 "InlineBlocks.cshtml" -public static Template Link(string link) { +Link(string link) { #line default #line hidden -return new Template(__razor_helper_writer => { - + return new Template((__razor_helper_writer) => { #line 1 "InlineBlocks.cshtml" - - #line default #line hidden -WriteLiteralTo(__razor_helper_writer, " (new Template(__razor_attribute_value_writer => { - + WriteLiteralTo(__razor_helper_writer, " (new Template((__razor_attribute_value_writer) => { #line 2 "InlineBlocks.cshtml" if(link != null) { - #line default #line hidden + WriteTo(__razor_attribute_value_writer, #line 2 "InlineBlocks.cshtml" -WriteTo(__razor_attribute_value_writer, link); - - + link #line default #line hidden - + ); #line 2 "InlineBlocks.cshtml" } else { - #line default #line hidden -WriteLiteralTo(__razor_attribute_value_writer, " "); - -WriteLiteralTo(__razor_attribute_value_writer, "#"); - -WriteLiteralTo(__razor_attribute_value_writer, " "); - + WriteLiteralTo(__razor_attribute_value_writer, " # "); #line 2 "InlineBlocks.cshtml" } - #line default #line hidden -}), 42), false) -); - -WriteLiteralTo(__razor_helper_writer, " />\r\n"); - + } + ), 42), false)); + WriteLiteralTo(__razor_helper_writer, " />\r\n"); #line 3 "InlineBlocks.cshtml" - - #line default #line hidden -}); + } + ); #line 3 "InlineBlocks.cshtml" } #line default #line hidden -public InlineBlocks() { -} -public override void Execute() { -} -} + #line hidden + public InlineBlocks() + { + } + + public override void Execute() + { + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Instrumented.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Instrumented.cs deleted file mode 100644 index f9f99bb17f..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Instrumented.cs +++ /dev/null @@ -1,359 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { -using System; - -public class Instrumented { -#line hidden -#line 1 "Instrumented.cshtml" -public static Template Strong(string s) { -#line default -#line hidden -return new Template(__razor_helper_writer => { - -#line 1 "Instrumented.cshtml" - - - -#line default -#line hidden -BeginContext(__razor_helper_writer, "~/Instrumented.cshtml", 28, 12, true); - -WriteLiteralTo(__razor_helper_writer, " "); - -EndContext(__razor_helper_writer, "~/Instrumented.cshtml", 28, 12, true); - -BeginContext(__razor_helper_writer, "~/Instrumented.cshtml", 41, 1, false); - - -#line 2 "Instrumented.cshtml" -WriteTo(__razor_helper_writer, s); - - -#line default -#line hidden -EndContext(__razor_helper_writer, "~/Instrumented.cshtml", 41, 1, false); - -BeginContext(__razor_helper_writer, "~/Instrumented.cshtml", 42, 11, true); - -WriteLiteralTo(__razor_helper_writer, "\r\n"); - -EndContext(__razor_helper_writer, "~/Instrumented.cshtml", 42, 11, true); - - -#line 3 "Instrumented.cshtml" - - -#line default -#line hidden -}); - -#line 3 "Instrumented.cshtml" -} -#line default -#line hidden - -public Instrumented() { -} -public override void Execute() { -BeginContext("~/Instrumented.cshtml", 56, 2, true); - -WriteLiteral("\r\n"); - -EndContext("~/Instrumented.cshtml", 56, 2, true); - - -#line 5 "Instrumented.cshtml" - - int i = 1; - var foo = - -#line default -#line hidden -item => new Template(__razor_template_writer => { - -BeginContext(__razor_template_writer, "~/Instrumented.cshtml", 93, 10, true); - -WriteLiteralTo(__razor_template_writer, "

Bar

"); - -EndContext(__razor_template_writer, "~/Instrumented.cshtml", 93, 10, true); - -}) - -#line 7 "Instrumented.cshtml" - ; - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 106, 4, true); - -WriteLiteral(" "); - -EndContext("~/Instrumented.cshtml", 106, 4, true); - -BeginContext("~/Instrumented.cshtml", 112, 14, true); - -WriteLiteral("Hello, World\r\n"); - -EndContext("~/Instrumented.cshtml", 112, 14, true); - -BeginContext("~/Instrumented.cshtml", 126, 25, true); - -WriteLiteral("

Hello, World

\r\n"); - -EndContext("~/Instrumented.cshtml", 126, 25, true); - - -#line 10 "Instrumented.cshtml" - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 152, 4, true); - -WriteLiteral("\r\n\r\n"); - -EndContext("~/Instrumented.cshtml", 152, 4, true); - - -#line 12 "Instrumented.cshtml" - while(i <= 10) { - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 175, 23, true); - -WriteLiteral("

Hello from C#, #"); - -EndContext("~/Instrumented.cshtml", 175, 23, true); - -BeginContext("~/Instrumented.cshtml", 200, 1, false); - - -#line 13 "Instrumented.cshtml" - Write(i); - - -#line default -#line hidden -EndContext("~/Instrumented.cshtml", 200, 1, false); - -BeginContext("~/Instrumented.cshtml", 202, 6, true); - -WriteLiteral("

\r\n"); - -EndContext("~/Instrumented.cshtml", 202, 6, true); - - -#line 14 "Instrumented.cshtml" - i += 1; -} - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 224, 2, true); - -WriteLiteral("\r\n"); - -EndContext("~/Instrumented.cshtml", 224, 2, true); - - -#line 17 "Instrumented.cshtml" - if(i == 11) { - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 242, 31, true); - -WriteLiteral("

We wrote 10 lines!

\r\n"); - -EndContext("~/Instrumented.cshtml", 242, 31, true); - - -#line 19 "Instrumented.cshtml" -} - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 276, 2, true); - -WriteLiteral("\r\n"); - -EndContext("~/Instrumented.cshtml", 276, 2, true); - - -#line 21 "Instrumented.cshtml" - switch(i) { - case 11: - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 306, 46, true); - -WriteLiteral("

No really, we wrote 10 lines!

\r\n"); - -EndContext("~/Instrumented.cshtml", 306, 46, true); - - -#line 24 "Instrumented.cshtml" - break; - default: - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 382, 39, true); - -WriteLiteral("

Actually, we didn\'t...

\r\n"); - -EndContext("~/Instrumented.cshtml", 382, 39, true); - - -#line 27 "Instrumented.cshtml" - break; -} - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 440, 2, true); - -WriteLiteral("\r\n"); - -EndContext("~/Instrumented.cshtml", 440, 2, true); - - -#line 30 "Instrumented.cshtml" - for(int j = 1; j <= 10; j += 2) { - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 478, 29, true); - -WriteLiteral("

Hello again from C#, #"); - -EndContext("~/Instrumented.cshtml", 478, 29, true); - -BeginContext("~/Instrumented.cshtml", 509, 1, false); - - -#line 31 "Instrumented.cshtml" - Write(j); - - -#line default -#line hidden -EndContext("~/Instrumented.cshtml", 509, 1, false); - -BeginContext("~/Instrumented.cshtml", 511, 6, true); - -WriteLiteral("

\r\n"); - -EndContext("~/Instrumented.cshtml", 511, 6, true); - - -#line 32 "Instrumented.cshtml" -} - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 520, 2, true); - -WriteLiteral("\r\n"); - -EndContext("~/Instrumented.cshtml", 520, 2, true); - - -#line 34 "Instrumented.cshtml" - try { - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 530, 41, true); - -WriteLiteral("

That time, we wrote 5 lines!

\r\n"); - -EndContext("~/Instrumented.cshtml", 530, 41, true); - - -#line 36 "Instrumented.cshtml" -} catch(Exception ex) { - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 596, 33, true); - -WriteLiteral("

Oh no! An error occurred: "); - -EndContext("~/Instrumented.cshtml", 596, 33, true); - -BeginContext("~/Instrumented.cshtml", 631, 10, false); - - -#line 37 "Instrumented.cshtml" - Write(ex.Message); - - -#line default -#line hidden -EndContext("~/Instrumented.cshtml", 631, 10, false); - -BeginContext("~/Instrumented.cshtml", 642, 6, true); - -WriteLiteral("

\r\n"); - -EndContext("~/Instrumented.cshtml", 642, 6, true); - - -#line 38 "Instrumented.cshtml" -} - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 651, 2, true); - -WriteLiteral("\r\n"); - -EndContext("~/Instrumented.cshtml", 651, 2, true); - - -#line 40 "Instrumented.cshtml" - lock(new object()) { - - -#line default -#line hidden -BeginContext("~/Instrumented.cshtml", 676, 53, true); - -WriteLiteral("

This block is locked, for your security!

\r\n"); - -EndContext("~/Instrumented.cshtml", 676, 53, true); - - -#line 42 "Instrumented.cshtml" -} - -#line default -#line hidden -} -} -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/LayoutDirective.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/LayoutDirective.cs index 86c0e0f6ea..f8f62c01d4 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/LayoutDirective.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/LayoutDirective.cs @@ -1,22 +1,17 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; + public class LayoutDirective + { + #line hidden + public LayoutDirective() + { + } -public class LayoutDirective { -#line hidden -public LayoutDirective() { -} -public override void Execute() { -Layout = "~/Foo/Bar/Baz"; -} -} + public override void Execute() + { + Layout = "~/Foo/Bar/Baz"; + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/MarkupInCodeBlock.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/MarkupInCodeBlock.cs index 14a1f096a0..33fafde719 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/MarkupInCodeBlock.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/MarkupInCodeBlock.cs @@ -1,49 +1,36 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class MarkupInCodeBlock { -#line hidden -public MarkupInCodeBlock() { -} -public override void Execute() { + public class MarkupInCodeBlock + { + #line hidden + public MarkupInCodeBlock() + { + } + public override void Execute() + { #line 1 "MarkupInCodeBlock.cshtml" for(int i = 1; i <= 10; i++) { - - #line default #line hidden -WriteLiteral("

Hello from C#, #"); - + WriteLiteral("

Hello from C#, #"); + Write( #line 3 "MarkupInCodeBlock.cshtml" - Write(i.ToString()); - - + i.ToString() #line default #line hidden -WriteLiteral("

\r\n"); - - + ); + WriteLiteral("

\r\n"); #line 4 "MarkupInCodeBlock.cshtml" } - - #line default #line hidden -WriteLiteral("\r\n"); -} -} + WriteLiteral("\r\n"); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NestedCodeBlocks.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NestedCodeBlocks.cs index 424e26c4c1..d41094cb26 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NestedCodeBlocks.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NestedCodeBlocks.cs @@ -1,42 +1,34 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class NestedCodeBlocks { -#line hidden -public NestedCodeBlocks() { -} -public override void Execute() { + public class NestedCodeBlocks + { + #line hidden + public NestedCodeBlocks() + { + } + public override void Execute() + { #line 1 "NestedCodeBlocks.cshtml" if(foo) { - #line default #line hidden #line 2 "NestedCodeBlocks.cshtml" if(bar) { } - #line default #line hidden #line 3 "NestedCodeBlocks.cshtml" } - #line default #line hidden -} -} + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NestedHelpers.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NestedHelpers.cs index 48c0e11469..a610506368 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NestedHelpers.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NestedHelpers.cs @@ -1,111 +1,92 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { -using System; - -public class NestedHelpers { -#line hidden -#line 3 "NestedHelpers.cshtml" -public static Template Bold(string s) { -#line default -#line hidden -return new Template(__razor_helper_writer => { - -#line 3 "NestedHelpers.cshtml" - - s = s.ToUpper(); - - -#line default -#line hidden -WriteLiteralTo(__razor_helper_writer, " "); - - -#line 5 "NestedHelpers.cshtml" -WriteTo(__razor_helper_writer, s); - - -#line default -#line hidden -WriteLiteralTo(__razor_helper_writer, "\r\n"); - - -#line 6 "NestedHelpers.cshtml" - - -#line default -#line hidden -}); - -#line 6 "NestedHelpers.cshtml" -} -#line default -#line hidden +namespace TestOutput +{ + using System; + public class NestedHelpers + { + public static Template #line 1 "NestedHelpers.cshtml" -public static Template Italic(string s) { +Italic(string s) { #line default #line hidden -return new Template(__razor_helper_writer => { - + return new Template((__razor_helper_writer) => { #line 1 "NestedHelpers.cshtml" s = s.ToUpper(); - #line default #line hidden #line 6 "NestedHelpers.cshtml" - - #line default #line hidden -WriteLiteralTo(__razor_helper_writer, " "); - + WriteLiteralTo(__razor_helper_writer, " "); + WriteTo(__razor_helper_writer, #line 7 "NestedHelpers.cshtml" -WriteTo(__razor_helper_writer, Bold(s)); - - + Bold(s) #line default #line hidden -WriteLiteralTo(__razor_helper_writer, "\r\n"); - - + ); + WriteLiteralTo(__razor_helper_writer, "\r\n"); #line 8 "NestedHelpers.cshtml" - - #line default #line hidden -}); + } + ); #line 8 "NestedHelpers.cshtml" } #line default #line hidden -public NestedHelpers() { + public static Template +#line 3 "NestedHelpers.cshtml" +Bold(string s) { +#line default +#line hidden + return new Template((__razor_helper_writer) => { +#line 3 "NestedHelpers.cshtml" + + s = s.ToUpper(); +#line default +#line hidden + + WriteLiteralTo(__razor_helper_writer, " "); + WriteTo(__razor_helper_writer, +#line 5 "NestedHelpers.cshtml" + s +#line default +#line hidden + ); + WriteLiteralTo(__razor_helper_writer, "\r\n"); +#line 6 "NestedHelpers.cshtml" + +#line default +#line hidden + + } + ); +#line 6 "NestedHelpers.cshtml" } -public override void Execute() { -WriteLiteral("\r\n"); +#line default +#line hidden + #line hidden + public NestedHelpers() + { + } + public override void Execute() + { + WriteLiteral("\r\n"); + Write( #line 10 "NestedHelpers.cshtml" -Write(Italic("Hello")); - - + Italic("Hello") #line default #line hidden -} -} + ); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NoLinePragmas.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NoLinePragmas.cs index 3fd500a59b..582a49790d 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NoLinePragmas.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NoLinePragmas.cs @@ -1,102 +1,144 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; + public class NoLinePragmas + { + #line hidden + public NoLinePragmas() + { + } -public class NoLinePragmas { -#line hidden -public NoLinePragmas() { -} -public override void Execute() { + public override void Execute() + { +#line 1 "" int i = 1; +#line default +#line hidden -WriteLiteral("\r\n\r\n"); - + WriteLiteral("\r\n\r\n"); +#line 5 "" while(i <= 10) { +#line default +#line hidden -WriteLiteral("

Hello from C#, #"); - - Write(i); - -WriteLiteral("

\r\n"); - + WriteLiteral("

Hello from C#, #"); + Write( +#line 6 "" + i +#line default +#line hidden + ); + WriteLiteral("

\r\n"); +#line 7 "" i += 1; } +#line default +#line hidden -WriteLiteral("\r\n"); - + WriteLiteral("\r\n"); +#line 10 "" if(i == 11) { +#line default +#line hidden -WriteLiteral("

We wrote 10 lines!

\r\n"); - + WriteLiteral("

We wrote 10 lines!

\r\n"); +#line 12 "" } +#line default +#line hidden -WriteLiteral("\r\n"); - + WriteLiteral("\r\n"); +#line 14 "" switch(i) { case 11: +#line default +#line hidden -WriteLiteral("

No really, we wrote 10 lines!

\r\n"); - + WriteLiteral("

No really, we wrote 10 lines!

\r\n"); +#line 17 "" break; default: +#line default +#line hidden -WriteLiteral("

Actually, we didn\'t...

\r\n"); - + WriteLiteral("

Actually, we didn\'t...

\r\n"); +#line 20 "" break; } +#line default +#line hidden -WriteLiteral("\r\n"); - + WriteLiteral("\r\n"); +#line 23 "" for(int j = 1; j <= 10; j += 2) { +#line default +#line hidden -WriteLiteral("

Hello again from C#, #"); - - Write(j); - -WriteLiteral("

\r\n"); - + WriteLiteral("

Hello again from C#, #"); + Write( +#line 24 "" + j +#line default +#line hidden + ); + WriteLiteral("

\r\n"); +#line 25 "" } +#line default +#line hidden -WriteLiteral("\r\n"); - + WriteLiteral("\r\n"); +#line 27 "" try { +#line default +#line hidden -WriteLiteral("

That time, we wrote 5 lines!

\r\n"); - + WriteLiteral("

That time, we wrote 5 lines!

\r\n"); +#line 29 "" } catch(Exception ex) { +#line default +#line hidden -WriteLiteral("

Oh no! An error occurred: "); - - Write(ex.Message); - -WriteLiteral("

\r\n"); - + WriteLiteral("

Oh no! An error occurred: "); + Write( +#line 30 "" + ex.Message +#line default +#line hidden + ); + WriteLiteral("

\r\n"); +#line 31 "" } +#line default +#line hidden +#line 33 "" +#line default +#line hidden -WriteLiteral("

i is now "); - - Write(i); - -WriteLiteral("

\r\n\r\n"); - + WriteLiteral("

i is now "); + Write( +#line 34 "" + i +#line default +#line hidden + ); + WriteLiteral("

\r\n\r\n"); +#line 36 "" lock(new object()) { +#line default +#line hidden -WriteLiteral("

This block is locked, for your security!

\r\n"); + WriteLiteral("

This block is locked, for your security!

\r\n"); +#line 38 "" +} +#line default +#line hidden -} -} -} + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/OpenedIf.DesignTime.Tabs.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/OpenedIf.DesignTime.Tabs.cs index c64677bbb9..829a32c55a 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/OpenedIf.DesignTime.Tabs.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/OpenedIf.DesignTime.Tabs.cs @@ -1,41 +1,37 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class OpenedIf { -#line hidden -public OpenedIf() { -} -public override void Execute() { - -#line 1 "OpenedIf.cshtml" -if (true) { - - -#line default -#line hidden - -#line 2 "OpenedIf.cshtml" - - - -#line default -#line hidden + public class OpenedIf + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public OpenedIf() + { + } + public override void Execute() + { #line 3 "OpenedIf.cshtml" - - + if (true) { #line default #line hidden -} -} + +#line 4 "OpenedIf.cshtml" + +#line default +#line hidden + +#line 5 "OpenedIf.cshtml" + +#line default +#line hidden + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/OpenedIf.DesignTime.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/OpenedIf.DesignTime.cs index d0f3774358..227383c944 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/OpenedIf.DesignTime.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/OpenedIf.DesignTime.cs @@ -1,41 +1,37 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class OpenedIf { -#line hidden -public OpenedIf() { -} -public override void Execute() { - -#line 1 "OpenedIf.cshtml" -if (true) { - - -#line default -#line hidden - -#line 2 "OpenedIf.cshtml" - - - -#line default -#line hidden + public class OpenedIf + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public OpenedIf() + { + } + public override void Execute() + { #line 3 "OpenedIf.cshtml" - - + if (true) { #line default #line hidden -} -} + +#line 4 "OpenedIf.cshtml" + +#line default +#line hidden + +#line 5 "OpenedIf.cshtml" + +#line default +#line hidden + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ParserError.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ParserError.cs index 79d25e62af..25a8405a71 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ParserError.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ParserError.cs @@ -1,31 +1,31 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class ParserError { -#line hidden -public ParserError() { -} -public override void Execute() { + public class ParserError + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public ParserError() + { + } + public override void Execute() + { #line 1 "ParserError.cshtml" /* int i =10; int j =20; } - #line default #line hidden -} -} + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/RazorComments.DesignTime.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/RazorComments.DesignTime.cs index dc7322289a..0d872a0618 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/RazorComments.DesignTime.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/RazorComments.DesignTime.cs @@ -1,72 +1,63 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; + public class RazorComments + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public RazorComments() + { + } -public class RazorComments { -private static object @__o; -#line hidden -public RazorComments() { -} -public override void Execute() { - -#line 1 "RazorComments.cshtml" + public override void Execute() + { +#line 4 "RazorComments.cshtml" - -#line default -#line hidden - -#line 2 "RazorComments.cshtml" - - Exception foo = - -#line default -#line hidden - -#line 3 "RazorComments.cshtml" - null; - if(foo != null) { - throw foo; - } - - -#line default -#line hidden - -#line 4 "RazorComments.cshtml" - var bar = "@* bar *@"; - #line default #line hidden #line 5 "RazorComments.cshtml" - __o = bar; - - + + Exception foo = #line default #line hidden #line 6 "RazorComments.cshtml" -__o = a - + null; + if(foo != null) { + throw foo; + } #line default #line hidden -#line 7 "RazorComments.cshtml" - b; - - +#line 12 "RazorComments.cshtml" + var bar = "@* bar *@"; #line default #line hidden -} -} + + __o = +#line 13 "RazorComments.cshtml" + bar +#line default +#line hidden + ; + __o = +#line 15 "RazorComments.cshtml" + a +#line default +#line hidden +#line 15 "RazorComments.cshtml" + b +#line default +#line hidden + ; + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/RazorComments.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/RazorComments.cs index 72d45d6011..4651728e81 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/RazorComments.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/RazorComments.cs @@ -1,37 +1,26 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TestOutput { -using System; - -public class RazorComments { -#line hidden -public RazorComments() { -} -public override void Execute() { -WriteLiteral("\r\n

This should "); - -WriteLiteral(" be shown

\r\n\r\n"); +namespace TestOutput +{ + using System; + public class RazorComments + { + #line hidden + public RazorComments() + { + } + public override void Execute() + { + WriteLiteral("\r\n

This should be shown

\r\n\r\n"); #line 4 "RazorComments.cshtml" - #line default #line hidden #line 5 "RazorComments.cshtml" Exception foo = - #line default #line hidden @@ -40,44 +29,34 @@ WriteLiteral(" be shown

\r\n\r\n"); if(foo != null) { throw foo; } - - #line default #line hidden -WriteLiteral("\r\n\r\n"); - + WriteLiteral("\r\n\r\n"); #line 12 "RazorComments.cshtml" var bar = "@* bar *@"; - #line default #line hidden -WriteLiteral("\r\n

But this should show the comment syntax: "); - + WriteLiteral("\r\n

But this should show the comment syntax: "); + Write( #line 13 "RazorComments.cshtml" - Write(bar); - - + bar #line default #line hidden -WriteLiteral("

\r\n\r\n"); - - + ); + WriteLiteral("

\r\n\r\n"); + Write( #line 15 "RazorComments.cshtml" -Write(a - + a #line default #line hidden - #line 15 "RazorComments.cshtml" - b); - - + b #line default #line hidden -WriteLiteral("\r\n"); - -} -} + ); + WriteLiteral("\r\n"); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ResolveUrl.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ResolveUrl.cs index f99f1ec199..26394f77c4 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ResolveUrl.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ResolveUrl.cs @@ -1,230 +1,131 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class ResolveUrl { -#line hidden -public ResolveUrl() { -} -public override void Execute() { -WriteLiteral("(Href("~/Foo") -, 9), false) -); - -WriteLiteral(">Foo\r\n(Href("~/Products/") -, 34), false) + public class ResolveUrl + { + #line hidden + public ResolveUrl() + { + } + public override void Execute() + { + WriteLiteral("(Href("~/Foo"), 9), false)); + WriteLiteral(">Foo\r\n(Href("~/Products/"), 34), false), + Tuple.Create(Tuple.Create("", 45), Tuple.Create( #line 2 "ResolveUrl.cshtml" -, Tuple.Create(Tuple.Create("", 45), Tuple.Create(product.id - + product.id #line default #line hidden -, 45), false) -); - -WriteLiteral(">"); - - + , 45), false)); + WriteLiteral(">"); + Write( #line 2 "ResolveUrl.cshtml" - Write(product.Name); - - + product.Name #line default #line hidden -WriteLiteral("\r\n(Href("~/Products/") -, 86), false) - + ); + WriteLiteral("\r\n(Href("~/Products/"), 86), false), + Tuple.Create(Tuple.Create("", 97), Tuple.Create( #line 3 "ResolveUrl.cshtml" -, Tuple.Create(Tuple.Create("", 97), Tuple.Create(product.id - + product.id #line default #line hidden -, 97), false) -, Tuple.Create(Tuple.Create("", 108), Tuple.Create("/Detail", 108), true) -); - -WriteLiteral(">Details\r\n(Href("~/A+Really(Crazy),Url.Is:This/") -, 139), false) - + , 97), false), Tuple.Create(Tuple.Create("", 108), Tuple.Create("/Detail", 108), true)); + WriteLiteral(">Details\r\n(Href("~/A+Really(Crazy),Url.Is:This/"), 139), false), + Tuple.Create(Tuple.Create("", 169), Tuple.Create( #line 4 "ResolveUrl.cshtml" -, Tuple.Create(Tuple.Create("", 169), Tuple.Create(product.id - + product.id #line default #line hidden -, 169), false) -, Tuple.Create(Tuple.Create("", 180), Tuple.Create("/Detail", 180), true) -); - -WriteLiteral(">Crazy Url!\r\n\r\n"); - - + , 169), false), Tuple.Create(Tuple.Create("", 180), Tuple.Create("/Detail", 180), true)); + WriteLiteral(">Crazy Url!\r\n\r\n"); #line 6 "ResolveUrl.cshtml" - - #line default #line hidden -WriteLiteral(" "); - -WriteLiteral("\r\n (Href("~/Foo") -, 240), false) -); - -WriteLiteral(">Foo\r\n (Href("~/Products/") -, 273), false) + WriteLiteral(" \r\n (Href("~/Foo"), 240), false)); + WriteLiteral(">Foo\r\n (Href("~/Products/"), 273), false), + Tuple.Create(Tuple.Create("", 284), Tuple.Create( #line 9 "ResolveUrl.cshtml" -, Tuple.Create(Tuple.Create("", 284), Tuple.Create(product.id - + product.id #line default #line hidden -, 284), false) -); - -WriteLiteral(">"); - - + , 284), false)); + WriteLiteral(">"); + Write( #line 9 "ResolveUrl.cshtml" - Write(product.Name); - - + product.Name #line default #line hidden -WriteLiteral("\r\n (Href("~/Products/") -, 333), false) - + ); + WriteLiteral("\r\n (Href("~/Products/"), 333), false), + Tuple.Create(Tuple.Create("", 344), Tuple.Create( #line 10 "ResolveUrl.cshtml" -, Tuple.Create(Tuple.Create("", 344), Tuple.Create(product.id - + product.id #line default #line hidden -, 344), false) -, Tuple.Create(Tuple.Create("", 355), Tuple.Create("/Detail", 355), true) -); - -WriteLiteral(">Details\r\n (Href("~/A+Really(Crazy),Url.Is:This/") -, 394), false) - + , 344), false), Tuple.Create(Tuple.Create("", 355), Tuple.Create("/Detail", 355), true)); + WriteLiteral(">Details\r\n (Href("~/A+Really(Crazy),Url.Is:This/"), 394), false), + Tuple.Create(Tuple.Create("", 424), Tuple.Create( #line 11 "ResolveUrl.cshtml" -, Tuple.Create(Tuple.Create("", 424), Tuple.Create(product.id - + product.id #line default #line hidden -, 424), false) -, Tuple.Create(Tuple.Create("", 435), Tuple.Create("/Detail", 435), true) -); - -WriteLiteral(">Crazy Url!\r\n "); - -WriteLiteral("\r\n"); - - + , 424), false), Tuple.Create(Tuple.Create("", 435), Tuple.Create("/Detail", 435), true)); + WriteLiteral(">Crazy Url!\r\n \r\n"); #line 13 "ResolveUrl.cshtml" - - #line default #line hidden -WriteLiteral("\r\n\r\n"); - -DefineSection("Foo", () => { - -WriteLiteral("\r\n (Href("~/Foo") -, 507), false) -); - -WriteLiteral(">Foo\r\n (Href("~/Products/") -, 536), false) + WriteLiteral("\r\n\r\n"); + DefineSection("Foo", () => { + WriteLiteral("\r\n (Href("~/Foo"), 507), false)); + WriteLiteral(">Foo\r\n (Href("~/Products/"), 536), false), + Tuple.Create(Tuple.Create("", 547), Tuple.Create( #line 17 "ResolveUrl.cshtml" -, Tuple.Create(Tuple.Create("", 547), Tuple.Create(product.id - + product.id #line default #line hidden -, 547), false) -); - -WriteLiteral(">"); - - + , 547), false)); + WriteLiteral(">"); + Write( #line 17 "ResolveUrl.cshtml" - Write(product.Name); - - + product.Name #line default #line hidden -WriteLiteral("\r\n (Href("~/Products/") -, 592), false) - + ); + WriteLiteral("\r\n (Href("~/Products/"), 592), false), + Tuple.Create(Tuple.Create("", 603), Tuple.Create( #line 18 "ResolveUrl.cshtml" -, Tuple.Create(Tuple.Create("", 603), Tuple.Create(product.id - + product.id #line default #line hidden -, 603), false) -, Tuple.Create(Tuple.Create("", 614), Tuple.Create("/Detail", 614), true) -); - -WriteLiteral(">Details\r\n (Href("~/A+Really(Crazy),Url.Is:This/") -, 649), false) - + , 603), false), Tuple.Create(Tuple.Create("", 614), Tuple.Create("/Detail", 614), true)); + WriteLiteral(">Details\r\n (Href("~/A+Really(Crazy),Url.Is:This/"), 649), false), + Tuple.Create(Tuple.Create("", 679), Tuple.Create( #line 19 "ResolveUrl.cshtml" -, Tuple.Create(Tuple.Create("", 679), Tuple.Create(product.id - + product.id #line default #line hidden -, 679), false) -, Tuple.Create(Tuple.Create("", 690), Tuple.Create("/Detail", 690), true) -); - -WriteLiteral(">Crazy Url!\r\n"); - -}); - -} -} + , 679), false), Tuple.Create(Tuple.Create("", 690), Tuple.Create("/Detail", 690), true)); + WriteLiteral(">Crazy Url!\r\n"); + } + ); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Sections.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Sections.cs index 13f24b7344..bf6ac1a58a 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Sections.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Sections.cs @@ -1,45 +1,32 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class Sections { -#line hidden -public Sections() { -} -public override void Execute() { + public class Sections + { + #line hidden + public Sections() + { + } + public override void Execute() + { #line 1 "Sections.cshtml" Layout = "_SectionTestLayout.cshtml" - - #line default #line hidden -WriteLiteral("\r\n\r\n
This is in the Body>\r\n\r\n"); - -DefineSection("Section2", () => { - -WriteLiteral("\r\n
This is in Section 2
\r\n"); - -}); - -WriteLiteral("\r\n"); - -DefineSection("Section1", () => { - -WriteLiteral("\r\n
This is in Section 1
\r\n"); - -}); -} -} + WriteLiteral("\r\n\r\n
This is in the Body>\r\n\r\n"); + DefineSection("Section2", () => { + WriteLiteral("\r\n
This is in Section 2
\r\n"); + } + ); + WriteLiteral("\r\n"); + DefineSection("Section1", () => { + WriteLiteral("\r\n
This is in Section 1
\r\n"); + } + ); + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/SimpleUnspacedIf.DesignTime.Tabs.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/SimpleUnspacedIf.DesignTime.Tabs.cs index 3374bdbdab..fd0442ecb9 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/SimpleUnspacedIf.DesignTime.Tabs.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/SimpleUnspacedIf.DesignTime.Tabs.cs @@ -1,36 +1,35 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class SimpleUnspacedIf { -#line hidden -public SimpleUnspacedIf() { -} -public override void Execute() { + public class SimpleUnspacedIf + { + private static object @__o; + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public SimpleUnspacedIf() + { + } + public override void Execute() + { #line 1 "SimpleUnspacedIf.cshtml" -if (true) + if (true) { - #line default #line hidden -#line 2 "SimpleUnspacedIf.cshtml" +#line 3 "SimpleUnspacedIf.cshtml" } - #line default #line hidden -} -} + + } + } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Templates.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Templates.cs index 8131acf7ed..cdd0317600 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Templates.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Templates.cs @@ -1,18 +1,9 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:N.N.NNNNN.N -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ +namespace TestOutput +{ + using System; -namespace TestOutput { -using System; - -public class Templates { -#line hidden + public class Templates + { #line 1 "Templates.cshtml" public HelperResult Repeat(int times, Func template) { @@ -22,159 +13,130 @@ public class Templates { } }); } - #line default #line hidden + #line hidden + public Templates() + { + } -public Templates() { -} -public override void Execute() { -WriteLiteral("\r\n"); - - + public override void Execute() + { + WriteLiteral("\r\n"); #line 11 "Templates.cshtml" Func foo = - #line default #line hidden -item => new Template(__razor_template_writer => { - -WriteLiteralTo(__razor_template_writer, "This works "); - + item => new Template((__razor_template_writer) => { + WriteLiteralTo(__razor_template_writer, "This works "); + WriteTo(__razor_template_writer, #line 12 "Templates.cshtml" - WriteTo(__razor_template_writer, item); - - + item #line default #line hidden -WriteLiteralTo(__razor_template_writer, "!"); - -}) - + ); + WriteLiteralTo(__razor_template_writer, "!"); + } + ) #line 12 "Templates.cshtml" ; - #line default #line hidden + Write( #line 13 "Templates.cshtml" -Write(foo("")); - - + foo("") #line default #line hidden - + ); #line 13 "Templates.cshtml" - - #line default #line hidden -WriteLiteral("\r\n\r\n
    \r\n"); - + WriteLiteral("\r\n\r\n
      \r\n"); + Write( #line 17 "Templates.cshtml" -Write(Repeat(10, item => new Template(__razor_template_writer => { - - + Repeat(10, #line default #line hidden -WriteLiteralTo(__razor_template_writer, "
    • Item #"); - - + item => new Template((__razor_template_writer) => { + WriteLiteralTo(__razor_template_writer, "
    • Item #"); + WriteTo(__razor_template_writer, #line 17 "Templates.cshtml" -WriteTo(__razor_template_writer, item); - - + item #line default #line hidden -WriteLiteralTo(__razor_template_writer, "
    • "); - - + ); + WriteLiteralTo(__razor_template_writer, ""); + } + ) #line 17 "Templates.cshtml" - }))); - - + ) #line default #line hidden -WriteLiteral("\r\n
    \r\n\r\n

    \r\n"); - - + ); + WriteLiteral("\r\n

\r\n\r\n

\r\n"); + Write( #line 21 "Templates.cshtml" -Write(Repeat(10, - item => new Template(__razor_template_writer => { - - + Repeat(10, + #line default #line hidden -WriteLiteralTo(__razor_template_writer, " This is line#"); - - + item => new Template((__razor_template_writer) => { + WriteLiteralTo(__razor_template_writer, " This is line#"); + WriteTo(__razor_template_writer, #line 22 "Templates.cshtml" -WriteTo(__razor_template_writer, item); - - + item #line default #line hidden -WriteLiteralTo(__razor_template_writer, " of markup
\r\n"); - - + ); + WriteLiteralTo(__razor_template_writer, " of markup
\r\n"); + } + ) #line 23 "Templates.cshtml" -}))); - - +) #line default #line hidden -WriteLiteral("\r\n

\r\n\r\n