diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcViewDocumentClassifierPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcViewDocumentClassifierPassTest.cs index e503c1a0ed7..1113bcce6a6 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcViewDocumentClassifierPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcViewDocumentClassifierPassTest.cs @@ -86,7 +86,7 @@ public void MvcViewDocumentClassifierPass_SetsClass() Assert.NotNull(baseNode.ModelType); Assert.Equal("TModel", baseNode.ModelType.Content); Assert.Equal(["public"], classNode.Modifiers); - Assert.Equal("Test", classNode.Name); + Assert.Equal("Test", classNode.Name.Content); } [Fact] @@ -109,7 +109,7 @@ public void MvcViewDocumentClassifierPass_NullFilePath_SetsClass() Assert.NotNull(baseNode.ModelType); Assert.Equal("TModel", baseNode.ModelType.Content); Assert.Equal(["public"], classNode.Modifiers); - Assert.Equal("AspNetCore_ec563e63d931b806184cb02f79875e4f3b21d1ca043ad06699424459128b58c0", classNode.Name); + Assert.Equal("AspNetCore_ec563e63d931b806184cb02f79875e4f3b21d1ca043ad06699424459128b58c0", classNode.Name.Content); } [Theory] @@ -129,7 +129,7 @@ public void MvcViewDocumentClassifierPass_UsesRelativePathToGenerateTypeName(str var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal(expected, classNode.Name); + Assert.Equal(expected, classNode.Name.Content); } [Fact] @@ -147,7 +147,7 @@ public void MvcViewDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSe var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal("x___application_Views_Home_Index", classNode.Name); + Assert.Equal("x___application_Views_Home_Index", classNode.Name.Content); } [Fact] @@ -165,7 +165,7 @@ public void MvcViewDocumentClassifierPass_SanitizesClassName() var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal("path_with_invalid_chars", classNode.Name); + Assert.Equal("path_with_invalid_chars", classNode.Name.Content); } [Fact] diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/AssemblyAttributeInjectionPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/AssemblyAttributeInjectionPassTest.cs index e5bd6901667..40e04699893 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/AssemblyAttributeInjectionPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/AssemblyAttributeInjectionPassTest.cs @@ -68,36 +68,6 @@ public void Execute_NoOps_IfClassNameNodeIsMissing() Assert.Same(@namespace, node); } - [Fact] - public void Execute_NoOps_IfClassNameIsEmpty() - { - // Arrange - var codeDocument = ProjectEngine.CreateEmptyCodeDocument(); - var documentNode = new DocumentIntermediateNode() { Options = codeDocument.CodeGenerationOptions }; - - var builder = IntermediateNodeBuilder.Create(documentNode); - - var @namespace = new NamespaceDeclarationIntermediateNode() - { - Name = "SomeNamespace", - IsPrimaryNamespace = true, - }; - - builder.Push(@namespace); - - builder.Add(new ClassDeclarationIntermediateNode - { - IsPrimaryClass = true, - }); - - // Act - ProjectEngine.ExecutePass(codeDocument, documentNode); - - // Assert - var node = Assert.Single(documentNode.Children); - Assert.Same(@namespace, node); - } - [Fact] public void Execute_NoOps_IfDocumentIsNotViewOrPage() { @@ -115,7 +85,7 @@ public void Execute_NoOps_IfDocumentIsNotViewOrPage() var @class = new ClassDeclarationIntermediateNode { - Name = "SomeName", + Name = IntermediateNodeFactory.CSharpToken("SomeName"), IsPrimaryClass = true, }; @@ -153,7 +123,7 @@ public void Execute_NoOps_ForDesignTime() var @class = new ClassDeclarationIntermediateNode { - Name = "SomeName", + Name = IntermediateNodeFactory.CSharpToken("SomeName"), IsPrimaryClass = true, }; @@ -193,7 +163,7 @@ public void Execute_AddsRazorViewAttribute_ToViews() builder.Push(@namespace); var @class = new ClassDeclarationIntermediateNode { - Name = "SomeName", + Name = IntermediateNodeFactory.CSharpToken("SomeName"), IsPrimaryClass = true, }; @@ -240,7 +210,7 @@ public void Execute_EscapesViewPathWhenAddingAttributeToViews() var @class = new ClassDeclarationIntermediateNode { - Name = "SomeName", + Name = IntermediateNodeFactory.CSharpToken("SomeName"), IsPrimaryClass = true, }; @@ -294,7 +264,7 @@ public void Execute_AddsRazorPagettribute_ToPage() var @class = new ClassDeclarationIntermediateNode { - Name = "SomeName", + Name = IntermediateNodeFactory.CSharpToken("SomeName"), IsPrimaryClass = true, }; @@ -341,7 +311,7 @@ public void Execute_EscapesViewPathAndRouteWhenAddingAttributeToPage() var @class = new ClassDeclarationIntermediateNode { - Name = "SomeName", + Name = IntermediateNodeFactory.CSharpToken("SomeName"), IsPrimaryClass = true, }; diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcViewDocumentClassifierPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcViewDocumentClassifierPassTest.cs index 5812a7fca61..f41190ecb45 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcViewDocumentClassifierPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcViewDocumentClassifierPassTest.cs @@ -86,7 +86,7 @@ public void MvcViewDocumentClassifierPass_SetsClass() Assert.NotNull(baseNode.ModelType); Assert.Equal("TModel", baseNode.ModelType.Content); Assert.Equal(["public"], classNode.Modifiers); - Assert.Equal("Test", classNode.Name); + Assert.Equal("Test", classNode.Name.Content); } [Fact] @@ -109,7 +109,7 @@ public void MvcViewDocumentClassifierPass_NullFilePath_SetsClass() Assert.NotNull(baseNode.ModelType); Assert.Equal("TModel", baseNode.ModelType.Content); Assert.Equal(["public"], classNode.Modifiers); - Assert.Equal("AspNetCore_ec563e63d931b806184cb02f79875e4f3b21d1ca043ad06699424459128b58c0", classNode.Name); + Assert.Equal("AspNetCore_ec563e63d931b806184cb02f79875e4f3b21d1ca043ad06699424459128b58c0", classNode.Name.Content); } [Theory] @@ -129,7 +129,7 @@ public void MvcViewDocumentClassifierPass_UsesRelativePathToGenerateTypeName(str var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal(expected, classNode.Name); + Assert.Equal(expected, classNode.Name.Content); } [Fact] @@ -147,7 +147,7 @@ public void MvcViewDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSe var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal("x___application_Views_Home_Index", classNode.Name); + Assert.Equal("x___application_Views_Home_Index", classNode.Name.Content); } [Fact] @@ -165,7 +165,7 @@ public void MvcViewDocumentClassifierPass_SanitizesClassName() var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal("path_with_invalid_chars", classNode.Name); + Assert.Equal("path_with_invalid_chars", classNode.Name.Content); } [Fact] diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/NamespaceDirectiveTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/NamespaceDirectiveTest.cs index 20444b08aac..3a1525ea506 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/NamespaceDirectiveTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/NamespaceDirectiveTest.cs @@ -133,7 +133,7 @@ public void Pass_SetsNamespace_ComputedFromImports() var @namespace = new NamespaceDeclarationIntermediateNode() { Name = "default" }; builder.Push(@namespace); - var @class = new ClassDeclarationIntermediateNode() { Name = "default" }; + var @class = new ClassDeclarationIntermediateNode() { Name = IntermediateNodeFactory.CSharpToken("default") }; builder.Add(@class); documentNode.DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind; @@ -143,7 +143,7 @@ public void Pass_SetsNamespace_ComputedFromImports() // Assert Assert.Equal("WebApplication.Account.Manage", @namespace.Name); - Assert.Equal("default", @class.Name); + Assert.Equal("default", @class.Name.Content); } // This is the case where the source file sets the namespace. @@ -180,7 +180,7 @@ public void Pass_SetsNamespace_ComputedFromSource() var @namespace = new NamespaceDeclarationIntermediateNode() { Name = "default" }; builder.Push(@namespace); - var @class = new ClassDeclarationIntermediateNode() { Name = "default" }; + var @class = new ClassDeclarationIntermediateNode() { Name = IntermediateNodeFactory.CSharpToken("default") }; builder.Add(@class); documentNode.DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind; @@ -190,7 +190,7 @@ public void Pass_SetsNamespace_ComputedFromSource() // Assert Assert.Equal("WebApplication.Account.Manage", @namespace.Name); - Assert.Equal("default", @class.Name); + Assert.Equal("default", @class.Name.Content); } // Handles cases where invalid characters appears in FileNames. Note that we don't sanitize the part of @@ -217,7 +217,7 @@ public void Pass_SetsNamespace_SanitizesClassAndNamespace() var @namespace = new NamespaceDeclarationIntermediateNode() { Name = "default" }; builder.Push(@namespace); - var @class = new ClassDeclarationIntermediateNode() { Name = "default" }; + var @class = new ClassDeclarationIntermediateNode() { Name = IntermediateNodeFactory.CSharpToken("default") }; builder.Add(@class); documentNode.DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind; @@ -227,7 +227,7 @@ public void Pass_SetsNamespace_SanitizesClassAndNamespace() // Assert Assert.Equal("WebApplication.Account.Manage_Info", @namespace.Name); - Assert.Equal("default", @class.Name); + Assert.Equal("default", @class.Name.Content); } // This is the case where the source file sets the namespace. @@ -264,7 +264,7 @@ public void Pass_SetsNamespace_ComputedFromSource_ForView() var @namespace = new NamespaceDeclarationIntermediateNode() { Name = "default" }; builder.Push(@namespace); - var @class = new ClassDeclarationIntermediateNode() { Name = "default" }; + var @class = new ClassDeclarationIntermediateNode() { Name = IntermediateNodeFactory.CSharpToken("default") }; builder.Add(@class); documentNode.DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind; @@ -274,7 +274,7 @@ public void Pass_SetsNamespace_ComputedFromSource_ForView() // Assert Assert.Equal("WebApplication.Account.Manage", @namespace.Name); - Assert.Equal("default", @class.Name); + Assert.Equal("default", @class.Name.Content); } // This handles an error case where we can't determine the relationship between the @@ -301,7 +301,7 @@ public void Pass_SetsNamespace_VerbatimFromImports() var @namespace = new NamespaceDeclarationIntermediateNode() { Name = "default" }; builder.Push(@namespace); - var @class = new ClassDeclarationIntermediateNode() { Name = "default" }; + var @class = new ClassDeclarationIntermediateNode() { Name = IntermediateNodeFactory.CSharpToken("default") }; builder.Add(@class); documentNode.DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind; @@ -311,7 +311,7 @@ public void Pass_SetsNamespace_VerbatimFromImports() // Assert Assert.Equal("WebApplication.Account", @namespace.Name); - Assert.Equal("default", @class.Name); + Assert.Equal("default", @class.Name.Content); } [Fact] @@ -336,7 +336,7 @@ public void Pass_DoesNothing_ForUnknownDocumentKind() var @namespace = new NamespaceDeclarationIntermediateNode() { Name = "default" }; builder.Push(@namespace); - var @class = new ClassDeclarationIntermediateNode() { Name = "default" }; + var @class = new ClassDeclarationIntermediateNode() { Name = IntermediateNodeFactory.CSharpToken("default") }; builder.Add(@class); documentNode.DocumentKind = null; @@ -346,6 +346,6 @@ public void Pass_DoesNothing_ForUnknownDocumentKind() // Assert Assert.Equal("default", @namespace.Name); - Assert.Equal("default", @class.Name); + Assert.Equal("default", @class.Name.Content); } } diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/RazorPageDocumentClassifierPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/RazorPageDocumentClassifierPassTest.cs index 2f9dd0b0045..1cb37747198 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/RazorPageDocumentClassifierPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/RazorPageDocumentClassifierPassTest.cs @@ -199,7 +199,7 @@ public void RazorPageDocumentClassifierPass_SetsClass() Assert.Equal("global::Microsoft.AspNetCore.Mvc.RazorPages.Page", classNode.BaseType?.BaseType.Content); Assert.Equal(["public"], classNode.Modifiers); - Assert.Equal("Test", classNode.Name); + Assert.Equal("Test", classNode.Name.Content); } [Fact] @@ -219,7 +219,7 @@ public void RazorPageDocumentClassifierPass_NullFilePath_SetsClass() Assert.Equal("global::Microsoft.AspNetCore.Mvc.RazorPages.Page", classNode.BaseType?.BaseType.Content); Assert.Equal(["public"], classNode.Modifiers); - Assert.Equal("AspNetCore_c3b458108610c1a2aa6eede0a5685ede853e036732db515609b2a23ca15359e1", classNode.Name); + Assert.Equal("AspNetCore_c3b458108610c1a2aa6eede0a5685ede853e036732db515609b2a23ca15359e1", classNode.Name.Content); } [Theory] @@ -239,7 +239,7 @@ public void RazorPageDocumentClassifierPass_UsesRelativePathToGenerateTypeName(s var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal(expected, classNode.Name); + Assert.Equal(expected, classNode.Name.Content); } [Fact] @@ -257,7 +257,7 @@ public void RazorPageDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNot var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal("x___application_Views_Home_Index", classNode.Name); + Assert.Equal("x___application_Views_Home_Index", classNode.Name.Content); } [Fact] @@ -275,7 +275,7 @@ public void RazorPageDocumentClassifierPass_SanitizesClassName() var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal("path_with_invalid_chars", classNode.Name); + Assert.Equal("path_with_invalid_chars", classNode.Name!.Content); } [Fact] diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ConsolidatedMvcViewDocumentClassifierPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ConsolidatedMvcViewDocumentClassifierPassTest.cs index 0636149efd4..2c21c9ec24e 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ConsolidatedMvcViewDocumentClassifierPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ConsolidatedMvcViewDocumentClassifierPassTest.cs @@ -54,7 +54,7 @@ public void ConsolidatedMvcViewDocumentClassifierPass_SetsClass() Assert.NotNull(baseNode.ModelType); Assert.Equal("TModel", baseNode.ModelType.Content); Assert.Equal(["internal", "sealed"], classNode.Modifiers); - Assert.Equal("Test", classNode.Name); + Assert.Equal("Test", classNode.Name.Content); } [Fact] @@ -77,7 +77,7 @@ public void MvcViewDocumentClassifierPass_NullFilePath_SetsClass() Assert.NotNull(baseNode.ModelType); Assert.Equal("TModel", baseNode.ModelType.Content); Assert.Equal(["internal", "sealed"], classNode.Modifiers); - AssertEx.Equal("AspNetCore_ec563e63d931b806184cb02f79875e4f3b21d1ca043ad06699424459128b58c0", classNode.Name); + AssertEx.Equal("AspNetCore_ec563e63d931b806184cb02f79875e4f3b21d1ca043ad06699424459128b58c0", classNode.Name.Content); } [Theory] @@ -97,7 +97,7 @@ public void ConsolidatedMvcViewDocumentClassifierPass_UsesRelativePathToGenerate var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal(expected, classNode.Name); + Assert.Equal(expected, classNode.Name.Content); Assert.Equal(["internal", "sealed"], classNode.Modifiers); } diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcViewDocumentClassifierPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcViewDocumentClassifierPassTest.cs index 27ce64a166a..ff66cfdb4a5 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcViewDocumentClassifierPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcViewDocumentClassifierPassTest.cs @@ -86,7 +86,7 @@ public void MvcViewDocumentClassifierPass_SetsClass() Assert.NotNull(baseNode.ModelType); Assert.Equal("TModel", baseNode.ModelType.Content); Assert.Equal(["public"], classNode.Modifiers); - Assert.Equal("Test", classNode.Name); + Assert.Equal("Test", classNode.Name.Content); } [Fact] @@ -109,7 +109,7 @@ public void MvcViewDocumentClassifierPass_NullFilePath_SetsClass() Assert.NotNull(baseNode.ModelType); Assert.Equal("TModel", baseNode.ModelType.Content); Assert.Equal(["public"], classNode.Modifiers); - Assert.Equal("AspNetCore_ec563e63d931b806184cb02f79875e4f3b21d1ca043ad06699424459128b58c0", classNode.Name); + Assert.Equal("AspNetCore_ec563e63d931b806184cb02f79875e4f3b21d1ca043ad06699424459128b58c0", classNode.Name.Content); } [Theory] @@ -129,7 +129,7 @@ public void MvcViewDocumentClassifierPass_UsesRelativePathToGenerateTypeName(str var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal(expected, classNode.Name); + Assert.Equal(expected, classNode.Name.Content); } [Fact] @@ -147,7 +147,7 @@ public void MvcViewDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSe var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal("x___application_Views_Home_Index", classNode.Name); + Assert.Equal("x___application_Views_Home_Index", classNode.Name.Content); } [Fact] @@ -165,7 +165,7 @@ public void MvcViewDocumentClassifierPass_SanitizesClassName() var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal("path_with_invalid_chars", classNode.Name); + Assert.Equal("path_with_invalid_chars", classNode.Name.Content); } [Fact] diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/RazorPageDocumentClassifierPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/RazorPageDocumentClassifierPassTest.cs index 9fb27d501e6..bb5328e93e0 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/RazorPageDocumentClassifierPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/RazorPageDocumentClassifierPassTest.cs @@ -199,7 +199,7 @@ public void RazorPageDocumentClassifierPass_SetsClass() Assert.Equal("global::Microsoft.AspNetCore.Mvc.RazorPages.Page", classNode.BaseType?.BaseType.Content); Assert.Equal(["public"], classNode.Modifiers); - Assert.Equal("Test", classNode.Name); + Assert.Equal("Test", classNode.Name.Content); } [Fact] @@ -219,7 +219,7 @@ public void RazorPageDocumentClassifierPass_NullFilePath_SetsClass() Assert.Equal("global::Microsoft.AspNetCore.Mvc.RazorPages.Page", classNode.BaseType?.BaseType.Content); Assert.Equal(["public"], classNode.Modifiers); - AssertEx.Equal("AspNetCore_c3b458108610c1a2aa6eede0a5685ede853e036732db515609b2a23ca15359e1", classNode.Name); + AssertEx.Equal("AspNetCore_c3b458108610c1a2aa6eede0a5685ede853e036732db515609b2a23ca15359e1", classNode.Name.Content); } [Theory] @@ -239,7 +239,7 @@ public void RazorPageDocumentClassifierPass_UsesRelativePathToGenerateTypeName(s var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal(expected, classNode.Name); + Assert.Equal(expected, classNode.Name.Content); } [Fact] @@ -257,7 +257,7 @@ public void RazorPageDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNot var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal("x___application_Views_Home_Index", classNode.Name); + Assert.Equal("x___application_Views_Home_Index", classNode.Name.Content); } [Fact] @@ -275,7 +275,7 @@ public void RazorPageDocumentClassifierPass_SanitizesClassName() var documentNode = processor.GetDocumentNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal("path_with_invalid_chars", classNode.Name); + Assert.Equal("path_with_invalid_chars", classNode.Name.Content); } [Fact] diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/CSharpCodeWriterTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/CSharpCodeWriterTest.cs index 2e31ca0ecc2..e6eb67c9084 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/CSharpCodeWriterTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/CSharpCodeWriterTest.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using Microsoft.AspNetCore.Razor.Language.Intermediate; using Roslyn.Test.Utilities; using Xunit; @@ -410,7 +411,7 @@ public void CSharpCodeWriter_RespectTabSetting() using var writer = new CodeWriter(options); // Act - writer.BuildClassDeclaration(modifiers: [], name: "C", baseType: null, interfaces: [], typeParameters: [], context: null); + writer.BuildClassDeclaration(modifiers: [], name: IntermediateNodeFactory.CSharpToken("C"), baseType: null, interfaces: [], typeParameters: [], context: null); writer.WriteField(suppressWarnings: [], modifiers: [], type: "int", name: "f"); // Assert @@ -434,7 +435,7 @@ public void CSharpCodeWriter_RespectSpaceSetting() using var writer = new CodeWriter(options); // Act - writer.BuildClassDeclaration(modifiers: [], name: "C", baseType: null, interfaces: [], typeParameters: [], context: null); + writer.BuildClassDeclaration(modifiers: [], name: IntermediateNodeFactory.CSharpToken("C"), baseType: null, interfaces: [], typeParameters: [], context: null); writer.WriteField(suppressWarnings: [], modifiers: [], type: "int", name: "f"); // Assert diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentDocumentClassifierPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentDocumentClassifierPassTest.cs index eb7fc612f6b..fd3aec13519 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentDocumentClassifierPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentDocumentClassifierPassTest.cs @@ -77,7 +77,7 @@ public void ComponentDocumentClassifierPass_SetsClass() Assert.Equal($"global::{ComponentsApi.ComponentBase.FullTypeName}", classNode.BaseType?.BaseType.Content); Assert.Equal(["public", "partial"], classNode.Modifiers); - Assert.Equal("Test", classNode.Name); + Assert.Equal("Test", classNode.Name.Content); } [Fact] @@ -102,7 +102,7 @@ public void ComponentDocumentClassifierPass_UsesRelativePathToGenerateTypeNameAn var namespaceNode = documentNode.GetNamespaceNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal("Banner", classNode.Name); + Assert.Equal("Banner", classNode.Name.Content); Assert.Equal("MyApp.Pages.Announcements", namespaceNode.Name); } @@ -127,7 +127,7 @@ public void ComponentDocumentClassifierPass_SanitizesClassName() var namespaceNode = documentNode.GetNamespaceNode(); var classNode = documentNode.GetClassNode(); - Assert.Equal("path_with_invalid_chars", classNode.Name); + Assert.Equal("path_with_invalid_chars", classNode.Name.Content); Assert.Equal("My._App", namespaceNode.Name); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorCSharpLoweringPhaseTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorCSharpLoweringPhaseTest.cs index 02cfcca205f..3d488f049c9 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorCSharpLoweringPhaseTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorCSharpLoweringPhaseTest.cs @@ -276,7 +276,7 @@ public void Execute_WritesClass() new("TKey"), new("TValue") ], - Name = "TestClass" + Name = IntermediateNodeFactory.CSharpToken("TestClass") }); // Act @@ -322,7 +322,7 @@ public void Execute_WithNullableContext_WritesClass() new("TKey"), new("TValue") ], - Name = "TestClass", + Name = IntermediateNodeFactory.CSharpToken("TestClass"), NullableContext = true }); @@ -371,7 +371,7 @@ public void Execute_WritesClass_ConstrainedGenericTypeParameters() new("TKey", "where TKey : class"), new("TValue", "where TValue : class") ], - Name = "TestClass" + Name = IntermediateNodeFactory.CSharpToken("TestClass") }); // Act diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DocumentClassifierPassBaseTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DocumentClassifierPassBaseTest.cs index 3bd8fc4d3c4..6b52dc48468 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DocumentClassifierPassBaseTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DocumentClassifierPassBaseTest.cs @@ -200,7 +200,7 @@ public void Execute_CanInitializeDefaults() Assert.Equal("TestNamespace", @namespace.Name); var @class = SingleChild(@namespace); - Assert.Equal("TestClass", @class.Name); + Assert.Equal("TestClass", @class.Name.Content); var method = SingleChild(@class); Assert.Equal("TestMethod", method.Name); @@ -262,6 +262,11 @@ protected override bool IsMatch(RazorCodeDocument codeDocument, DocumentIntermed return ShouldMatch; } + protected override string GetClassName(RazorCodeDocument codeDocument) + { + return Class ?? ""; + } + protected override void OnDocumentStructureCreated( RazorCodeDocument codeDocument, NamespaceDeclarationIntermediateNode @namespace, @@ -269,7 +274,6 @@ protected override void OnDocumentStructureCreated( MethodDeclarationIntermediateNode method) { @namespace.Name = Namespace; - @class.Name = Class; @method.Name = Method; } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributePassTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributePassTest.cs index 6d5381f429e..d3526405f82 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributePassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributePassTest.cs @@ -111,7 +111,7 @@ public void Execute_NoNamespaceSet_Noops() var @class = new ClassDeclarationIntermediateNode { IsPrimaryClass = true, - Name = "Test" + Name = IntermediateNodeFactory.CSharpToken("Test") }; builder.Add(@class); @@ -133,43 +133,7 @@ public void Execute_NoNamespaceSet_Noops() Assert.Equal("/test.cshtml", checksum.Identifier); var foundClass = Assert.IsType(@namespace.Children[1]); - Assert.Equal("Test", foundClass.Name); - } - - [Fact] - public void Execute_NoClassNameSet_Noops() - { - // Arrange - var source = TestRazorSourceDocument.Create(); - var codeDocument = ProjectEngine.CreateCodeDocument(source); - - var documentNode = new DocumentIntermediateNode() - { - DocumentKind = "test", - Options = codeDocument.CodeGenerationOptions - }; - - var builder = IntermediateNodeBuilder.Create(documentNode); - var @namespace = new NamespaceDeclarationIntermediateNode - { - IsPrimaryNamespace = true, - Name = "Some.Namespace" - }; - - builder.Push(@namespace); - - var @class = new ClassDeclarationIntermediateNode - { - IsPrimaryClass = true, - }; - - builder.Add(@class); - - // Act - ProjectEngine.ExecutePass(codeDocument, documentNode); - - // Assert - SingleChild(documentNode); + Assert.Equal("Test", foundClass.Name.Content); } [Fact] @@ -193,7 +157,7 @@ public void Execute_NoDocumentKind_Noops() var @class = new ClassDeclarationIntermediateNode { IsPrimaryClass = true, - Name = "Test" + Name = IntermediateNodeFactory.CSharpToken("Test") }; builder.Add(@class); @@ -230,7 +194,7 @@ public void Execute_NoIdentifier_Noops() var @class = new ClassDeclarationIntermediateNode { IsPrimaryClass = true, - Name = "Test" + Name = IntermediateNodeFactory.CSharpToken("Test") }; builder.Add(@class); @@ -267,7 +231,7 @@ public void Execute_HasRequiredInfo_AddsItemAndSourceChecksum() var @class = new ClassDeclarationIntermediateNode { IsPrimaryClass = true, - Name = "Test", + Name = IntermediateNodeFactory.CSharpToken("Test"), }; builder.Add(@class); @@ -315,7 +279,7 @@ public void Execute_HasRequiredInfo_AndImport_AddsItemAndSourceChecksum() var @class = new ClassDeclarationIntermediateNode { IsPrimaryClass = true, - Name = "Test", + Name = IntermediateNodeFactory.CSharpToken("Test"), }; builder.Add(@class); @@ -375,7 +339,7 @@ public void Execute_SuppressMetadataSourceChecksumAttributes_DoesNotGenerateSour var @class = new ClassDeclarationIntermediateNode { IsPrimaryClass = true, - Name = "Test" + Name = IntermediateNodeFactory.CSharpToken("Test") }; builder.Add(@class); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index cb969d332a5..a8a9ff1dbea 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -13018,5 +13018,138 @@ @inject float Value5 CompileToAssembly(generated); } + #endregion + + #region ClassName + + [IntegrationTestFact] + public void ClassName_Directive_Basic() + { + var generated = CompileToCSharp(""" + @classname MyCustomComponent + + + """); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void ClassName_Directive_Empty() + { + var generated = CompileToCSharp(""" + @classname +

Hello World

+ """); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + + [IntegrationTestFact] + public void ClassName_Directive_InvalidClassName() + { + var generated = CompileToCSharp(""" + @classname 123class +

Hello World

+ """); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void ClassName_Directive_InvalidClassName2() + { + var generated = CompileToCSharp(""" + @classname class +

Hello World

+ """); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void ClassName_Directive_With_Periods() + { + var generated = CompileToCSharp(""" + @classname My.Custom.Component +

Hello World

+ """); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void ClassName_Directive_WithTypeParam() + { + var generated = CompileToCSharp(""" + @classname MyGenericComponent + @typeparam TItem + + + + @code { + [Parameter] + public TItem Item { get; set; } + } + """); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void ClassName_Directive_WithNamespace() + { + var generated = CompileToCSharp(""" + @classname MyCustomComponent + @namespace Custom.Namespace + + + + """); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [IntegrationTestFact] + public void ClassName_Directive_WithOtherDirectives() + { + var generated = CompileToCSharp(""" + @page "/my-page" + @classname MyPageComponent + @using System.Collections.Generic + + + """); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + + #endregion } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDirectiveIntegrationTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDirectiveIntegrationTest.cs index 9ec30ba0ba9..caaeb02873c 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDirectiveIntegrationTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDirectiveIntegrationTest.cs @@ -97,7 +97,85 @@ public void SupportsInjectDirective() .Where(p => p.GetAttributes().Any(a => a.AttributeClass.Name == "InjectAttribute")); Assert.Collection(injectableProperties.OrderBy(p => p.Name), s => AssertEx.Equal("private TestNamespace.IMyService1 Test.TestComponent.MyService1 { get; set; }", s.ToTestDisplayString()), - s => AssertEx.Equal("private TestNamespace.IMyService2 Test.TestComponent.MyService2 { get; set; }", s.ToTestDisplayString())); + s => AssertEx.Equal("private TestNamespace.IMyService2 Test.TestComponent.MyService2 { get; set; }", s.ToTestDisplayString())); +} + + [Fact] + public void SupportsClassNameDirective() + { + // Arrange/Act + var assemblyResult = CompileToAssembly("TestComponent.razor", + "@classname MyCustomComponent\n" + + "Hello"); + + // Assert + var component = assemblyResult.Compilation.GetTypeByMetadataName("Test.MyCustomComponent"); + Assert.NotNull(component); + AssertEx.Equal("Test.MyCustomComponent", component.ToTestDisplayString()); + } + + [Fact] + public void MultipleClassNameDirectives_ProducesError() + { + // Arrange/Act + var cSharpResult = CompileToCSharp( + cshtmlRelativePath: "TestComponent.razor", + cshtmlContent: "@classname FirstName\n" + + "@classname SecondName\n" + + "Hello"); + + // Assert - should have an error for duplicate directive + var diagnostic = cSharpResult.RazorDiagnostics.Single(); + Assert.Equal("RZ2001", diagnostic.Id); + Assert.Contains("classname", diagnostic.GetMessage()); + } + + [Fact] + public void ClassNameDirective_NotAvailableInNonPreviewLanguageVersion() + { + // Arrange - Use an earlier language version + var configuration = RazorConfiguration.Default with { LanguageVersion = RazorLanguageVersion.Version_10_0 }; + + // Act + var cSharpResult = CompileToCSharp( + cshtmlRelativePath: "TestComponent.razor", + cshtmlContent: "@classname MyCustomComponent\nHello", + configuration: configuration); + + // Assert - the directive is not recognized, so it's treated as a C# expression + // which results in generated code that references an undefined 'classname' identifier. + // The component class is still generated with the original file name. + Assert.Contains("classname", cSharpResult.Code); + } + + [Fact] + public void ClassNameDirective_WithTypeParam() + { + // Arrange/Act + var assemblyResult = CompileToAssembly("TestComponent.razor", + """ + @classname MyGenericComponent + @typeparam TItem + +
@typeof(TItem).Name
+ + @code { + [Parameter] public TItem Item { get; set; } + } + """); + + // Assert - component should have custom name and be generic + var component = assemblyResult.Compilation.GetTypeByMetadataName("Test.MyGenericComponent`1"); + Assert.NotNull(component); + AssertEx.Equal("Test.MyGenericComponent", component.ToTestDisplayString()); + + // Verify type parameter + var typeParam = Assert.Single(component.TypeParameters); + AssertEx.Equal("TItem", typeParam.Name); + + // Verify the Item property exists with the correct type + var itemProperty = component.GetMembers().OfType().Single(p => p.Name == "Item"); + AssertEx.Equal("TItem", itemProperty.Type.ToTestDisplayString()); } [Fact] diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Intermediate/DocumentIntermediateNodeExtensionsTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Intermediate/DocumentIntermediateNodeExtensionsTest.cs index b9f05bb6701..d644e452958 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Intermediate/DocumentIntermediateNodeExtensionsTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Intermediate/DocumentIntermediateNodeExtensionsTest.cs @@ -16,7 +16,8 @@ public void FindPrimaryClass_FindsClassWithAnnotation() var document = new DocumentIntermediateNode(); var @class = new ClassDeclarationIntermediateNode { - IsPrimaryClass = true + IsPrimaryClass = true, + Name = IntermediateNodeFactory.CSharpToken("") }; var builder = IntermediateNodeBuilder.Create(document); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.codegen.cs new file mode 100644 index 00000000000..5c178012290 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.codegen.cs @@ -0,0 +1,59 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +MyCustomComponent + +#line default +#line hidden +#nullable disable + : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((global::System.Action)(() => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object MyCustomComponent = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyCustomComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.ir.txt new file mode 100644 index 00000000000..aecaf6dbc2a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.ir.txt @@ -0,0 +1,20 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - MyCustomComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (11:0,11 [17] x:\dir\subdir\Test\TestComponent.cshtml) - MyCustomComponent + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + HtmlContent - (30:1,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (30:1,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (32:2,0 [21] x:\dir\subdir\Test\TestComponent.cshtml) - MyCustomComponent diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.mappings.txt new file mode 100644 index 00000000000..2ae67aaf2ee --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (11:0,11 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|MyCustomComponent| +Generated Location: (448:16,0 [17] ) +|MyCustomComponent| + +Source Location: (11:0,11 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|MyCustomComponent| +Generated Location: (837:29,22 [17] ) +|MyCustomComponent| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.codegen.cs new file mode 100644 index 00000000000..47931c37eec --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((global::System.Action)(() => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..383a8c067a3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,12): Error RZ1015: The 'classname' directive expects an identifier. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.ir.txt new file mode 100644 index 00000000000..435f5023278 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.ir.txt @@ -0,0 +1,24 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (11:0,11 [0] x:\dir\subdir\Test\TestComponent.cshtml) - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MalformedDirective - (0:0,0 [11] x:\dir\subdir\Test\TestComponent.cshtml) - classname + DirectiveToken - (11:0,11 [0] x:\dir\subdir\Test\TestComponent.cshtml) - + HtmlContent - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (13:1,0 [20] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (17:1,4 [11] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (17:1,4 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello World diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.mappings.txt new file mode 100644 index 00000000000..ee23eb6085c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (11:0,11 [0] x:\dir\subdir\Test\TestComponent.cshtml) +|| +Generated Location: (683:21,0 [0] ) +|| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.codegen.cs new file mode 100644 index 00000000000..02c715203ff --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #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 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..383a8c067a3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,12): Error RZ1015: The 'classname' directive expects an identifier. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.ir.txt new file mode 100644 index 00000000000..4ed92fb4278 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MalformedDirective - (0:0,0 [11] x:\dir\subdir\Test\TestComponent.cshtml) - classname + HtmlContent - (11:0,11 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (11:0,11 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 123class\n + MarkupElement - (21:1,0 [20] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (25:1,4 [11] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (25:1,4 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello World diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.codegen.cs new file mode 100644 index 00000000000..02c715203ff --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #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 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..383a8c067a3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,12): Error RZ1015: The 'classname' directive expects an identifier. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.ir.txt new file mode 100644 index 00000000000..6be70e14914 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MalformedDirective - (0:0,0 [11] x:\dir\subdir\Test\TestComponent.cshtml) - classname + HtmlContent - (11:0,11 [7] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (11:0,11 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - class\n + MarkupElement - (18:1,0 [20] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (22:1,4 [11] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (22:1,4 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello World diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.codegen.cs new file mode 100644 index 00000000000..a0c9496cefe --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.codegen.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable 1591 +namespace Custom.Namespace +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +MyCustomComponent + +#line default +#line hidden +#nullable disable + : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((global::System.Action)(() => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object MyCustomComponent = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((global::System.Action)(() => { +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object __typeHelper = nameof(Custom.Namespace); + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Custom.Namespace.MyCustomComponent); + +#line default +#line hidden +#nullable disable + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 5 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Custom.Namespace.MyCustomComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.ir.txt new file mode 100644 index 00000000000..51a82394261 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.ir.txt @@ -0,0 +1,24 @@ +Document - + NamespaceDeclaration - (41:1,11 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Custom.Namespace + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - MyCustomComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (11:0,11 [17] x:\dir\subdir\Test\TestComponent.cshtml) - MyCustomComponent + DirectiveToken - (41:1,11 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Custom.Namespace + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + HtmlContent - (59:2,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (59:2,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (61:3,0 [21] x:\dir\subdir\Test\TestComponent.cshtml) - MyCustomComponent + HtmlContent - (82:3,21 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (82:3,21 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (84:4,0 [38] x:\dir\subdir\Test\TestComponent.cshtml) - Custom.Namespace.MyCustomComponent diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.mappings.txt new file mode 100644 index 00000000000..52fc988101d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (11:0,11 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|MyCustomComponent| +Generated Location: (460:16,0 [17] ) +|MyCustomComponent| + +Source Location: (11:0,11 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|MyCustomComponent| +Generated Location: (849:29,22 [17] ) +|MyCustomComponent| + +Source Location: (41:1,11 [16] x:\dir\subdir\Test\TestComponent.cshtml) +|Custom.Namespace| +Generated Location: (1109:39,44 [16] ) +|Custom.Namespace| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.codegen.cs new file mode 100644 index 00000000000..ea75c2cd594 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.codegen.cs @@ -0,0 +1,75 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" +using System.Collections.Generic; + +#line default +#line hidden +#nullable disable + [global::Microsoft.AspNetCore.Components.RouteAttribute("/my-page")] + #nullable restore + public partial class +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +MyPageComponent + +#line default +#line hidden +#nullable disable + : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((global::System.Action)(() => { +// language=Route,Component +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object __typeHelper = "/my-page"; + +#line default +#line hidden +#nullable disable + } + ))(); + ((global::System.Action)(() => { +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object MyPageComponent = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 5 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyPageComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.ir.txt new file mode 100644 index 00000000000..fd593519b1f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + UsingDirective - (47:2,1 [32] x:\dir\subdir\Test\TestComponent.cshtml) - System.Collections.Generic + RouteAttributeExtensionNode - (6:0,6 [10] x:\dir\subdir\Test\TestComponent.cshtml) - "/my-page" + ClassDeclaration - - public partial - MyPageComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (6:0,6 [10] x:\dir\subdir\Test\TestComponent.cshtml) - "/my-page" + DirectiveToken - (29:1,11 [15] x:\dir\subdir\Test\TestComponent.cshtml) - MyPageComponent + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + HtmlContent - (79:2,33 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (79:2,33 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + Component - (83:4,0 [19] x:\dir\subdir\Test\TestComponent.cshtml) - MyPageComponent diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.mappings.txt new file mode 100644 index 00000000000..4e51abb1df2 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (47:2,1 [32] x:\dir\subdir\Test\TestComponent.cshtml) +|using System.Collections.Generic| +Generated Location: (314:11,0 [32] ) +|using System.Collections.Generic| + +Source Location: (29:1,11 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|MyPageComponent| +Generated Location: (593:21,0 [15] ) +|MyPageComponent| + +Source Location: (6:0,6 [10] x:\dir\subdir\Test\TestComponent.cshtml) +|"/my-page"| +Generated Location: (1024:35,37 [10] ) +|"/my-page"| + +Source Location: (29:1,11 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|MyPageComponent| +Generated Location: (1247:45,22 [15] ) +|MyPageComponent| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithTypeParam/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithTypeParam/TestComponent.codegen.cs new file mode 100644 index 00000000000..66560be3cf5 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithTypeParam/TestComponent.codegen.cs @@ -0,0 +1,88 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +MyGenericComponent + +#line default +#line hidden +#nullable disable + < +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +TItem + +#line default +#line hidden +#nullable disable + > : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((global::System.Action)(() => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object MyGenericComponent = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((global::System.Action)(() => { + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = typeof( +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + string + +#line default +#line hidden +#nullable disable + ); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyGenericComponent<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 6 "x:\dir\subdir\Test\TestComponent.cshtml" + + [Parameter] + public TItem Item { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithTypeParam/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithTypeParam/TestComponent.ir.txt new file mode 100644 index 00000000000..58aeb55d566 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithTypeParam/TestComponent.ir.txt @@ -0,0 +1,27 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - MyGenericComponent - global::Microsoft.AspNetCore.Components.ComponentBase - - TItem + DesignTimeDirective - + DirectiveToken - (11:0,11 [18] x:\dir\subdir\Test\TestComponent.cshtml) - MyGenericComponent + DirectiveToken - (42:1,11 [5] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + HtmlContent - (49:2,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (49:2,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (51:3,0 [37] x:\dir\subdir\Test\TestComponent.cshtml) - MyGenericComponent + ComponentTypeArgument - (78:3,27 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + LazyIntermediateToken - (78:3,27 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + HtmlContent - (88:3,37 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (88:3,37 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + CSharpCode - (99:5,7 [56] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (99:5,7 [56] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter]\n public TItem Item { get; set; }\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithTypeParam/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithTypeParam/TestComponent.mappings.txt new file mode 100644 index 00000000000..6940352abbb --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_WithTypeParam/TestComponent.mappings.txt @@ -0,0 +1,31 @@ +Source Location: (11:0,11 [18] x:\dir\subdir\Test\TestComponent.cshtml) +|MyGenericComponent| +Generated Location: (448:16,0 [18] ) +|MyGenericComponent| + +Source Location: (42:1,11 [5] x:\dir\subdir\Test\TestComponent.cshtml) +|TItem| +Generated Location: (595:24,0 [5] ) +|TItem| + +Source Location: (11:0,11 [18] x:\dir\subdir\Test\TestComponent.cshtml) +|MyGenericComponent| +Generated Location: (973:37,22 [18] ) +|MyGenericComponent| + +Source Location: (78:3,27 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|string| +Generated Location: (1614:58,27 [6] ) +|string| + +Source Location: (99:5,7 [56] x:\dir\subdir\Test\TestComponent.cshtml) +| + [Parameter] + public TItem Item { get; set; } +| +Generated Location: (2147:78,7 [56] ) +| + [Parameter] + public TItem Item { get; set; } +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_With_Periods/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_With_Periods/TestComponent.codegen.cs new file mode 100644 index 00000000000..e8e8d1ffe96 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_With_Periods/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((global::System.Action)(() => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object My = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_With_Periods/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_With_Periods/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..65f527607dc --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_With_Periods/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,14): Error RZ1017: Unexpected literal following the 'classname' directive. Expected 'line break'. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_With_Periods/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_With_Periods/TestComponent.ir.txt new file mode 100644 index 00000000000..6862ef426b1 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_With_Periods/TestComponent.ir.txt @@ -0,0 +1,24 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) - My + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MalformedDirective - (0:0,0 [13] x:\dir\subdir\Test\TestComponent.cshtml) - classname + DirectiveToken - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) - My + HtmlContent - (13:0,13 [19] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (13:0,13 [19] x:\dir\subdir\Test\TestComponent.cshtml) - Html - .Custom.Component\n + MarkupElement - (32:1,0 [20] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (36:1,4 [11] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (36:1,4 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello World diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_With_Periods/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_With_Periods/TestComponent.mappings.txt new file mode 100644 index 00000000000..0f3daf42ea5 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ClassName_Directive_With_Periods/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|My| +Generated Location: (705:21,22 [2] ) +|My| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.codegen.cs new file mode 100644 index 00000000000..c975b2365f0 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.codegen.cs @@ -0,0 +1,34 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class +#nullable restore +#line (1,12)-(1,29) "x:\dir\subdir\Test\TestComponent.cshtml" +MyCustomComponent + +#line default +#line hidden +#nullable disable + : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.ir.txt new file mode 100644 index 00000000000..94979daadbd --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.ir.txt @@ -0,0 +1,10 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - MyCustomComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (32:2,0 [21] x:\dir\subdir\Test\TestComponent.cshtml) - MyCustomComponent diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.mappings.txt new file mode 100644 index 00000000000..ecf4c76524a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Basic/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (11:0,11 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|MyCustomComponent| +Generated Location: (460:16,0 [17] ) +|MyCustomComponent| + +Source Location: (33:2,1 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|MyCustomComponent| +Generated Location: (847:27,49 [17] ) +|MyCustomComponent| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.codegen.cs new file mode 100644 index 00000000000..e82c3e54db7 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.codegen.cs @@ -0,0 +1,25 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.AddMarkupContent(0, "

Hello World

"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..383a8c067a3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,12): Error RZ1015: The 'classname' directive expects an identifier. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.ir.txt new file mode 100644 index 00000000000..e86f4106ee4 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_Empty/TestComponent.ir.txt @@ -0,0 +1,12 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MalformedDirective - (0:0,0 [11] x:\dir\subdir\Test\TestComponent.cshtml) - classname + DirectiveToken - (11:0,11 [0] x:\dir\subdir\Test\TestComponent.cshtml) - + MarkupBlock - -

Hello World

diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.codegen.cs new file mode 100644 index 00000000000..e761e044562 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.codegen.cs @@ -0,0 +1,26 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.AddMarkupContent(0, "123class\r\n"); + __builder.AddMarkupContent(1, "

Hello World

"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..383a8c067a3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,12): Error RZ1015: The 'classname' directive expects an identifier. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.ir.txt new file mode 100644 index 00000000000..a5950e3e012 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MalformedDirective - (0:0,0 [11] x:\dir\subdir\Test\TestComponent.cshtml) - classname + HtmlContent - (11:0,11 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (11:0,11 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 123class\n + MarkupBlock - -

Hello World

diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.codegen.cs new file mode 100644 index 00000000000..c6eb69b5e86 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.codegen.cs @@ -0,0 +1,26 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.AddMarkupContent(0, "class\r\n"); + __builder.AddMarkupContent(1, "

Hello World

"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.diagnostics.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..383a8c067a3 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,12): Error RZ1015: The 'classname' directive expects an identifier. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.ir.txt new file mode 100644 index 00000000000..6f7577fd635 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_InvalidClassName2/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MalformedDirective - (0:0,0 [11] x:\dir\subdir\Test\TestComponent.cshtml) - classname + HtmlContent - (11:0,11 [7] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (11:0,11 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - class\n + MarkupBlock - -

Hello World

diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.codegen.cs new file mode 100644 index 00000000000..859a128fa39 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.codegen.cs @@ -0,0 +1,44 @@ +// +#pragma warning disable 1591 +namespace +#nullable restore +#line (2,12)-(2,28) "x:\dir\subdir\Test\TestComponent.cshtml" +Custom.Namespace + +#line default +#line hidden +#nullable disable +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class +#nullable restore +#line (1,12)-(1,29) "x:\dir\subdir\Test\TestComponent.cshtml" +MyCustomComponent + +#line default +#line hidden +#nullable disable + : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.CloseComponent(); + __builder.AddMarkupContent(1, "\r\n"); + __builder.OpenComponent(2); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.ir.txt new file mode 100644 index 00000000000..2f957fb568b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - (41:1,11 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Custom.Namespace + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - MyCustomComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (61:3,0 [21] x:\dir\subdir\Test\TestComponent.cshtml) - MyCustomComponent + HtmlContent - (82:3,21 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (82:3,21 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (84:4,0 [38] x:\dir\subdir\Test\TestComponent.cshtml) - Custom.Namespace.MyCustomComponent diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.mappings.txt new file mode 100644 index 00000000000..255b8cb3e3c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithNamespace/TestComponent.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (41:1,11 [16] x:\dir\subdir\Test\TestComponent.cshtml) +|Custom.Namespace| +Generated Location: (146:5,0 [16] ) +|Custom.Namespace| + +Source Location: (11:0,11 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|MyCustomComponent| +Generated Location: (606:23,0 [17] ) +|MyCustomComponent| + +Source Location: (62:3,1 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|MyCustomComponent| +Generated Location: (1005:34,61 [17] ) +|MyCustomComponent| + +Source Location: (85:4,1 [34] x:\dir\subdir\Test\TestComponent.cshtml) +|Custom.Namespace.MyCustomComponent| +Generated Location: (1166:37,44 [34] ) +|Custom.Namespace.MyCustomComponent| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.codegen.cs new file mode 100644 index 00000000000..d85c1b3c62c --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.codegen.cs @@ -0,0 +1,49 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; +#nullable restore +#line (3,2)-(3,34) "x:\dir\subdir\Test\TestComponent.cshtml" +using System.Collections.Generic + +#nullable disable + ; + #line default + #line hidden + [global::Microsoft.AspNetCore.Components.RouteAttribute( + // language=Route,Component +#nullable restore +#line (1,7)-(1,17) "x:\dir\subdir\Test\TestComponent.cshtml" +"/my-page" + +#line default +#line hidden +#nullable disable + )] + #nullable restore + public partial class +#nullable restore +#line (2,12)-(2,27) "x:\dir\subdir\Test\TestComponent.cshtml" +MyPageComponent + +#line default +#line hidden +#nullable disable + : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.ir.txt new file mode 100644 index 00000000000..46ef8fbf11d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + UsingDirective - (47:2,1 [32] x:\dir\subdir\Test\TestComponent.cshtml) - System.Collections.Generic + RouteAttributeExtensionNode - (6:0,6 [10] x:\dir\subdir\Test\TestComponent.cshtml) - "/my-page" + ClassDeclaration - - public partial - MyPageComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (83:4,0 [19] x:\dir\subdir\Test\TestComponent.cshtml) - MyPageComponent diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.mappings.txt new file mode 100644 index 00000000000..adb2b33dc2b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithOtherDirectives/TestComponent.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (47:2,1 [32] x:\dir\subdir\Test\TestComponent.cshtml) +|using System.Collections.Generic| +Generated Location: (325:11,0 [32] ) +|using System.Collections.Generic| + +Source Location: (6:0,6 [10] x:\dir\subdir\Test\TestComponent.cshtml) +|"/my-page"| +Generated Location: (600:21,0 [10] ) +|"/my-page"| + +Source Location: (29:1,11 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|MyPageComponent| +Generated Location: (802:31,0 [15] ) +|MyPageComponent| + +Source Location: (84:4,1 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|MyPageComponent| +Generated Location: (1187:42,49 [15] ) +|MyPageComponent| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithTypeParam/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithTypeParam/TestComponent.codegen.cs new file mode 100644 index 00000000000..ed3417803c5 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ClassName_Directive_WithTypeParam/TestComponent.codegen.cs @@ -0,0 +1,60 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class +#nullable restore +#line (1,12)-(1,30) "x:\dir\subdir\Test\TestComponent.cshtml" +MyGenericComponent + +#line default +#line hidden +#nullable disable + < +#nullable restore +#line (2,12)-(2,17) "x:\dir\subdir\Test\TestComponent.cshtml" +TItem + +#line default +#line hidden +#nullable disable + > : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent