Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,27 @@ @inherits MyBase
CompileToAssembly(generated);
}

[Fact, WorkItem("https://github.com/dotnet/razor/issues/10965")]
public void InvalidCode_EmptyImplicitExpression_Runtime()
{
// Act
var generated = CompileToCSharp("""
<html>
<head>
@
</head>
</html>
""", designTime: false);

// Assert
var intermediate = generated.CodeDocument.GetDocumentIntermediateNode();
var csharp = generated.CodeDocument.GetCSharpDocument();
AssertDocumentNodeMatchesBaseline(intermediate);
AssertCSharpDocumentMatchesBaseline(csharp);
AssertSourceMappingsMatchBaseline(generated.CodeDocument);
CompileToAssembly(generated, throwOnFailure: false, ignoreRazorDiagnostics: true);
}

#endregion

#region DesignTime
Expand Down Expand Up @@ -1516,6 +1537,26 @@ @inherits MyBase
CompileToAssembly(generated);
}

[Fact, WorkItem("https://github.com/dotnet/razor/issues/10965")]
public void InvalidCode_EmptyImplicitExpression_DesignTime()
{
// Act
var generated = CompileToCSharp("""
<html>
<head>
@
</head>
</html>
""", designTime: true);

// Assert
var intermediate = generated.CodeDocument.GetDocumentIntermediateNode();
var csharp = generated.CodeDocument.GetCSharpDocument();
AssertDocumentNodeMatchesBaseline(intermediate);
AssertCSharpDocumentMatchesBaseline(csharp);
CompileToAssembly(generated, throwOnFailure: false, ignoreRazorDiagnostics: true);
}

#endregion

[Theory, CombinatorialData, WorkItem("https://github.com/dotnet/razor/issues/7286")]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// <auto-generated/>
#pragma warning disable 1591
namespace AspNetCoreGeneratedDocument
{
#line default
using TModel = global::System.Object;
using global::System;
using global::System.Collections.Generic;
using global::System.Linq;
using global::System.Threading.Tasks;
using global::Microsoft.AspNetCore.Mvc;
using global::Microsoft.AspNetCore.Mvc.Rendering;
using global::Microsoft.AspNetCore.Mvc.ViewFeatures;
#line default
#line hidden
[global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemMetadataAttribute("Identifier", "/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/test.cshtml")]
[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdateAttribute]
#nullable restore
internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
#nullable disable
{
#line hidden
#pragma warning disable 0649
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext __tagHelperExecutionContext;
#pragma warning restore 0649
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner __tagHelperRunner = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner();
private global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper;
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
#pragma warning disable 0414
private static object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
public async override global::System.Threading.Tasks.Task ExecuteAsync()
{
#nullable restore
#line 3 "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml"
__o = ;

#line default
#line hidden
#nullable disable
__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper = CreateTagHelper<global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper>();
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
}
#pragma warning restore 1998
#nullable restore
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; } = default!;
#nullable disable
#nullable restore
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; } = default!;
#nullable disable
#nullable restore
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; } = default!;
#nullable disable
#nullable restore
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } = default!;
#nullable disable
#nullable restore
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; } = default!;
#nullable disable
}
}
#pragma warning restore 1591
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml(3,10): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Document -
NamespaceDeclaration - - AspNetCoreGeneratedDocument
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [20] ) - global::System
UsingDirective - (24:1,1 [40] ) - global::System.Collections.Generic
UsingDirective - (67:2,1 [25] ) - global::System.Linq
UsingDirective - (95:3,1 [36] ) - global::System.Threading.Tasks
UsingDirective - (134:4,1 [38] ) - global::Microsoft.AspNetCore.Mvc
UsingDirective - (175:5,1 [48] ) - global::Microsoft.AspNetCore.Mvc.Rendering
UsingDirective - (226:6,1 [51] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures
RazorCompiledItemMetadataAttribute -
CreateNewOnMetadataUpdateAttribute -
ClassDeclaration - - internal sealed - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic> -
DefaultTagHelperRuntime -
FieldDeclaration - - private - global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper - __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper
DesignTimeDirective -
DirectiveToken - (287:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>
DirectiveToken - (350:7,71 [4] ) - Html
DirectiveToken - (364:8,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper
DirectiveToken - (419:8,63 [4] ) - Json
DirectiveToken - (433:9,8 [53] ) - global::Microsoft.AspNetCore.Mvc.IViewComponentHelper
DirectiveToken - (487:9,62 [9] ) - Component
DirectiveToken - (506:10,8 [43] ) - global::Microsoft.AspNetCore.Mvc.IUrlHelper
DirectiveToken - (550:10,52 [3] ) - Url
DirectiveToken - (563:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
DirectiveToken - (634:11,79 [23] ) - ModelExpressionProvider
DirectiveToken - (673:12,14 [104] ) - global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor
DirectiveToken - (793:13,14 [95] ) - global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor
DirectiveToken - (904:14,14 [95] ) - global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
CSharpCode -
IntermediateToken - - CSharp - private static object __o = null;
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
HtmlContent - (0:0,0 [12] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml)
LazyIntermediateToken - (0:0,0 [5] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - <html
LazyIntermediateToken - (5:0,5 [1] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - >
LazyIntermediateToken - (6:0,6 [6] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
TagHelper - (12:1,4 [30] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - head - TagMode.StartTagAndEndTag
DefaultTagHelperBody -
HtmlContent - (18:1,10 [10] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml)
LazyIntermediateToken - (18:1,10 [10] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
CSharpExpression - (29:2,9 [0] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml)
LazyIntermediateToken - (29:2,9 [0] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - CSharp -
HtmlContent - (29:2,9 [6] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml)
LazyIntermediateToken - (29:2,9 [6] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
DefaultTagHelperCreate - - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper
DefaultTagHelperExecute -
HtmlContent - (42:3,11 [9] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml)
LazyIntermediateToken - (42:3,11 [2] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - \n
LazyIntermediateToken - (44:4,0 [7] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml) - Html - </html>
Inject -
Inject -
Inject -
Inject -
Inject -
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#pragma checksum "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "e297cf93ff7f33ab02330169876f3e695dc26e57f3b7b474cac407efa4bed6a0"
// <auto-generated/>
#pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCoreGeneratedDocument.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/test.cshtml")]
namespace AspNetCoreGeneratedDocument
{
#line default
using global::System;
using global::System.Collections.Generic;
using global::System.Linq;
using global::System.Threading.Tasks;
using global::Microsoft.AspNetCore.Mvc;
using global::Microsoft.AspNetCore.Mvc.Rendering;
using global::Microsoft.AspNetCore.Mvc.ViewFeatures;
#line default
#line hidden
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"Sha256", @"e297cf93ff7f33ab02330169876f3e695dc26e57f3b7b474cac407efa4bed6a0", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/test.cshtml")]
[global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemMetadataAttribute("Identifier", "/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/test.cshtml")]
[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdateAttribute]
#nullable restore
internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_test : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
#nullable disable
{
#line hidden
#pragma warning disable 0649
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext __tagHelperExecutionContext;
#pragma warning restore 0649
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner __tagHelperRunner = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner();
#pragma warning disable 0169
private string __tagHelperStringValueBuffer;
#pragma warning restore 0169
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager __backed__tagHelperScopeManager = null;
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager __tagHelperScopeManager
{
get
{
if (__backed__tagHelperScopeManager == null)
{
__backed__tagHelperScopeManager = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager(StartTagHelperWritingScope, EndTagHelperWritingScope);
}
return __backed__tagHelperScopeManager;
}
}
private global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper;
#pragma warning disable 1998
public async override global::System.Threading.Tasks.Task ExecuteAsync()
{
WriteLiteral("<html>\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("head", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "__UniqueIdSuppressedForTesting__", async() => {
WriteLiteral("\r\n ");
Write(
#nullable restore
#line (3,10)-(3,10) "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml"

#line default
#line hidden
#nullable disable
);
WriteLiteral("\r\n ");
}
);
__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper = CreateTagHelper<global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper>();
__tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper);
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
if (!__tagHelperExecutionContext.Output.IsContentModified)
{
await __tagHelperExecutionContext.SetOutputContentAsync();
}
Write(__tagHelperExecutionContext.Output);
__tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral("\r\n</html>");
}
#pragma warning restore 1998
#nullable restore
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; } = default!;
#nullable disable
#nullable restore
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; } = default!;
#nullable disable
#nullable restore
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; } = default!;
#nullable disable
#nullable restore
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } = default!;
#nullable disable
#nullable restore
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; } = default!;
#nullable disable
}
}
#pragma warning restore 1591
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TestFiles\IntegrationTests\CodeGenerationIntegrationTest\test.cshtml(3,10): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between.
Loading