diff --git a/eng/Build.props b/eng/Build.props index 17c9848f83..64ae3afd52 100644 --- a/eng/Build.props +++ b/eng/Build.props @@ -34,8 +34,8 @@ $(RepoRoot)src\Installers\**\*.*proj; $(RepoRoot)src\SignalR\clients\ts\**\node_modules\**\*.*proj; $(RepoRoot)src\Components\Web.JS\node_modules\**\*.*proj; - $(RepoRoot)src\Components\Blazor\Build\testassets\**\*.*proj; - $(RepoRoot)src\ProjectTemplates\BlazorWasm.ProjectTemplates\content\**\*.csproj; + $(RepoRoot)src\Components\WebAssembly\Build\testassets\**\*.*proj; + $(RepoRoot)src\ProjectTemplates\ComponentsWebAssembly.ProjectTemplates\content\**\*.csproj; $(RepoRoot)src\ProjectTemplates\Web.ProjectTemplates\content\**\*.csproj; $(RepoRoot)src\ProjectTemplates\Web.ProjectTemplates\content\**\*.fsproj; $(RepoRoot)src\ProjectTemplates\Web.Spa.ProjectTemplates\content\**\*.csproj; diff --git a/eng/ProjectReferences.props b/eng/ProjectReferences.props index 1ca356ab60..105e7348f6 100644 --- a/eng/ProjectReferences.props +++ b/eng/ProjectReferences.props @@ -5,13 +5,12 @@ --> - - - - - - - - + + + + + + + diff --git a/src/Components/Blazor.sln b/src/Components/Blazor.sln index ca74e8d148..cd32283c75 100644 --- a/src/Components/Blazor.sln +++ b/src/Components/Blazor.sln @@ -11,65 +11,65 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wasm.Performance.Driver", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wasm.Performance.TestApp", "benchmarkapps\Wasm.Performance\TestApp\Wasm.Performance.TestApp.csproj", "{10E5AD2E-25A9-4B8B-BD33-207B12D5BAE4}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Blazor", "Blazor", "{B29FB58D-FAE5-405E-9695-BCF93582BE9A}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebAssembly", "WebAssembly", "{B29FB58D-FAE5-405E-9695-BCF93582BE9A}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Blazor", "Blazor", "{E363191C-6C15-4C40-8698-B0AD5AA09700}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebAssembly", "WebAssembly", "{E363191C-6C15-4C40-8698-B0AD5AA09700}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor", "Blazor\Blazor\src\Microsoft.AspNetCore.Blazor.csproj", "{8A585A38-917D-4A7E-8AFD-E860C76878FA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.WebAssembly", "WebAssembly\WebAssembly\src\Microsoft.AspNetCore.Components.WebAssembly.csproj", "{8A585A38-917D-4A7E-8AFD-E860C76878FA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.Tests", "Blazor\Blazor\test\Microsoft.AspNetCore.Blazor.Tests.csproj", "{75DA4341-5B7F-419C-8EED-3492013D8EB5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.WebAssembly.Tests", "WebAssembly\WebAssembly\test\Microsoft.AspNetCore.Components.WebAssembly.Tests.csproj", "{75DA4341-5B7F-419C-8EED-3492013D8EB5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{A82B9830-447D-4E26-BEB7-C724A3956C0D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.Build", "Blazor\Build\src\Microsoft.AspNetCore.Blazor.Build.csproj", "{201D53B3-2D33-40AD-813F-347A0C1998ED}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.WebAssembly.Build", "WebAssembly\Build\src\Microsoft.AspNetCore.Components.WebAssembly.Build.csproj", "{201D53B3-2D33-40AD-813F-347A0C1998ED}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.Build.Tests", "Blazor\Build\test\Microsoft.AspNetCore.Blazor.Build.Tests.csproj", "{AB13059F-8F21-48F6-B9F3-EAF260D9CB81}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.WebAssembly.Build.Tests", "WebAssembly\Build\test\Microsoft.AspNetCore.Components.WebAssembly.Build.Tests.csproj", "{AB13059F-8F21-48F6-B9F3-EAF260D9CB81}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testassets", "testassets", "{B4ACD900-27B6-482B-B434-2C1E86E9D8BC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "blazorhosted", "Blazor\Build\testassets\blazorhosted\blazorhosted.csproj", "{5F44DC59-3B4E-4E87-973F-C9FB4BBFD03D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "blazorhosted", "WebAssembly\Build\testassets\blazorhosted\blazorhosted.csproj", "{5F44DC59-3B4E-4E87-973F-C9FB4BBFD03D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "classlibrarywithsatelliteassemblies", "Blazor\Build\testassets\classlibrarywithsatelliteassemblies\classlibrarywithsatelliteassemblies.csproj", "{4BD2D530-83C7-4A86-AF8E-FE1FECBF64C6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "classlibrarywithsatelliteassemblies", "WebAssembly\Build\testassets\classlibrarywithsatelliteassemblies\classlibrarywithsatelliteassemblies.csproj", "{4BD2D530-83C7-4A86-AF8E-FE1FECBF64C6}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorClassLibrary", "Blazor\Build\testassets\razorclasslibrary\RazorClassLibrary.csproj", "{779749F3-8D4F-42BD-9219-37502AD68F0E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorClassLibrary", "WebAssembly\Build\testassets\razorclasslibrary\RazorClassLibrary.csproj", "{779749F3-8D4F-42BD-9219-37502AD68F0E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "standalone", "Blazor\Build\testassets\standalone\standalone.csproj", "{9C41BA92-FBC8-4E11-9A71-0B07906A2D6C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "standalone", "WebAssembly\Build\testassets\standalone\standalone.csproj", "{9C41BA92-FBC8-4E11-9A71-0B07906A2D6C}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DevServer", "DevServer", "{A44FB7D1-78AB-41C4-B1C7-94399396EA6C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.DevServer", "Blazor\DevServer\src\Microsoft.AspNetCore.Blazor.DevServer.csproj", "{0ED336B7-6FAB-4872-8D75-1CDD5A5DDBB2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.WebAssembly.DevServer", "WebAssembly\DevServer\src\Microsoft.AspNetCore.Components.WebAssembly.DevServer.csproj", "{0ED336B7-6FAB-4872-8D75-1CDD5A5DDBB2}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Http", "Http", "{F4995C96-8D4E-4B26-8FB8-614B020156C2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.HttpClient", "Blazor\Http\src\Microsoft.AspNetCore.Blazor.HttpClient.csproj", "{FAFE3FF2-D36D-47DA-833D-C382A902705E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.HttpClient", "WebAssembly\Http\src\Microsoft.AspNetCore.Blazor.HttpClient.csproj", "{FAFE3FF2-D36D-47DA-833D-C382A902705E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.HttpClient.Tests", "Blazor\Http\test\Microsoft.AspNetCore.Blazor.HttpClient.Tests.csproj", "{2C10DF3B-D138-414A-BB36-02E45A7B6025}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.HttpClient.Tests", "WebAssembly\Http\test\Microsoft.AspNetCore.Blazor.HttpClient.Tests.csproj", "{2C10DF3B-D138-414A-BB36-02E45A7B6025}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mono.WebAssembly.Interop", "Mono.WebAssembly.Interop", "{37FA056D-A7B3-4F72-A8B9-8D3C175E831E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.WebAssembly.Interop", "Blazor\Mono.WebAssembly.Interop\src\Mono.WebAssembly.Interop.csproj", "{FBD7C733-200E-4BED-8B31-2610C2263F72}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.WebAssembly.Interop", "WebAssembly\Mono.WebAssembly.Interop\src\Mono.WebAssembly.Interop.csproj", "{FBD7C733-200E-4BED-8B31-2610C2263F72}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server", "Server", "{7920B09F-8016-49CF-A229-E72D0CECDD17}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.Server", "Blazor\Server\src\Microsoft.AspNetCore.Blazor.Server.csproj", "{BDBEDE12-74C1-466E-B8AE-49EC40F83866}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.WebAssembly.Server", "WebAssembly\Server\src\Microsoft.AspNetCore.Components.WebAssembly.Server.csproj", "{BDBEDE12-74C1-466E-B8AE-49EC40F83866}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testassets", "testassets", "{CBD2BB24-3EC3-4950-ABE4-8C521D258DCD}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HostedInAspNet.Client", "Blazor\testassets\HostedInAspNet.Client\HostedInAspNet.Client.csproj", "{8276993E-3F54-4D2F-8DDA-E86F2C6BEF1E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HostedInAspNet.Client", "WebAssembly\testassets\HostedInAspNet.Client\HostedInAspNet.Client.csproj", "{8276993E-3F54-4D2F-8DDA-E86F2C6BEF1E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HostedInAspNet.Server", "Blazor\testassets\HostedInAspNet.Server\HostedInAspNet.Server.csproj", "{CFA20A59-F52B-47A2-BD5D-B600D9576BDA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HostedInAspNet.Server", "WebAssembly\testassets\HostedInAspNet.Server\HostedInAspNet.Server.csproj", "{CFA20A59-F52B-47A2-BD5D-B600D9576BDA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoSanity", "Blazor\testassets\MonoSanity\MonoSanity.csproj", "{C97721BB-8D89-4167-9E59-839C237BA270}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoSanity", "WebAssembly\testassets\MonoSanity\MonoSanity.csproj", "{C97721BB-8D89-4167-9E59-839C237BA270}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoSanityClient", "Blazor\testassets\MonoSanityClient\MonoSanityClient.csproj", "{7F357E7B-BF33-4055-9A21-37B3507BFF90}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoSanityClient", "WebAssembly\testassets\MonoSanityClient\MonoSanityClient.csproj", "{7F357E7B-BF33-4055-9A21-37B3507BFF90}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StandaloneApp", "Blazor\testassets\StandaloneApp\StandaloneApp.csproj", "{236FC110-FBE0-476D-ADC5-D98E23BAA1EE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StandaloneApp", "WebAssembly\testassets\StandaloneApp\StandaloneApp.csproj", "{236FC110-FBE0-476D-ADC5-D98E23BAA1EE}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Validation", "Validation", "{09758C93-6707-46E3-9211-470449280C2C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.DataAnnotations.Validation", "Blazor\Validation\src\Microsoft.AspNetCore.Blazor.DataAnnotations.Validation.csproj", "{52F0CF32-9506-4D9C-B715-52900B219BDF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.DataAnnotations.Validation", "WebAssembly\Validation\src\Microsoft.AspNetCore.Components.DataAnnotations.Validation.csproj", "{52F0CF32-9506-4D9C-B715-52900B219BDF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.DataAnnotations.Validation.Tests", "Blazor\Validation\test\Microsoft.AspNetCore.Blazor.DataAnnotations.Validation.Tests.csproj", "{C1CC2480-7925-4391-86F5-60653D864E87}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.DataAnnotations.Validation.Tests", "WebAssembly\Validation\test\Microsoft.AspNetCore.Components.DataAnnotations.Validation.Tests.csproj", "{C1CC2480-7925-4391-86F5-60653D864E87}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{194596E0-E6F5-4728-8A7A-A82EA0893111}" EndProject diff --git a/src/Components/Blazor/Build/src/Properties/AssemblyInfo.cs b/src/Components/Blazor/Build/src/Properties/AssemblyInfo.cs deleted file mode 100644 index aac42c25cc..0000000000 --- a/src/Components/Blazor/Build/src/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Blazor.Build.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Components/Blazor/Build/test/BindRazorIntegrationTest.cs b/src/Components/Blazor/Build/test/BindRazorIntegrationTest.cs deleted file mode 100644 index 1fafb9e81d..0000000000 --- a/src/Components/Blazor/Build/test/BindRazorIntegrationTest.cs +++ /dev/null @@ -1,534 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Test.Helpers; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Blazor.Build.Test -{ - public class BindRazorIntegrationTest : RazorIntegrationTestBase - { - public BindRazorIntegrationTest(ITestOutputHelper output) - : base(output) - { - } - - internal override bool UseTwoPhaseCompilation => true; - - [Fact] - public void Render_BindToComponent_SpecifiesValue_WithMatchingProperties() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using System; -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class MyComponent : ComponentBase - { - [Parameter] - public int Value { get; set; } - - [Parameter] - public Action ValueChanged { get; set; } - } -}")); - - var component = CompileToComponent(@" - -@code { - public int ParentValue { get; set; } = 42; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 3, 0), - frame => AssertFrame.Attribute(frame, "Value", 42, 1), - frame => AssertFrame.Attribute(frame, "ValueChanged", typeof(Action), 2)); - } - - [Fact] - public void Render_BindToComponent_SpecifiesValue_WithoutMatchingProperties() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class MyComponent : ComponentBase, IComponent - { - Task IComponent.SetParametersAsync(ParameterView parameters) - { - return Task.CompletedTask; - } - } -}")); - - var component = CompileToComponent(@" - -@code { - public int ParentValue { get; set; } = 42; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 3, 0), - frame => AssertFrame.Attribute(frame, "Value", 42, 1), - frame => AssertFrame.Attribute(frame, "ValueChanged", typeof(EventCallback), 2)); - } - - [Fact] - public void Render_BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using System; -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class MyComponent : ComponentBase - { - [Parameter] - public int Value { get; set; } - - [Parameter] - public Action OnChanged { get; set; } - } -}")); - - var component = CompileToComponent(@" - -@code { - public int ParentValue { get; set; } = 42; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 3, 0), - frame => AssertFrame.Attribute(frame, "Value", 42, 1), - frame => AssertFrame.Attribute(frame, "OnChanged", typeof(Action), 2)); - } - - [Fact] - public void Render_BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class MyComponent : ComponentBase, IComponent - { - Task IComponent.SetParametersAsync(ParameterView parameters) - { - return Task.CompletedTask; - } - } -}")); - - var component = CompileToComponent(@" - -@code { - public int ParentValue { get; set; } = 42; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 3, 0), - frame => AssertFrame.Attribute(frame, "Value", 42, 1), - frame => AssertFrame.Attribute(frame, "OnChanged", typeof(EventCallback), 2)); - } - - [Fact] - public void Render_BindToElement_WritesAttributes() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using System; -using Microsoft.AspNetCore.Components; - -namespace Test -{ - [BindElement(""div"", null, ""myvalue"", ""myevent"")] - public static class BindAttributes - { - } -}")); - - var component = CompileToComponent(@" -
-@code { - public string ParentValue { get; set; } = ""hi""; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "div", 3, 0), - frame => AssertFrame.Attribute(frame, "myvalue", "hi", 1), - frame => AssertFrame.Attribute(frame, "myevent", typeof(EventCallback), 2)); - } - - [Fact] - public void Render_BindToElementWithSuffix_WritesAttributes() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using System; -using Microsoft.AspNetCore.Components; - -namespace Test -{ - [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] - public static class BindAttributes - { - } -}")); - - var component = CompileToComponent(@" -
-@code { - public string ParentValue { get; set; } = ""hi""; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "div", 3, 0), - frame => AssertFrame.Attribute(frame, "myvalue", "hi", 1), - frame => AssertFrame.Attribute(frame, "myevent", typeof(EventCallback), 2)); - } - - [Fact] - public void Render_BindDuplicates_ReportsDiagnostic() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using System; -using Microsoft.AspNetCore.Components; - -namespace Test -{ - [BindElement(""div"", ""value"", ""myvalue2"", ""myevent2"")] - [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] - public static class BindAttributes - { - } -}")); - - // Act - var result = CompileToCSharp(@" -
-@code { - public string ParentValue { get; set; } = ""hi""; -}"); - - // Assert - var diagnostic = Assert.Single(result.Diagnostics); - Assert.Equal("RZ9989", diagnostic.Id); - Assert.Equal( - "The attribute '@bind-value' was matched by multiple bind attributes. Duplicates:" + Environment.NewLine + - "Test.BindAttributes" + Environment.NewLine + - "Test.BindAttributes", - diagnostic.GetMessage()); - } - - [Fact] - public void Render_BuiltIn_BindToInputWithoutType_WritesAttributes() - { - // Arrange - var component = CompileToComponent(@" -@using Microsoft.AspNetCore.Components.Web - -@code { - public int ParentValue { get; set; } = 42; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "input", 3, 0), - frame => AssertFrame.Attribute(frame, "value", "42", 1), - frame => AssertFrame.Attribute(frame, "onchange", typeof(EventCallback), 2)); - } - - [Fact] - public void Render_BuiltIn_BindToInputText_WithFormat_WritesAttributes() - { - // Arrange - var component = CompileToComponent(@" -@using Microsoft.AspNetCore.Components.Web - -@code { - public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "input", 4, 0), - frame => AssertFrame.Attribute(frame, "type", "text", 1), - frame => AssertFrame.Attribute(frame, "value", new DateTime(2018, 1, 1).ToString("MM/dd/yyyy"), 2), - frame => AssertFrame.Attribute(frame, "onchange", typeof(EventCallback), 3)); - } - - [Fact] - public void Render_BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes() - { - // Arrange - var component = CompileToComponent(@" -@using Microsoft.AspNetCore.Components.Web - -@code { - public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); - - public string Format { get; set; } = ""MM/dd/yyyy""; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "input", 4, 0), - frame => AssertFrame.Attribute(frame, "type", "text", 1), - frame => AssertFrame.Attribute(frame, "value", new DateTime(2018, 1, 1).ToString("MM/dd/yyyy"), 2), - frame => AssertFrame.Attribute(frame, "onchange", typeof(EventCallback), 3)); - } - - [Fact] - public void Render_BuiltIn_BindToInputText_WritesAttributes() - { - // Arrange - var component = CompileToComponent(@" -@using Microsoft.AspNetCore.Components.Web - -@code { - public int ParentValue { get; set; } = 42; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "input", 4, 0), - frame => AssertFrame.Attribute(frame, "type", "text", 1), - frame => AssertFrame.Attribute(frame, "value", "42", 2), - frame => AssertFrame.Attribute(frame, "onchange", typeof(EventCallback), 3)); - } - - [Fact] - public void Render_BuiltIn_BindToInputCheckbox_WritesAttributes() - { - // Arrange - var component = CompileToComponent(@" -@using Microsoft.AspNetCore.Components.Web - -@code { - public bool Enabled { get; set; } -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "input", 3, 0), - frame => AssertFrame.Attribute(frame, "type", "checkbox", 1), - frame => AssertFrame.Attribute(frame, "onchange", typeof(EventCallback), 3)); - } - - [Fact] - public void Render_BindToElementFallback_WritesAttributes() - { - // Arrange - var component = CompileToComponent(@" - -@code { - public int ParentValue { get; set; } = 42; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "input", 4, 0), - frame => AssertFrame.Attribute(frame, "type", "text", 1), - frame => AssertFrame.Attribute(frame, "value", "42", 2), - frame => AssertFrame.Attribute(frame, "onchange", typeof(EventCallback), 3)); - } - - [Fact] - public void Render_BindToElementFallback_WithFormat_WritesAttributes() - { - // Arrange - var component = CompileToComponent(@" - -@code { - public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "input", 4, 0), - frame => AssertFrame.Attribute(frame, "type", "text", 1), - frame => AssertFrame.Attribute(frame, "value", new DateTime(2018, 1, 1).ToString("MM/dd"), 2), - frame => AssertFrame.Attribute(frame, "onchange", typeof(EventCallback), 3)); - } - - [Fact] // Additional coverage of OrphanTagHelperLoweringPass - public void Render_BindToElementFallback_SpecifiesValueAndChangeEvent_WithCSharpAttribute() - { - // Arrange - var component = CompileToComponent(@" - -@code { - public int ParentValue { get; set; } = 42; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "input", 5, 0), - frame => AssertFrame.Attribute(frame, "type", "text", 1), - frame => AssertFrame.Attribute(frame, "visible", 2), - frame => AssertFrame.Attribute(frame, "value", "42", 3), - frame => AssertFrame.Attribute(frame, "onchange", typeof(EventCallback), 4)); - } - - [Fact] // See https://github.com/aspnet/Blazor/issues/703 - public void Workaround_703() - { - // Arrange - var component = CompileToComponent(@" - -@code { - public int ParentValue { get; set; } = 42; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - // - // The workaround for 703 is that the value attribute MUST be after the type - // attribute. - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "input", 5, 0), - frame => AssertFrame.Attribute(frame, "type", "text", 1), - frame => AssertFrame.Attribute(frame, "visible", 2), - frame => AssertFrame.Attribute(frame, "value", "42", 3), - frame => AssertFrame.Attribute(frame, "onchange", typeof(EventCallback), 4)); - } - - [Fact] // Additional coverage of OrphanTagHelperLoweringPass - public void Render_BindToElementFallback_SpecifiesValueAndChangeEvent_BodyContent() - { - // Arrange - var component = CompileToComponent(@" -
- @(42.ToString()) -
-@code { - public int ParentValue { get; set; } = 42; -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "div", 7, 0), - frame => AssertFrame.Attribute(frame, "value", "42", 1), - frame => AssertFrame.Attribute(frame, "onchange", typeof(EventCallback), 2), - frame => AssertFrame.MarkupWhitespace(frame, 3), - frame => AssertFrame.Element(frame, "span", 2, 4), - frame => AssertFrame.Text(frame, "42", 5), - frame => AssertFrame.MarkupWhitespace(frame, 6)); - } - - [Fact] - public void Render_BindFallback_InvalidSyntax_TooManyParts() - { - // Arrange & Act - var generated = CompileToCSharp(@" - -@code { - public string Text { get; set; } = ""text""; -}"); - - // Assert - var diagnostic = Assert.Single(generated.Diagnostics); - Assert.Equal("RZ9991", diagnostic.Id); - } - - [Fact] - public void Render_BindFallback_InvalidSyntax_TrailingDash() - { - // Arrange & Act - var generated = CompileToCSharp(@" - -@code { - public string Text { get; set; } = ""text""; -}"); - - // Assert - var diagnostic = Assert.Single(generated.Diagnostics); - Assert.Equal("RZ9991", diagnostic.Id); - } - } -} diff --git a/src/Components/Blazor/Build/test/ChildContentRazorIntegrationTest.cs b/src/Components/Blazor/Build/test/ChildContentRazorIntegrationTest.cs deleted file mode 100644 index 720c00fe9b..0000000000 --- a/src/Components/Blazor/Build/test/ChildContentRazorIntegrationTest.cs +++ /dev/null @@ -1,407 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Test.Helpers; -using Microsoft.CodeAnalysis.CSharp; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Blazor.Build.Test -{ - public class ChildContentRazorIntegrationTest : RazorIntegrationTestBase - { - private readonly CSharpSyntaxTree RenderChildContentComponent = Parse(@" -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Rendering; -namespace Test -{ - public class RenderChildContent : ComponentBase - { - protected override void BuildRenderTree(RenderTreeBuilder builder) - { - builder.AddContent(0, ChildContent); - } - - [Parameter] - public RenderFragment ChildContent { get; set; } - } -} -"); - - private readonly CSharpSyntaxTree RenderChildContentStringComponent = Parse(@" -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Rendering; -namespace Test -{ - public class RenderChildContentString : ComponentBase - { - protected override void BuildRenderTree(RenderTreeBuilder builder) - { - builder.AddContent(0, ChildContent, Value); - } - - [Parameter] - public RenderFragment ChildContent { get; set; } - - [Parameter] - public string Value { get; set; } - } -} -"); - - private readonly CSharpSyntaxTree RenderMultipleChildContent = Parse(@" -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Rendering; -namespace Test -{ - public class RenderMultipleChildContent : ComponentBase - { - protected override void BuildRenderTree(RenderTreeBuilder builder) - { - builder.AddContent(0, Header, Name); - builder.AddContent(1, ChildContent, Value); - builder.AddContent(2, Footer); - } - - [Parameter] - public string Name { get; set; } - - [Parameter] - public RenderFragment Header { get; set; } - - [Parameter] - public RenderFragment ChildContent { get; set; } - - [Parameter] - public RenderFragment Footer { get; set; } - - [Parameter] - public string Value { get; set; } - } -} -"); - - public ChildContentRazorIntegrationTest(ITestOutputHelper output) - : base(output) - { - } - - internal override bool UseTwoPhaseCompilation => true; - - [Fact] - public void Render_BodyChildContent() - { - // Arrange - AdditionalSyntaxTrees.Add(RenderChildContentComponent); - - var component = CompileToComponent(@" - -
-
"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 0), - frame => AssertFrame.Attribute(frame, "ChildContent", 1), - frame => AssertFrame.Markup(frame, "\n
\n", 2)); - } - - [Fact] - public void Render_BodyChildContent_Generic() - { - // Arrange - AdditionalSyntaxTrees.Add(RenderChildContentStringComponent); - - var component = CompileToComponent(@" - -
@context.ToLowerInvariant()
-
"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.RenderChildContentString", 3, 0), - frame => AssertFrame.Attribute(frame, "Value", "HI", 1), - frame => AssertFrame.Attribute(frame, "ChildContent", 2), - frame => AssertFrame.MarkupWhitespace(frame, 3), - frame => AssertFrame.Element(frame, "div", 2, 4), - frame => AssertFrame.Text(frame, "hi", 5), - frame => AssertFrame.MarkupWhitespace(frame, 6)); - } - - [Fact] - public void Render_ExplicitChildContent() - { - // Arrange - AdditionalSyntaxTrees.Add(RenderChildContentComponent); - - var component = CompileToComponent(@" - - -
-
-
"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 0), - frame => AssertFrame.Attribute(frame, "ChildContent", 1), - frame => AssertFrame.Markup(frame, "\n
\n ", 2)); - } - - [Fact] - public void Render_BodyChildContent_Recursive() - { - // Arrange - AdditionalSyntaxTrees.Add(RenderChildContentComponent); - - var component = CompileToComponent(@" - - - -
-
-
"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 0), - frame => AssertFrame.Attribute(frame, "ChildContent", 1), - frame => AssertFrame.MarkupWhitespace(frame, 2), - frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 3), - frame => AssertFrame.Attribute(frame, "ChildContent", 4), - frame => AssertFrame.MarkupWhitespace(frame, 6), - frame => AssertFrame.Markup(frame, "\n
\n ", 5)); - } - - [Fact] - public void Render_AttributeChildContent() - { - // Arrange - AdditionalSyntaxTrees.Add(RenderChildContentComponent); - - var component = CompileToComponent(@" -@{ RenderFragment template = (context) => @
@context.ToLowerInvariant()
; } -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 2), - frame => AssertFrame.Attribute(frame, "ChildContent", 3), - frame => AssertFrame.Element(frame, "div", 2, 0), - frame => AssertFrame.Text(frame, "hi", 1)); - } - - [Fact] - public void Render_AttributeChildContent_RenderFragmentOfString() - { - // Arrange - AdditionalSyntaxTrees.Add(RenderChildContentStringComponent); - - var component = CompileToComponent(@" -@{ RenderFragment template = (context) => @
@context.ToLowerInvariant()
; } -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.RenderChildContentString", 3, 2), - frame => AssertFrame.Attribute(frame, "ChildContent", 3), - frame => AssertFrame.Attribute(frame, "Value", "HI", 4), - frame => AssertFrame.Element(frame, "div", 2, 0), - frame => AssertFrame.Text(frame, "hi", 1)); - } - - [Fact] - public void Render_AttributeChildContent_NoArgTemplate() - { - // Arrange - AdditionalSyntaxTrees.Add(RenderChildContentComponent); - - var component = CompileToComponent(@" -@{ RenderFragment template = @
@(""HI"".ToLowerInvariant())
; } -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 2), - frame => AssertFrame.Attribute(frame, "ChildContent", 3), - frame => AssertFrame.Element(frame, "div", 2, 0), - frame => AssertFrame.Text(frame, "hi", 1)); - } - - [Fact] - public void Render_AttributeChildContent_IgnoresEmptyBody() - { - // Arrange - AdditionalSyntaxTrees.Add(RenderChildContentComponent); - - var component = CompileToComponent(@" -@{ RenderFragment template = (context) => @
@context.ToLowerInvariant()
; } -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 2), - frame => AssertFrame.Attribute(frame, "ChildContent", 3), - frame => AssertFrame.Element(frame, "div", 2, 0), - frame => AssertFrame.Text(frame, "hi", 1)); - } - - [Fact] - public void Render_AttributeChildContent_IgnoresWhitespaceBody() - { - // Arrange - AdditionalSyntaxTrees.Add(RenderChildContentComponent); - - var component = CompileToComponent(@" -@{ RenderFragment template = (context) => @
@context.ToLowerInvariant()
; } - - -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 2), - frame => AssertFrame.Attribute(frame, "ChildContent", 3), - frame => AssertFrame.Element(frame, "div", 2, 0), - frame => AssertFrame.Text(frame, "hi", 1)); - } - - [Fact] - public void Render_MultipleChildContent() - { - // Arrange - AdditionalSyntaxTrees.Add(RenderMultipleChildContent); - - var component = CompileToComponent(@" -@{ RenderFragment header = context => @
@context.ToLowerInvariant()
; } - - Some @context.ToLowerInvariant() Content -
Bye!
-
"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.RenderMultipleChildContent", 6, 2), - frame => AssertFrame.Attribute(frame, "Name", "billg", 3), - frame => AssertFrame.Attribute(frame, "Header", typeof(RenderFragment), 4), - frame => AssertFrame.Attribute(frame, "Value", "HI", 5), - frame => AssertFrame.Attribute(frame, "ChildContent", typeof(RenderFragment), 6), - frame => AssertFrame.Attribute(frame, "Footer", typeof(RenderFragment), 10), - frame => AssertFrame.Element(frame, "div", 2, 0), - frame => AssertFrame.Text(frame, "billg", 1), - frame => AssertFrame.Text(frame, "Some ", 7), - frame => AssertFrame.Text(frame, "hi", 8), - frame => AssertFrame.Text(frame, " Content", 9), - frame => AssertFrame.Text(frame, "Bye!", 11)); - } - - [Fact] - public void Render_MultipleChildContent_ContextParameterOnComponent() - { - // Arrange - AdditionalSyntaxTrees.Add(RenderMultipleChildContent); - - var component = CompileToComponent(@" - -
@item.ToLowerInvariant()
- Some @Context.ToLowerInvariant() Content -
Bye!
-
"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.RenderMultipleChildContent", 6, 0), - frame => AssertFrame.Attribute(frame, "Name", "billg", 1), - frame => AssertFrame.Attribute(frame, "Value", "HI", 2), - frame => AssertFrame.Attribute(frame, "Header", typeof(RenderFragment), 3), - frame => AssertFrame.Attribute(frame, "ChildContent", typeof(RenderFragment), 6), - frame => AssertFrame.Attribute(frame, "Footer", typeof(RenderFragment), 10), - frame => AssertFrame.Element(frame, "div", 2, 4), - frame => AssertFrame.Text(frame, "billg", 5), - frame => AssertFrame.Text(frame, "Some ", 7), - frame => AssertFrame.Text(frame, "hi", 8), - frame => AssertFrame.Text(frame, " Content", 9), - frame => AssertFrame.Text(frame, "Bye!", 11)); - } - - // Verifies that our check for reuse of parameter names isn't too aggressive. - [Fact] - public void Render_MultipleChildContent_ContextParameterOnComponent_SetsSameName() - { - // Arrange - AdditionalSyntaxTrees.Add(RenderMultipleChildContent); - - var component = CompileToComponent(@" - - -
@item.ToLowerInvariant()
- Some @item.ToLowerInvariant() Content -
Bye!
-
"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.RenderMultipleChildContent", 6, 0), - frame => AssertFrame.Attribute(frame, "Name", "billg", 1), - frame => AssertFrame.Attribute(frame, "Value", "HI", 2), - frame => AssertFrame.Attribute(frame, "Header", typeof(RenderFragment), 3), - frame => AssertFrame.Attribute(frame, "ChildContent", typeof(RenderFragment), 6), - frame => AssertFrame.Attribute(frame, "Footer", typeof(RenderFragment), 10), - frame => AssertFrame.Element(frame, "div", 2, 4), - frame => AssertFrame.Text(frame, "billg", 5), - frame => AssertFrame.Text(frame, "Some ", 7), - frame => AssertFrame.Text(frame, "hi", 8), - frame => AssertFrame.Text(frame, " Content", 9), - frame => AssertFrame.Text(frame, "Bye!", 11)); - } - } -} diff --git a/src/Components/Blazor/Build/test/ComponentRenderingRazorIntegrationTest.cs b/src/Components/Blazor/Build/test/ComponentRenderingRazorIntegrationTest.cs deleted file mode 100644 index d15cf4f584..0000000000 --- a/src/Components/Blazor/Build/test/ComponentRenderingRazorIntegrationTest.cs +++ /dev/null @@ -1,616 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Linq; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.RenderTree; -using Microsoft.AspNetCore.Components.Test.Helpers; -using Microsoft.AspNetCore.Components.Web; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Blazor.Build.Test -{ - public class ComponentRenderingRazorIntegrationTest : RazorIntegrationTestBase - { - public ComponentRenderingRazorIntegrationTest(ITestOutputHelper output) - : base(output) - { - } - - internal override bool UseTwoPhaseCompilation => true; - - [Fact] - public void Render_ChildComponent_Simple() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class MyComponent : ComponentBase - { - } -} -")); - - var component = CompileToComponent(@" -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 1, 0)); - } - - [Fact] - public void Render_ChildComponent_WithParameters() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class SomeType - { - } - - public class MyComponent : ComponentBase - { - [Parameter] public int IntProperty { get; set; } - [Parameter] public bool BoolProperty { get; set; } - [Parameter] public string StringProperty { get; set; } - [Parameter] public SomeType ObjectProperty { get; set; } - } -} -")); - - var component = CompileToComponent(@" -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 5, 0), - frame => AssertFrame.Attribute(frame, "IntProperty", 123, 1), - frame => AssertFrame.Attribute(frame, "BoolProperty", true, 2), - frame => AssertFrame.Attribute(frame, "StringProperty", "My string", 3), - frame => - { - AssertFrame.Attribute(frame, "ObjectProperty", 4); - Assert.Equal("Test.SomeType", frame.AttributeValue.GetType().FullName); - }); - } - - [Fact] - public void Render_ChildComponent_TriesToSetNonParamter() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class MyComponent : ComponentBase - { - public int IntProperty { get; set; } - } -} -")); - - var component = CompileToComponent(@" -"); - - // Act - var ex = Assert.Throws(() => GetRenderTree(component)); - - // Assert - Assert.Equal( - "Object of type 'Test.MyComponent' has a property matching the name 'IntProperty', " + - "but it does not have [ParameterAttribute] or [CascadingParameterAttribute] applied.", - ex.Message); - } - - [Fact] - public void Render_ChildComponent_WithExplicitStringParameter() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class MyComponent : ComponentBase - { - [Parameter] - public string StringProperty { get; set; } - } -} -")); - - var component = CompileToComponent(@" -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 0), - frame => AssertFrame.Attribute(frame, "StringProperty", "42", 1)); - } - - [Fact] - public void Render_ChildComponent_WithNonPropertyAttributes() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using System.Threading.Tasks; -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class MyComponent : ComponentBase, IComponent - { - Task IComponent.SetParametersAsync(ParameterView parameters) - { - return Task.CompletedTask; - } - } -} -")); - - var component = CompileToComponent(@" -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 3, 0), - frame => AssertFrame.Attribute(frame, "some-attribute", "foo", 1), - frame => AssertFrame.Attribute(frame, "another-attribute", "42", 2)); - } - - - [Theory] - [InlineData("e => Increment(e)")] - [InlineData("(e) => Increment(e)")] - [InlineData("@(e => Increment(e))")] - [InlineData("@(e => { Increment(e); })")] - [InlineData("Increment")] - [InlineData("@Increment")] - [InlineData("@(Increment)")] - public void Render_ChildComponent_WithEventHandler(string expression) - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using System; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Web; - -namespace Test -{ - public class MyComponent : ComponentBase - { - [Parameter] - public Action OnClick { get; set; } - } -} -")); - - var component = CompileToComponent($@" -@using Microsoft.AspNetCore.Components.Web - - -@code {{ - private int counter; - private void Increment(MouseEventArgs e) {{ - counter++; - }} -}}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 0), - frame => - { - AssertFrame.Attribute(frame, "OnClick", 1); - - // The handler will have been assigned to a lambda - var handler = Assert.IsType>(frame.AttributeValue); - Assert.Equal("Test.TestComponent", handler.Target.GetType().FullName); - }); - } - - [Fact] - public void Render_ChildComponent_WithExplicitEventHandler() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using System; -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class MyComponent : ComponentBase - { - [Parameter] - public Action OnClick { get; set; } - } -} -")); - - var component = CompileToComponent(@" - - -@code { - private int counter; - private void Increment(EventArgs e) { - counter++; - } -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 0), - frame => - { - AssertFrame.Attribute(frame, "OnClick", 1); - - // The handler will have been assigned to a lambda - var handler = Assert.IsType>(frame.AttributeValue); - Assert.Equal("Test.TestComponent", handler.Target.GetType().FullName); - Assert.Equal("Increment", handler.Method.Name); - }); - } - - [Fact] - public void Render_ChildComponent_WithMinimizedBoolAttribute() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class MyComponent : ComponentBase - { - [Parameter] - public bool BoolProperty { get; set; } - } -}")); - - var component = CompileToComponent(@" -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 0), - frame => AssertFrame.Attribute(frame, "BoolProperty", true, 1)); - } - - [Fact] - public void Render_ChildComponent_WithChildContent() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using Microsoft.AspNetCore.Components; -namespace Test -{ - public class MyComponent : ComponentBase - { - [Parameter] - public string MyAttr { get; set; } - - [Parameter] - public RenderFragment ChildContent { get; set; } - } -} -")); - - var component = CompileToComponent(@" -Some textNested text @(""Hello"")"); - - // Act - var frames = GetRenderTree(component); - - // Assert: component frames are correct - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 3, 0), - frame => AssertFrame.Attribute(frame, "MyAttr", "abc", 1), - frame => AssertFrame.Attribute(frame, "ChildContent", 2)); - - // Assert: Captured ChildContent frames are correct - var childFrames = GetFrames((RenderFragment)frames[2].AttributeValue); - Assert.Collection( - childFrames.AsEnumerable(), - frame => AssertFrame.Text(frame, "Some text", 3), - frame => AssertFrame.Element(frame, "some-child", 4, 4), - frame => AssertFrame.Attribute(frame, "a", "1", 5), - frame => AssertFrame.Text(frame, "Nested text ", 6), - frame => AssertFrame.Text(frame, "Hello", 7)); - } - - [Fact] - public void Render_ChildComponent_Nested() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class MyComponent : ComponentBase - { - [Parameter] - public RenderFragment ChildContent { get; set; } - } -} -")); - - var component = CompileToComponent(@" -Some text"); - - // Act - var frames = GetRenderTree(component); - - // Assert: outer component frames are correct - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 0), - frame => AssertFrame.Attribute(frame, "ChildContent", 1)); - - // Assert: first level of ChildContent is correct - // Note that we don't really need the sequence numbers to continue on from the - // sequence numbers at the parent level. All that really matters is that they are - // correct relative to each other (i.e., incrementing) within the nesting level. - // As an implementation detail, it happens that they do follow on from the parent - // level, but we could change that part of the implementation if we wanted. - var innerFrames = GetFrames((RenderFragment)frames[1].AttributeValue).AsEnumerable().ToArray(); - Assert.Collection( - innerFrames, - frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 2), - frame => AssertFrame.Attribute(frame, "ChildContent", 3)); - - // Assert: second level of ChildContent is correct - Assert.Collection( - GetFrames((RenderFragment)innerFrames[1].AttributeValue).AsEnumerable(), - frame => AssertFrame.Text(frame, "Some text", 4)); - } - - [Fact] // https://github.com/aspnet/Blazor/issues/773 - public void Regression_773() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using Microsoft.AspNetCore.Components; - -namespace Test -{ - public class SurveyPrompt : ComponentBase - { - [Parameter] public string Title { get; set; } - } -} -")); - - var component = CompileToComponent(@" -@page ""/"" - -Test!
"" /> -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.SurveyPrompt", 2, 0), - frame => AssertFrame.Attribute(frame, "Title", "
Test!
", 1)); - } - - - [Fact] - public void Regression_784() - { - // Arrange - - // Act - var component = CompileToComponent(@" -@using Microsoft.AspNetCore.Components.Web -

-@code { - public string ParentBgColor { get; set; } = ""#FFFFFF""; - - public void OnComponentHover(MouseEventArgs e) - { - } -} -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "p", 3, 0), - frame => AssertFrame.Attribute(frame, "onmouseover", 1), - frame => AssertFrame.Attribute(frame, "style", "background: #FFFFFF;", 2)); - } - - [Fact(Skip = "https://github.com/aspnet/AspNetCore/issues/6185")] - public void Render_Component_HtmlEncoded() - { - // Arrange - var component = CompileToComponent(@"<span>Hi</span>"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Text(frame, "Hi")); - } - - [Fact] - public void Render_Component_HtmlBlockEncoded() - { - // Arrange - var component = CompileToComponent(@"

<span>Hi</span>
"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Markup(frame, "
<span>Hi</span>
")); - } - - // Integration test for HTML block rewriting - [Fact(Skip = "https://github.com/aspnet/AspNetCore/issues/6183")] - public void Render_HtmlBlock_Integration() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using Microsoft.AspNetCore.Components; -namespace Test -{ - public class MyComponent : ComponentBase - { - [Parameter] - public RenderFragment ChildContent { get; set; } - } -} -")); - - var component = CompileToComponent(@" - - - - -
-
@(""hi"")
-
-
-
@(""hi"")
-
-
- -"); - - // Act - var frames = GetRenderTree(component); - - // Assert: component frames are correct - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "html", 9, 0), - frame => AssertFrame.MarkupWhitespace(frame, 1), - frame => AssertFrame.Markup(frame, "\n ", 2), - frame => AssertFrame.Element(frame, "body", 5, 3), - frame => AssertFrame.MarkupWhitespace(frame, 4), - frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 5), - frame => AssertFrame.Attribute(frame, "ChildContent", 6), - frame => AssertFrame.MarkupWhitespace(frame, 16), - frame => AssertFrame.MarkupWhitespace(frame, 17)); - - // Assert: Captured ChildContent frames are correct - var childFrames = GetFrames((RenderFragment)frames[6].AttributeValue); - Assert.Collection( - childFrames.AsEnumerable(), - frame => AssertFrame.MarkupWhitespace(frame, 7), - frame => AssertFrame.Markup(frame, "
\n ", 8), - frame => AssertFrame.Element(frame, "div", 2, 9), - frame => AssertFrame.Text(frame, "hi", 10), - frame => AssertFrame.MarkupWhitespace(frame, 11), - frame => AssertFrame.Markup(frame, "
\n
\n ", 12), - frame => AssertFrame.Element(frame, "div", 2, 13), - frame => AssertFrame.Text(frame, "hi", 14), - frame => AssertFrame.Markup(frame, "\n
\n ", 15)); - } - - [Fact] - public void RazorTemplate_CanBeUsedFromComponent() - { - // Arrange - AdditionalSyntaxTrees.Add(Parse(@" -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Rendering; - -namespace Test -{ - public class Repeater : ComponentBase - { - [Parameter] public int Count { get; set; } - [Parameter] public RenderFragment Template { get; set; } - [Parameter] public string Value { get; set; } - - protected override void BuildRenderTree(RenderTreeBuilder builder) - { - for (var i = 0; i < Count; i++) - { - builder.AddContent(i, Template, Value); - } - } - } -} -")); - - var component = CompileToComponent(@" -@{ RenderFragment template = (context) => @
@context.ToLower()
; } - -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, "Test.Repeater", 4, 2), - frame => AssertFrame.Attribute(frame, "Count", typeof(int), 3), - frame => AssertFrame.Attribute(frame, "Value", typeof(string), 4), - frame => AssertFrame.Attribute(frame, "Template", typeof(RenderFragment), 5), - frame => AssertFrame.Element(frame, "div", 2, 0), - frame => AssertFrame.Text(frame, "hello, world!", 1), - frame => AssertFrame.Element(frame, "div", 2, 0), - frame => AssertFrame.Text(frame, "hello, world!", 1), - frame => AssertFrame.Element(frame, "div", 2, 0), - frame => AssertFrame.Text(frame, "hello, world!", 1)); - } - } -} diff --git a/src/Components/Blazor/Build/test/DirectiveRazorIntegrationTest.cs b/src/Components/Blazor/Build/test/DirectiveRazorIntegrationTest.cs deleted file mode 100644 index ef46dd1d19..0000000000 --- a/src/Components/Blazor/Build/test/DirectiveRazorIntegrationTest.cs +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Test.Helpers; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Blazor.Build.Test -{ - // Integration tests for Blazor's directives - public class DirectiveRazorIntegrationTest : RazorIntegrationTestBase - { - public DirectiveRazorIntegrationTest(ITestOutputHelper output) - : base(output) - { - } - - [Fact] - public void ComponentsDoNotHaveLayoutAttributeByDefault() - { - // Arrange/Act - var component = CompileToComponent($"Hello"); - - // Assert - Assert.Null(component.GetType().GetCustomAttribute()); - } - - [Fact] - public void SupportsLayoutDeclarations() - { - // Arrange/Act - var testComponentTypeName = FullTypeName(); - var component = CompileToComponent( - $"@layout {testComponentTypeName}\n" + - $"Hello"); - var frames = GetRenderTree(component); - - // Assert - var layoutAttribute = component.GetType().GetCustomAttribute(); - Assert.NotNull(layoutAttribute); - Assert.Equal(typeof(TestLayout), layoutAttribute.LayoutType); - Assert.Collection(frames, - frame => AssertFrame.Text(frame, "Hello")); - } - - [Fact] - public void SupportsImplementsDeclarations() - { - // Arrange/Act - var testInterfaceTypeName = FullTypeName(); - var component = CompileToComponent( - $"@implements {testInterfaceTypeName}\n" + - $"Hello"); - var frames = GetRenderTree(component); - - // Assert - Assert.IsAssignableFrom(component); - Assert.Collection(frames, - frame => AssertFrame.Text(frame, "Hello")); - } - - [Fact] - public void SupportsMultipleImplementsDeclarations() - { - // Arrange/Act - var testInterfaceTypeName = FullTypeName(); - var testInterfaceTypeName2 = FullTypeName(); - var component = CompileToComponent( - $"@implements {testInterfaceTypeName}\n" + - $"@implements {testInterfaceTypeName2}\n" + - $"Hello"); - var frames = GetRenderTree(component); - - // Assert - Assert.IsAssignableFrom(component); - Assert.IsAssignableFrom(component); - Assert.Collection(frames, - frame => AssertFrame.Text(frame, "Hello")); - } - - [Fact] - public void SupportsInheritsDirective() - { - // Arrange/Act - var testBaseClassTypeName = FullTypeName(); - var component = CompileToComponent( - $"@inherits {testBaseClassTypeName}" + Environment.NewLine + - $"Hello"); - var frames = GetRenderTree(component); - - // Assert - Assert.IsAssignableFrom(component); - Assert.Collection(frames, - frame => AssertFrame.Text(frame, "Hello")); - } - - [Fact] - public void SupportsInjectDirective() - { - // Arrange/Act 1: Compilation - var componentType = CompileToComponent( - $"@inject {FullTypeName()} MyService1\n" + - $"@inject {FullTypeName()} MyService2\n" + - $"Hello from @MyService1 and @MyService2").GetType(); - - // Assert 1: Compiled type has correct properties - var propertyFlags = BindingFlags.Instance | BindingFlags.NonPublic; - var injectableProperties = componentType.GetProperties(propertyFlags) - .Where(p => p.GetCustomAttribute() != null); - Assert.Collection(injectableProperties.OrderBy(p => p.Name), - property => - { - Assert.Equal("MyService1", property.Name); - Assert.Equal(typeof(IMyService1), property.PropertyType); - Assert.False(property.GetMethod.IsPublic); - Assert.False(property.SetMethod.IsPublic); - }, - property => - { - Assert.Equal("MyService2", property.Name); - Assert.Equal(typeof(IMyService2), property.PropertyType); - Assert.False(property.GetMethod.IsPublic); - Assert.False(property.SetMethod.IsPublic); - }); - - // Arrange/Act 2: DI-supplied component has correct behavior - var serviceProvider = new TestServiceProvider(); - serviceProvider.AddService(new MyService1Impl()); - serviceProvider.AddService(new MyService2Impl()); - var componentFactory = new ComponentFactory(); - var component = componentFactory.InstantiateComponent(serviceProvider, componentType); - var frames = GetRenderTree(component); - - // Assert 2: Rendered component behaves correctly - Assert.Collection(frames, - frame => AssertFrame.Text(frame, "Hello from "), - frame => AssertFrame.Text(frame, typeof(MyService1Impl).FullName), - frame => AssertFrame.Text(frame, " and "), - frame => AssertFrame.Text(frame, typeof(MyService2Impl).FullName)); - } - - public class TestLayout : IComponent - { - [Parameter] - public RenderFragment Body { get; set; } - - public void Attach(RenderHandle renderHandle) - { - } - - public Task SetParametersAsync(ParameterView parameters) - { - return Task.CompletedTask; - } - } - - public interface ITestInterface { } - - public interface ITestInterface2 { } - - public class TestBaseClass : ComponentBase { } - - public interface IMyService1 { } - public interface IMyService2 { } - public class MyService1Impl : IMyService1 { } - public class MyService2Impl : IMyService2 { } - } -} diff --git a/src/Components/Blazor/Build/test/GenericComponentRazorIntegrationTest.cs b/src/Components/Blazor/Build/test/GenericComponentRazorIntegrationTest.cs deleted file mode 100644 index 7527e83535..0000000000 --- a/src/Components/Blazor/Build/test/GenericComponentRazorIntegrationTest.cs +++ /dev/null @@ -1,314 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Test.Helpers; -using Microsoft.CodeAnalysis.CSharp; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Blazor.Build.Test -{ - public class GenericComponentRazorIntegrationTest : RazorIntegrationTestBase - { - private readonly CSharpSyntaxTree GenericContextComponent = Parse(@" -using System; -using System.Collections.Generic; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Rendering; -namespace Test -{ - public class GenericContext : ComponentBase - { - protected override void BuildRenderTree(RenderTreeBuilder builder) - { - var items = (IReadOnlyList)Items ?? Array.Empty(); - for (var i = 0; i < items.Count; i++) - { - if (ChildContent == null) - { - builder.AddContent(i, Items[i]); - } - else - { - builder.AddContent(i, ChildContent, new Context() { Index = i, Item = items[i], }); - } - } - } - - [Parameter] - public List Items { get; set; } - - [Parameter] - public RenderFragment ChildContent { get; set; } - - public class Context - { - public int Index { get; set; } - public TItem Item { get; set; } - } - } -} -"); - - private readonly CSharpSyntaxTree MultipleGenericParameterComponent = Parse(@" -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Rendering; -namespace Test -{ - public class MultipleGenericParameter : ComponentBase - { - protected override void BuildRenderTree(RenderTreeBuilder builder) - { - builder.AddContent(0, Item1); - builder.AddContent(1, Item2); - builder.AddContent(2, Item3); - } - - [Parameter] - public TItem1 Item1 { get; set; } - - [Parameter] - public TItem2 Item2 { get; set; } - - [Parameter] - public TItem3 Item3 { get; set; } - } -} -"); - - public GenericComponentRazorIntegrationTest(ITestOutputHelper output) - : base(output) - { - } - - internal override bool UseTwoPhaseCompilation => true; - - [Fact] - public void Render_GenericComponent_WithoutChildContent() - { - // Arrange - AdditionalSyntaxTrees.Add(GenericContextComponent); - - var component = CompileToComponent(@" -() { 1, 2, })"" />"); - - // Act - var frames = GetRenderTree(component); - - // Assert - var genericComponentType = component.GetType().Assembly.DefinedTypes - .Where(t => t.Name == "GenericContext`1") - .Single() - .MakeGenericType(typeof(int)); - - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, genericComponentType.FullName, 2, 0), - frame => AssertFrame.Attribute(frame, "Items", typeof(List), 1), - frame => AssertFrame.Text(frame, "1", 0), - frame => AssertFrame.Text(frame, "2", 1)); - } - - [Fact] - public void Render_GenericComponent_WithRef() - { - // Arrange - AdditionalSyntaxTrees.Add(GenericContextComponent); - - var component = CompileToComponent(@" -() { 1, 2, })"" @ref=""_my"" /> - -@code { - GenericContext _my; - void Foo() { GC.KeepAlive(_my); } -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - var genericComponentType = component.GetType().Assembly.DefinedTypes - .Where(t => t.Name == "GenericContext`1") - .Single() - .MakeGenericType(typeof(int)); - - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, genericComponentType.FullName, 3, 0), - frame => AssertFrame.Attribute(frame, "Items", typeof(List), 1), - frame => AssertFrame.ComponentReferenceCapture(frame, 2), - frame => AssertFrame.Text(frame, "1", 0), - frame => AssertFrame.Text(frame, "2", 1)); - } - - [Fact] - public void Render_GenericComponent_WithChildContent() - { - // Arrange - AdditionalSyntaxTrees.Add(GenericContextComponent); - - var component = CompileToComponent(@" -() { 1, 2, })""> -
@(context.Item * context.Index)
-
"); - - // Act - var frames = GetRenderTree(component); - - // Assert - var genericComponentType = component.GetType().Assembly.DefinedTypes - .Where(t => t.Name == "GenericContext`1") - .Single() - .MakeGenericType(typeof(int)); - - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, genericComponentType.FullName, 3, 0), - frame => AssertFrame.Attribute(frame, "Items", typeof(List), 1), - frame => AssertFrame.Attribute(frame, "ChildContent", 2), - frame => AssertFrame.MarkupWhitespace(frame, 3), - frame => AssertFrame.Element(frame, "div", 2, 4), - frame => AssertFrame.Text(frame, "0", 5), - frame => AssertFrame.MarkupWhitespace(frame, 6), - frame => AssertFrame.MarkupWhitespace(frame, 3), - frame => AssertFrame.Element(frame, "div", 2, 4), - frame => AssertFrame.Text(frame, "2", 5), - frame => AssertFrame.MarkupWhitespace(frame, 6)); - } - - [Fact] - public void Render_GenericComponent_TypeInference_WithRef() - { - // Arrange - AdditionalSyntaxTrees.Add(GenericContextComponent); - - var component = CompileToComponent(@" -() { 1, 2, })"" @ref=""_my"" /> - -@code { - GenericContext _my; - void Foo() { GC.KeepAlive(_my); } -}"); - - // Act - var frames = GetRenderTree(component); - - // Assert - var genericComponentType = component.GetType().Assembly.DefinedTypes - .Where(t => t.Name == "GenericContext`1") - .Single() - .MakeGenericType(typeof(int)); - - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, genericComponentType.FullName, 3, 0), - frame => AssertFrame.Attribute(frame, "Items", typeof(List), 1), - frame => AssertFrame.ComponentReferenceCapture(frame, 2), - frame => AssertFrame.Text(frame, "1", 0), - frame => AssertFrame.Text(frame, "2", 1)); - } - - [Fact] - public void Render_GenericComponent_TypeInference_WithRef_Recursive() - { - // Arrange - AdditionalSyntaxTrees.Add(GenericContextComponent); - - var assembly = CompileToAssembly("Test.cshtml", @" -@typeparam TItem - - -@code { - [Parameter] public List MyItems { get; set; } - GenericContext _my; - void Foo() { GC.KeepAlive(_my); } -}"); - - var componentType = assembly.Assembly.DefinedTypes - .Where(t => t.Name == "Test`1") - .Single() - .MakeGenericType(typeof(int)); - var component = (IComponent)Activator.CreateInstance(componentType); - - // Act - var frames = GetRenderTree(component); - - // Assert - var genericComponentType = assembly.Assembly.DefinedTypes - .Where(t => t.Name == "GenericContext`1") - .Single() - .MakeGenericType(typeof(int)); - - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, genericComponentType.FullName, 3, 0), - frame => AssertFrame.Attribute(frame, "Items", 1), - frame => AssertFrame.ComponentReferenceCapture(frame, 2)); - } - - [Fact] - public void Render_GenericComponent_TypeInference_WithoutChildContent() - { - // Arrange - AdditionalSyntaxTrees.Add(GenericContextComponent); - - var component = CompileToComponent(@" -() { 1, 2, })"" />"); - - // Act - var frames = GetRenderTree(component); - - // Assert - var genericComponentType = component.GetType().Assembly.DefinedTypes - .Where(t => t.Name == "GenericContext`1") - .Single() - .MakeGenericType(typeof(int)); - - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, genericComponentType.FullName, 2, 0), - frame => AssertFrame.Attribute(frame, "Items", typeof(List), 1), - frame => AssertFrame.Text(frame, "1", 0), - frame => AssertFrame.Text(frame, "2", 1)); - } - - [Fact] - public void Render_GenericComponent_MultipleParameters_WithChildContent() - { - // Arrange - AdditionalSyntaxTrees.Add(MultipleGenericParameterComponent); - - var component = CompileToComponent(@" -"); - - // Act - var frames = GetRenderTree(component); - - // Assert - var genericComponentType = component.GetType().Assembly.DefinedTypes - .Where(t => t.Name == "MultipleGenericParameter`3") - .Single() - .MakeGenericType(typeof(int), typeof(string), typeof(long)); - - Assert.Collection( - frames, - frame => AssertFrame.Component(frame, genericComponentType.FullName, 4, 0), - frame => AssertFrame.Attribute(frame, "Item1", 3, 1), - frame => AssertFrame.Attribute(frame, "Item2", "FOO", 2), - frame => AssertFrame.Attribute(frame, "Item3", 39L, 3), - frame => AssertFrame.Text(frame, "3", 0), - frame => AssertFrame.Text(frame, "FOO", 1), - frame => AssertFrame.Text(frame, "39", 2)); - } - } -} diff --git a/src/Components/Blazor/Build/test/Razor/NotFoundProjectItem.cs b/src/Components/Blazor/Build/test/Razor/NotFoundProjectItem.cs deleted file mode 100644 index ec5359db65..0000000000 --- a/src/Components/Blazor/Build/test/Razor/NotFoundProjectItem.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.IO; - -namespace Microsoft.AspNetCore.Razor.Language -{ - /// - /// A that does not exist. - /// - internal class NotFoundProjectItem : RazorProjectItem - { - /// - /// Initializes a new instance of . - /// - /// The base path. - /// The path. - public NotFoundProjectItem(string basePath, string path) - { - BasePath = basePath; - FilePath = path; - } - - /// - public override string BasePath { get; } - - /// - public override string FilePath { get; } - - /// - public override bool Exists => false; - - /// - public override string PhysicalPath => throw new NotSupportedException(); - - /// - public override Stream Read() => throw new NotSupportedException(); - } -} \ No newline at end of file diff --git a/src/Components/Blazor/Build/test/Razor/TestFile.cs b/src/Components/Blazor/Build/test/Razor/TestFile.cs deleted file mode 100644 index 70d5cacd70..0000000000 --- a/src/Components/Blazor/Build/test/Razor/TestFile.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.IO; -using System.Reflection; -using Xunit; - -namespace Microsoft.AspNetCore.Razor.Language -{ - public class TestFile - { - private TestFile(string resourceName, Assembly assembly) - { - Assembly = assembly; - ResourceName = Assembly.GetName().Name + "." + resourceName.Replace('/', '.').Replace('\\', '.'); - } - - public Assembly Assembly { get; } - - public string ResourceName { get; } - - public static TestFile Create(string resourceName, Type type) - { - return new TestFile(resourceName, type.GetTypeInfo().Assembly); - } - - public static TestFile Create(string resourceName, Assembly assembly) - { - return new TestFile(resourceName, assembly); - } - - public Stream OpenRead() - { - var stream = Assembly.GetManifestResourceStream(ResourceName); - if (stream == null) - { - Assert.True(false, string.Format("Manifest resource: {0} not found", ResourceName)); - } - - return stream; - } - - public bool Exists() - { - var resourceNames = Assembly.GetManifestResourceNames(); - foreach (var resourceName in resourceNames) - { - // Resource names are case-sensitive. - if (string.Equals(ResourceName, resourceName, StringComparison.Ordinal)) - { - return true; - } - } - - return false; - } - - public string ReadAllText() - { - using (var reader = new StreamReader(OpenRead())) - { - // The .Replace() calls normalize line endings, in case you get \n instead of \r\n - // since all the unit tests rely on the assumption that the files will have \r\n endings. - return reader.ReadToEnd().Replace("\r", "").Replace("\n", "\r\n"); - } - } - - /// - /// Saves the file to the specified path. - /// - public void Save(string filePath) - { - var directory = Path.GetDirectoryName(filePath); - if (!Directory.Exists(directory)) - { - Directory.CreateDirectory(directory); - } - - using (var outStream = File.Create(filePath)) - { - using (var inStream = OpenRead()) - { - inStream.CopyTo(outStream); - } - } - } - } -} diff --git a/src/Components/Blazor/Build/test/Razor/TestProject.cs b/src/Components/Blazor/Build/test/Razor/TestProject.cs deleted file mode 100644 index 5f14ef4bed..0000000000 --- a/src/Components/Blazor/Build/test/Razor/TestProject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.IO; - -namespace Microsoft.AspNetCore.Razor.Language -{ - public static class TestProject - { - public static string GetProjectDirectory(Type type) - { - var solutionDir = GetSolutionRootDirectory("Components"); - - var assemblyName = type.Assembly.GetName().Name; - - var projectDirectory = Path.Combine(solutionDir, "test", assemblyName); - if (!Directory.Exists(projectDirectory)) - { - throw new InvalidOperationException( -$@"Could not locate project directory for type {type.FullName}. -Directory probe path: {projectDirectory}."); - } - - return projectDirectory; - } - - public static string GetSolutionRootDirectory(string solution) - { - var applicationBasePath = AppContext.BaseDirectory; - var directoryInfo = new DirectoryInfo(applicationBasePath); - - do - { - var projectFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, $"{solution}.sln")); - if (projectFileInfo.Exists) - { - return projectFileInfo.DirectoryName; - } - - directoryInfo = directoryInfo.Parent; - } - while (directoryInfo.Parent != null); - - throw new Exception($"Solution file {solution}.sln could not be found in {applicationBasePath} or its parent directories."); - } - } -} diff --git a/src/Components/Blazor/Build/test/Razor/VirtualProjectFileSystem.cs b/src/Components/Blazor/Build/test/Razor/VirtualProjectFileSystem.cs deleted file mode 100644 index 3d694a82d0..0000000000 --- a/src/Components/Blazor/Build/test/Razor/VirtualProjectFileSystem.cs +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; - -namespace Microsoft.AspNetCore.Razor.Language -{ - internal class VirtualRazorProjectFileSystem : RazorProjectFileSystem - { - private readonly DirectoryNode _root = new DirectoryNode("/"); - - public override IEnumerable EnumerateItems(string basePath) - { - basePath = NormalizeAndEnsureValidPath(basePath); - var directory = _root.GetDirectory(basePath); - return directory?.EnumerateItems() ?? Enumerable.Empty(); - } - - [Obsolete("Use GetItem(string path, string fileKind)] instead")] - public override RazorProjectItem GetItem(string path) - { - return GetItem(path, fileKind: null); - } - - public override RazorProjectItem GetItem(string path, string fileKind) - { - // We ignore fileKind here because the _root is pre-filled with project items that already have fileKinds defined. This is - // a unique circumstance where the RazorProjectFileSystem is actually pre-filled with all of its project items on construction. - - path = NormalizeAndEnsureValidPath(path); - return _root.GetItem(path) ?? new NotFoundProjectItem(string.Empty, path); - } - - public void Add(RazorProjectItem projectItem) - { - if (projectItem == null) - { - throw new ArgumentNullException(nameof(projectItem)); - } - - var filePath = NormalizeAndEnsureValidPath(projectItem.FilePath); - _root.AddFile(new FileNode(filePath, projectItem)); - } - - // Internal for testing - [DebuggerDisplay("{Path}")] - internal class DirectoryNode - { - public DirectoryNode(string path) - { - Path = path; - } - - public string Path { get; } - - public List Directories { get; } = new List(); - - public List Files { get; } = new List(); - - public void AddFile(FileNode fileNode) - { - var filePath = fileNode.Path; - if (!filePath.StartsWith(Path, StringComparison.OrdinalIgnoreCase)) - { - var message = "Error"; - throw new InvalidOperationException(message); - } - - // Look for the first / that appears in the path after the current directory path. - var directoryPath = GetDirectoryPath(filePath); - var directory = GetOrAddDirectory(this, directoryPath, createIfNotExists: true); - Debug.Assert(directory != null); - directory.Files.Add(fileNode); - } - - public DirectoryNode GetDirectory(string path) - { - if (!path.StartsWith(Path, StringComparison.OrdinalIgnoreCase)) - { - var message = "Error"; - throw new InvalidOperationException(message); - } - - return GetOrAddDirectory(this, path); - } - - public IEnumerable EnumerateItems() - { - foreach (var file in Files) - { - yield return file.ProjectItem; - } - - foreach (var directory in Directories) - { - foreach (var file in directory.EnumerateItems()) - { - yield return file; - } - } - } - - public RazorProjectItem GetItem(string path) - { - if (!path.StartsWith(Path, StringComparison.OrdinalIgnoreCase)) - { - throw new InvalidOperationException("Error"); - } - - var directoryPath = GetDirectoryPath(path); - var directory = GetOrAddDirectory(this, directoryPath); - if (directory == null) - { - return null; - } - - foreach (var file in directory.Files) - { - var filePath = file.Path; - var directoryLength = directory.Path.Length; - - // path, filePath -> /Views/Home/Index.cshtml - // directory.Path -> /Views/Home/ - // We only need to match the file name portion since we've already matched the directory segment. - if (string.Compare(path, directoryLength, filePath, directoryLength, path.Length - directoryLength, StringComparison.OrdinalIgnoreCase) == 0) - { - return file.ProjectItem; - } - } - - return null; - } - - private static string GetDirectoryPath(string path) - { - // /dir1/dir2/file.cshtml -> /dir1/dir2/ - var fileNameIndex = path.LastIndexOf('/'); - if (fileNameIndex == -1) - { - return path; - } - - return path.Substring(0, fileNameIndex + 1); - } - - private static DirectoryNode GetOrAddDirectory( - DirectoryNode directory, - string path, - bool createIfNotExists = false) - { - Debug.Assert(!string.IsNullOrEmpty(path)); - if (path[path.Length - 1] != '/') - { - path += '/'; - } - - int index; - while ((index = path.IndexOf('/', directory.Path.Length)) != -1 && index != path.Length) - { - var subDirectory = FindSubDirectory(directory, path); - - if (subDirectory == null) - { - if (createIfNotExists) - { - var directoryPath = path.Substring(0, index + 1); // + 1 to include trailing slash - subDirectory = new DirectoryNode(directoryPath); - directory.Directories.Add(subDirectory); - } - else - { - return null; - } - } - - directory = subDirectory; - } - - return directory; - } - - private static DirectoryNode FindSubDirectory(DirectoryNode parentDirectory, string path) - { - for (var i = 0; i < parentDirectory.Directories.Count; i++) - { - // ParentDirectory.Path -> /Views/Home/ - // CurrentDirectory.Path -> /Views/Home/SubDir/ - // Path -> /Views/Home/SubDir/MorePath/File.cshtml - // Each invocation of FindSubDirectory returns the immediate subdirectory along the path to the file. - - var currentDirectory = parentDirectory.Directories[i]; - var directoryPath = currentDirectory.Path; - var startIndex = parentDirectory.Path.Length; - var directoryNameLength = directoryPath.Length - startIndex; - - if (string.Compare(path, startIndex, directoryPath, startIndex, directoryPath.Length - startIndex, StringComparison.OrdinalIgnoreCase) == 0) - { - return currentDirectory; - } - } - - return null; - } - } - - // Internal for testing - [DebuggerDisplay("{Path}")] - internal struct FileNode - { - public FileNode(string path, RazorProjectItem projectItem) - { - Path = path; - ProjectItem = projectItem; - } - - public string Path { get; } - - public RazorProjectItem ProjectItem { get; } - } - } -} diff --git a/src/Components/Blazor/Build/test/Razor/VirtualProjectItem.cs b/src/Components/Blazor/Build/test/Razor/VirtualProjectItem.cs deleted file mode 100644 index 68c135d715..0000000000 --- a/src/Components/Blazor/Build/test/Razor/VirtualProjectItem.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.IO; - -namespace Microsoft.AspNetCore.Razor.Language -{ - internal class VirtualProjectItem : RazorProjectItem - { - private readonly byte[] _content; - - public VirtualProjectItem( - string basePath, - string filePath, - string physicalPath, - string relativePhysicalPath, - string fileKind, - byte[] content) - { - BasePath = basePath; - FilePath = filePath; - PhysicalPath = physicalPath; - RelativePhysicalPath = relativePhysicalPath; - _content = content; - - // Base class will detect based on file-extension. - FileKind = fileKind ?? base.FileKind; - } - - public override string BasePath { get; } - - public override string RelativePhysicalPath { get; } - - public override string FileKind { get; } - - public override string FilePath { get; } - - public override string PhysicalPath { get; } - - public override bool Exists => true; - - public override Stream Read() - { - return new MemoryStream(_content); - } - } -} diff --git a/src/Components/Blazor/Build/test/RazorIntegrationTestBase.cs b/src/Components/Blazor/Build/test/RazorIntegrationTestBase.cs deleted file mode 100644 index 943a658a36..0000000000 --- a/src/Components/Blazor/Build/test/RazorIntegrationTestBase.cs +++ /dev/null @@ -1,542 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.ExceptionServices; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Rendering; -using Microsoft.AspNetCore.Components.RenderTree; -using Microsoft.AspNetCore.Components.Test.Helpers; -using Microsoft.AspNetCore.Razor.Language; -using Microsoft.AspNetCore.Razor.Language.CodeGeneration; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.Razor; -using Microsoft.Extensions.Logging.Abstractions; -using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Blazor.Build.Test -{ - public class RazorIntegrationTestBase - { - private static readonly AsyncLocal _output = new AsyncLocal(); - - internal const string ArbitraryWindowsPath = "x:\\dir\\subdir\\Test"; - internal const string ArbitraryMacLinuxPath = "/dir/subdir/Test"; - - // Creating the initial compilation + reading references is on the order of 250ms without caching - // so making sure it doesn't happen for each test. - private static readonly CSharpCompilation BaseCompilation; - - private static CSharpParseOptions CSharpParseOptions { get; } - - static RazorIntegrationTestBase() - { - var referenceAssemblyRoots = new[] - { - typeof(System.Runtime.AssemblyTargetedPatchBandAttribute).Assembly, // System.Runtime - typeof(ComponentBase).Assembly, - typeof(RazorIntegrationTestBase).Assembly, // Reference this assembly, so that we can refer to test component types - }; - - var referenceAssemblies = referenceAssemblyRoots - .SelectMany(assembly => assembly.GetReferencedAssemblies().Concat(new[] { assembly.GetName() })) - .Distinct() - .Select(Assembly.Load) - .Select(assembly => MetadataReference.CreateFromFile(assembly.Location)) - .ToList(); - BaseCompilation = CSharpCompilation.Create( - "TestAssembly", - Array.Empty(), - referenceAssemblies, - new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); - - CSharpParseOptions = new CSharpParseOptions(LanguageVersion.Preview); - } - - public RazorIntegrationTestBase(ITestOutputHelper output) - { - _output.Value = output; - - AdditionalSyntaxTrees = new List(); - AdditionalRazorItems = new List(); - - Configuration = RazorConfiguration.Create(RazorLanguageVersion.Latest, "MVC-3.0", Array.Empty()); - FileKind = FileKinds.Component; // Treat input files as components by default. - FileSystem = new VirtualRazorProjectFileSystem(); - PathSeparator = Path.DirectorySeparatorChar.ToString(); - WorkingDirectory = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ArbitraryWindowsPath : ArbitraryMacLinuxPath; - - // Many of the rendering tests include line endings in the output. - LineEnding = "\n"; - NormalizeSourceLineEndings = true; - - DefaultRootNamespace = "Test"; // Matches the default working directory - DefaultFileName = "TestComponent.cshtml"; - } - - internal List AdditionalRazorItems { get; } - - internal List AdditionalSyntaxTrees { get; } - - internal virtual RazorConfiguration Configuration { get; } - - internal virtual string DefaultRootNamespace { get; } - - internal virtual string DefaultFileName { get; } - - internal virtual bool DesignTime { get; } - - internal virtual string FileKind { get; } - - internal virtual VirtualRazorProjectFileSystem FileSystem { get; } - - // Used to force a specific style of line-endings for testing. This matters - // for the baseline tests that exercise line mappings. Even though we normalize - // newlines for testing, the difference between platforms affects the data through - // the *count* of characters written. - internal virtual string LineEnding { get; } - - internal virtual string PathSeparator { get; } - - internal virtual bool NormalizeSourceLineEndings { get; } - - internal virtual bool UseTwoPhaseCompilation { get; } - - internal virtual string WorkingDirectory { get; } - - // Intentionally private, we don't want tests messing with this because it's fragile. - private RazorProjectEngine CreateProjectEngine(MetadataReference[] references) - { - return RazorProjectEngine.Create(Configuration, FileSystem, b => - { - b.SetRootNamespace(DefaultRootNamespace); - - // Turn off checksums, we're testing code generation. - b.Features.Add(new SuppressChecksum()); - - if (LineEnding != null) - { - b.Phases.Insert(0, new ForceLineEndingPhase(LineEnding)); - } - - // Including MVC here so that we can find any issues that arise from mixed MVC + Components. - Microsoft.AspNetCore.Mvc.Razor.Extensions.RazorExtensions.Register(b); - - // Features that use Roslyn are mandatory for components - Microsoft.CodeAnalysis.Razor.CompilerFeatures.Register(b); - - b.Features.Add(new CompilationTagHelperFeature()); - b.Features.Add(new DefaultMetadataReferenceFeature() - { - References = references, - }); - }); - } - - internal RazorProjectItem CreateProjectItem(string cshtmlRelativePath, string cshtmlContent) - { - var fullPath = WorkingDirectory + PathSeparator + cshtmlRelativePath; - - // FilePaths in Razor are **always** are of the form '/a/b/c.cshtml' - var filePath = cshtmlRelativePath.Replace('\\', '/'); - if (!filePath.StartsWith('/')) - { - filePath = '/' + filePath; - } - - if (NormalizeSourceLineEndings) - { - cshtmlContent = cshtmlContent.Replace("\r", "").Replace("\n", LineEnding); - } - - return new VirtualProjectItem( - WorkingDirectory, - filePath, - fullPath, - cshtmlRelativePath, - FileKind, - Encoding.UTF8.GetBytes(cshtmlContent.TrimStart())); - } - - protected CompileToCSharpResult CompileToCSharp(string cshtmlContent) - { - return CompileToCSharp(DefaultFileName, cshtmlContent); - } - - protected CompileToCSharpResult CompileToCSharp(string cshtmlRelativePath, string cshtmlContent) - { - if (UseTwoPhaseCompilation) - { - // The first phase won't include any metadata references for component discovery. This mirrors - // what the build does. - var projectEngine = CreateProjectEngine(Array.Empty()); - - RazorCodeDocument codeDocument; - foreach (var item in AdditionalRazorItems) - { - // Result of generating declarations - codeDocument = projectEngine.ProcessDeclarationOnly(item); - Assert.Empty(codeDocument.GetCSharpDocument().Diagnostics); - - var syntaxTree = Parse(codeDocument.GetCSharpDocument().GeneratedCode, path: item.FilePath); - AdditionalSyntaxTrees.Add(syntaxTree); - } - - // Result of generating declarations - var projectItem = CreateProjectItem(cshtmlRelativePath, cshtmlContent); - codeDocument = projectEngine.ProcessDeclarationOnly(projectItem); - var declaration = new CompileToCSharpResult - { - BaseCompilation = BaseCompilation.AddSyntaxTrees(AdditionalSyntaxTrees), - CodeDocument = codeDocument, - Code = codeDocument.GetCSharpDocument().GeneratedCode, - Diagnostics = codeDocument.GetCSharpDocument().Diagnostics, - }; - - // Result of doing 'temp' compilation - var tempAssembly = CompileToAssembly(declaration); - - // Add the 'temp' compilation as a metadata reference - var references = BaseCompilation.References.Concat(new[] { tempAssembly.Compilation.ToMetadataReference() }).ToArray(); - projectEngine = CreateProjectEngine(references); - - // Now update the any additional files - foreach (var item in AdditionalRazorItems) - { - // Result of generating declarations - codeDocument = DesignTime ? projectEngine.ProcessDesignTime(item) : projectEngine.Process(item); - Assert.Empty(codeDocument.GetCSharpDocument().Diagnostics); - - // Replace the 'declaration' syntax tree - var syntaxTree = Parse(codeDocument.GetCSharpDocument().GeneratedCode, path: item.FilePath); - AdditionalSyntaxTrees.RemoveAll(st => st.FilePath == item.FilePath); - AdditionalSyntaxTrees.Add(syntaxTree); - } - - // Result of real code generation for the document under test - codeDocument = DesignTime ? projectEngine.ProcessDesignTime(projectItem) : projectEngine.Process(projectItem); - - _output.Value.WriteLine("Use this output when opening an issue"); - _output.Value.WriteLine(string.Empty); - - _output.Value.WriteLine($"## Main source file ({projectItem.FileKind}):"); - _output.Value.WriteLine("```"); - _output.Value.WriteLine(ReadProjectItem(projectItem)); - _output.Value.WriteLine("```"); - _output.Value.WriteLine(string.Empty); - - foreach (var item in AdditionalRazorItems) - { - _output.Value.WriteLine($"### Additional source file ({item.FileKind}):"); - _output.Value.WriteLine("```"); - _output.Value.WriteLine(ReadProjectItem(item)); - _output.Value.WriteLine("```"); - _output.Value.WriteLine(string.Empty); - } - - _output.Value.WriteLine("## Generated C#:"); - _output.Value.WriteLine("```C#"); - _output.Value.WriteLine(codeDocument.GetCSharpDocument().GeneratedCode); - _output.Value.WriteLine("```"); - - return new CompileToCSharpResult - { - BaseCompilation = BaseCompilation.AddSyntaxTrees(AdditionalSyntaxTrees), - CodeDocument = codeDocument, - Code = codeDocument.GetCSharpDocument().GeneratedCode, - Diagnostics = codeDocument.GetCSharpDocument().Diagnostics, - }; - } - else - { - // For single phase compilation tests just use the base compilation's references. - // This will include the built-in Blazor components. - var projectEngine = CreateProjectEngine(BaseCompilation.References.ToArray()); - - var projectItem = CreateProjectItem(cshtmlRelativePath, cshtmlContent); - var codeDocument = DesignTime ? projectEngine.ProcessDesignTime(projectItem) : projectEngine.Process(projectItem); - - // Log the generated code for test results. - _output.Value.WriteLine("Use this output when opening an issue"); - _output.Value.WriteLine(string.Empty); - - _output.Value.WriteLine($"## Main source file ({projectItem.FileKind}):"); - _output.Value.WriteLine("```"); - _output.Value.WriteLine(ReadProjectItem(projectItem)); - _output.Value.WriteLine("```"); - _output.Value.WriteLine(string.Empty); - - _output.Value.WriteLine("## Generated C#:"); - _output.Value.WriteLine("```C#"); - _output.Value.WriteLine(codeDocument.GetCSharpDocument().GeneratedCode); - _output.Value.WriteLine("```"); - - return new CompileToCSharpResult - { - BaseCompilation = BaseCompilation.AddSyntaxTrees(AdditionalSyntaxTrees), - CodeDocument = codeDocument, - Code = codeDocument.GetCSharpDocument().GeneratedCode, - Diagnostics = codeDocument.GetCSharpDocument().Diagnostics, - }; - } - } - - protected CompileToAssemblyResult CompileToAssembly(string cshtmlRelativePath, string cshtmlContent) - { - var cSharpResult = CompileToCSharp(cshtmlRelativePath, cshtmlContent); - return CompileToAssembly(cSharpResult); - } - - protected CompileToAssemblyResult CompileToAssembly(CompileToCSharpResult cSharpResult, bool throwOnFailure = true) - { - if (cSharpResult.Diagnostics.Any()) - { - var diagnosticsLog = string.Join(Environment.NewLine, cSharpResult.Diagnostics.Select(d => d.ToString()).ToArray()); - throw new InvalidOperationException($"Aborting compilation to assembly because RazorCompiler returned nonempty diagnostics: {diagnosticsLog}"); - } - - var syntaxTrees = new[] - { - Parse(cSharpResult.Code), - }; - - var compilation = cSharpResult.BaseCompilation.AddSyntaxTrees(syntaxTrees); - - var diagnostics = compilation - .GetDiagnostics() - .Where(d => d.Severity != DiagnosticSeverity.Hidden); - - if (diagnostics.Any() && throwOnFailure) - { - throw new CompilationFailedException(compilation); - } - else if (diagnostics.Any()) - { - return new CompileToAssemblyResult - { - Compilation = compilation, - Diagnostics = diagnostics, - }; - } - - using (var peStream = new MemoryStream()) - { - compilation.Emit(peStream); - - return new CompileToAssemblyResult - { - Compilation = compilation, - Diagnostics = diagnostics, - Assembly = diagnostics.Any() ? null : Assembly.Load(peStream.ToArray()) - }; - } - } - - protected IComponent CompileToComponent(string cshtmlSource) - { - var assemblyResult = CompileToAssembly(DefaultFileName, cshtmlSource); - - var componentFullTypeName = $"{DefaultRootNamespace}.{Path.GetFileNameWithoutExtension(DefaultFileName)}"; - return CompileToComponent(assemblyResult, componentFullTypeName); - } - - protected IComponent CompileToComponent(CompileToCSharpResult cSharpResult, string fullTypeName) - { - return CompileToComponent(CompileToAssembly(cSharpResult), fullTypeName); - } - - protected IComponent CompileToComponent(CompileToAssemblyResult assemblyResult, string fullTypeName) - { - var componentType = assemblyResult.Assembly.GetType(fullTypeName); - if (componentType == null) - { - throw new XunitException( - $"Failed to find component type '{fullTypeName}'. Found types:" + Environment.NewLine + - string.Join(Environment.NewLine, assemblyResult.Assembly.ExportedTypes.Select(t => t.FullName))); - } - - return (IComponent)Activator.CreateInstance(componentType); - } - - protected static CSharpSyntaxTree Parse(string text, string path = null) - { - return (CSharpSyntaxTree)CSharpSyntaxTree.ParseText(text, CSharpParseOptions, path: path); - } - - protected static string FullTypeName() => typeof(T).FullName.Replace('+', '.'); - - protected RenderTreeFrame[] GetRenderTree(IComponent component) - { - var renderer = new TestRenderer(); - return GetRenderTree(renderer, component); - } - - protected private RenderTreeFrame[] GetRenderTree(TestRenderer renderer, IComponent component) - { - renderer.AttachComponent(component); - var task = renderer.Dispatcher.InvokeAsync(() => component.SetParametersAsync(ParameterView.Empty)); - // we will have to change this method if we add a test that does actual async work. - Assert.True(task.Status.HasFlag(TaskStatus.RanToCompletion) || task.Status.HasFlag(TaskStatus.Faulted)); - if (task.IsFaulted) - { - ExceptionDispatchInfo.Capture(task.Exception.InnerException).Throw(); - } - return renderer.LatestBatchReferenceFrames; - } - - protected ArrayRange GetFrames(RenderFragment fragment) - { - var builder = new RenderTreeBuilder(); - fragment(builder); - return builder.GetFrames(); - } - - protected static void AssertSourceEquals(string expected, CompileToCSharpResult generated) - { - // Normalize the paths inside the expected result to match the OS paths - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - var windowsPath = Path.Combine(ArbitraryWindowsPath, generated.CodeDocument.Source.RelativePath).Replace('/', '\\'); - expected = expected.Replace(windowsPath, generated.CodeDocument.Source.FilePath); - } - - expected = expected.Trim(); - Assert.Equal(expected, generated.Code.Trim(), ignoreLineEndingDifferences: true); - } - - private static string ReadProjectItem(RazorProjectItem item) - { - using (var reader = new StreamReader(item.Read())) - { - return reader.ReadToEnd(); - } - } - - protected class CompileToCSharpResult - { - // A compilation that can be used *with* this code to compile an assembly - public Compilation BaseCompilation { get; set; } - public RazorCodeDocument CodeDocument { get; set; } - public string Code { get; set; } - public IEnumerable Diagnostics { get; set; } - } - - protected class CompileToAssemblyResult - { - public Assembly Assembly { get; set; } - public Compilation Compilation { get; set; } - public string VerboseLog { get; set; } - public IEnumerable Diagnostics { get; set; } - } - - protected class TestRenderer : Renderer - { - public TestRenderer() : base(new TestServiceProvider(), NullLoggerFactory.Instance) - { - } - - public override Dispatcher Dispatcher { get; } = Dispatcher.CreateDefault(); - - public RenderTreeFrame[] LatestBatchReferenceFrames { get; private set; } - - public void AttachComponent(IComponent component) - => AssignRootComponentId(component); - - protected override void HandleException(Exception exception) - { - ExceptionDispatchInfo.Capture(exception).Throw(); - } - - protected override Task UpdateDisplayAsync(in RenderBatch renderBatch) - { - LatestBatchReferenceFrames = renderBatch.ReferenceFrames.AsEnumerable().ToArray(); - return Task.CompletedTask; - } - } - - private class CompilationFailedException : XunitException - { - public CompilationFailedException(Compilation compilation) - { - Compilation = compilation; - } - - public Compilation Compilation { get; } - - public override string Message - { - get - { - var builder = new StringBuilder(); - builder.AppendLine("Compilation failed: "); - - var diagnostics = Compilation.GetDiagnostics(); - var syntaxTreesWithErrors = new HashSet(); - foreach (var diagnostic in diagnostics) - { - builder.AppendLine(diagnostic.ToString()); - - if (diagnostic.Location.IsInSource) - { - syntaxTreesWithErrors.Add(diagnostic.Location.SourceTree); - } - } - - if (syntaxTreesWithErrors.Any()) - { - builder.AppendLine(); - builder.AppendLine(); - - foreach (var syntaxTree in syntaxTreesWithErrors) - { - builder.AppendLine($"File {syntaxTree.FilePath ?? "unknown"}:"); - builder.AppendLine(syntaxTree.GetText().ToString()); - } - } - - return builder.ToString(); - } - } - } - - private class SuppressChecksum : IConfigureRazorCodeGenerationOptionsFeature - { - public int Order => 0; - - public RazorEngine Engine { get; set; } - - public void Configure(RazorCodeGenerationOptionsBuilder options) - { - options.SuppressChecksum = true; - } - } - - private class ForceLineEndingPhase : RazorEnginePhaseBase - { - public ForceLineEndingPhase(string lineEnding) - { - LineEnding = lineEnding; - } - - public string LineEnding { get; } - - protected override void ExecuteCore(RazorCodeDocument codeDocument) - { - var field = typeof(CodeRenderingContext).GetField("NewLineString", BindingFlags.Static | BindingFlags.NonPublic); - var key = field.GetValue(null); - codeDocument.Items[key] = LineEnding; - } - } - } -} diff --git a/src/Components/Blazor/Build/test/RenderingRazorIntegrationTest.cs b/src/Components/Blazor/Build/test/RenderingRazorIntegrationTest.cs deleted file mode 100644 index 3f380cbc79..0000000000 --- a/src/Components/Blazor/Build/test/RenderingRazorIntegrationTest.cs +++ /dev/null @@ -1,744 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.RenderTree; -using Microsoft.AspNetCore.Components.Test.Helpers; -using Microsoft.AspNetCore.Components.Web; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Blazor.Build.Test -{ - // Integration tests for the end-to-end of successful Razor compilation of component definitions - // Includes running the component code to verify the output. - public class RenderingRazorIntegrationTest : RazorIntegrationTestBase - { - public RenderingRazorIntegrationTest(ITestOutputHelper output) - : base(output) - { - } - - [Fact] - public void SupportsPlainText() - { - // Arrange/Act - var component = CompileToComponent("Some plain text"); - var frames = GetRenderTree(component); - - // Assert - Assert.Collection(frames, - frame => AssertFrame.Text(frame, "Some plain text", 0)); - } - - [Fact] - public void SupportsCSharpExpressions() - { - // Arrange/Act - var component = CompileToComponent(@" - @(""Hello"") - @((object)null) - @(123) - @(new object()) - "); - - // Assert - var frames = GetRenderTree(component); - Assert.Collection(frames, - frame => AssertFrame.Text(frame, "Hello", 0), - frame => AssertFrame.MarkupWhitespace(frame, 1), - frame => AssertFrame.TextWhitespace(frame, 2), // @((object)null) - frame => AssertFrame.MarkupWhitespace(frame, 3), - frame => AssertFrame.Text(frame, "123", 4), - frame => AssertFrame.MarkupWhitespace(frame, 5), - frame => AssertFrame.Text(frame, new object().ToString(), 6)); - } - - [Fact] - public void SupportsCSharpFunctionsBlock() - { - // Arrange/Act - var component = CompileToComponent(@" - @foreach(var item in items) { - @item - } - @code { - string[] items = new[] { ""First"", ""Second"", ""Third"" }; - } - "); - - // Assert - var frames = GetRenderTree(component); - Assert.Collection(frames, - frame => AssertFrame.Text(frame, "First", 0), - frame => AssertFrame.Text(frame, "Second", 0), - frame => AssertFrame.Text(frame, "Third", 0)); - } - - [Fact] - public void SupportsElementsWithDynamicContent() - { - // Arrange/Act - var component = CompileToComponent("Hello @(\"there\")"); - - // Assert - Assert.Collection(GetRenderTree(component), - frame => AssertFrame.Element(frame, "myelem", 3, 0), - frame => AssertFrame.Text(frame, "Hello ", 1), - frame => AssertFrame.Text(frame, "there", 2)); - } - - [Fact] - public void SupportsElementsAsStaticBlock() - { - // Arrange/Act - var component = CompileToComponent("Hello"); - - // Assert - Assert.Collection(GetRenderTree(component), - frame => AssertFrame.Markup(frame, "Hello", 0)); - } - - [Fact] - public void CreatesSeparateMarkupFrameForEachTopLevelStaticElement() - { - // The JavaScript-side rendering code does not rely on this behavior. It supports - // inserting markup frames with arbitrary markup (e.g., multiple top-level elements - // or none). This test exists only as an observation of the current behavior rather - // than a promise that we never want to change it. - - // Arrange/Act - var component = CompileToComponent( - "@(\"Hi\") a b "); - - // Assert - var frames = GetRenderTree(component); - Assert.Collection( - frames, - frame => AssertFrame.Element(frame, "root", 5, 0), - frame => AssertFrame.Text(frame, "Hi", 1), - frame => AssertFrame.Text(frame, " ", 2), - frame => AssertFrame.Markup(frame, "a ", 3), - frame => AssertFrame.Markup(frame, "b ", 4)); - } - - [Fact] - public void RendersMarkupStringAsMarkupFrame() - { - // Arrange/Act - var component = CompileToComponent( - "@{ var someMarkup = new MarkupString(\"
Hello
\"); }" - + "

@someMarkup

"); - - // Assert - Assert.Collection(GetRenderTree(component), - frame => AssertFrame.Element(frame, "p", 2, 0), - frame => AssertFrame.Markup(frame, "
Hello
", 1)); - } - - [Fact] - public void SupportsSelfClosingElementsWithDynamicContent() - { - // Arrange/Act - var component = CompileToComponent("Some text so elem isn't at position 0 "); - - // Assert - Assert.Collection(GetRenderTree(component), - frame => AssertFrame.Text(frame, "Some text so elem isn't at position 0 ", 0), - frame => AssertFrame.Element(frame, "myelem", 2, 1), - frame => AssertFrame.Attribute(frame, "myattr", "val", 2)); - } - - [Fact] - public void SupportsSelfClosingElementsAsStaticBlock() - { - // Arrange/Act - var component = CompileToComponent("Some text so elem isn't at position 0 "); - - // Assert - Assert.Collection( - GetRenderTree(component), - frame => AssertFrame.Markup(frame, "Some text so elem isn't at position 0 ", 0)); - } - - [Fact] - public void SupportsVoidHtmlElements() - { - // Arrange/Act - var component = CompileToComponent("Some text so elem isn't at position 0 "); - - // Assert - Assert.Collection( - GetRenderTree(component), - frame => AssertFrame.Markup(frame, "Some text so elem isn't at position 0 ", 0)); - } - - [Fact] - public void SupportsComments() - { - // Arrange/Act - var component = CompileToComponent("StartEnd"); - var frames = GetRenderTree(component); - - // Assert - Assert.Collection( - frames, - frame => AssertFrame.Markup(frame, "StartEnd", 0)); - } - - [Fact] - public void SupportsAttributesWithLiteralValues() - { - // Arrange/Act - var component = CompileToComponent("@(\"Hello\")"); - - // Assert - Assert.Collection(GetRenderTree(component), - frame => AssertFrame.Element(frame, "elem", 4, 0), - frame => AssertFrame.Attribute(frame, "attrib-one", "Value 1", 1), - frame => AssertFrame.Attribute(frame, "a2", "v2", 2), - frame => AssertFrame.Text(frame, "Hello", 3)); - } - - [Fact] - public void SupportsAttributesWithStringExpressionValues() - { - // Arrange/Act - var component = CompileToComponent( - "@{ var myValue = \"My string\"; }" - + ""); - - // Assert - Assert.Collection(GetRenderTree(component), - frame => AssertFrame.Element(frame, "elem", 2, 0), - frame => AssertFrame.Attribute(frame, "attr", "My string", 1)); - } - - [Fact] - public void SupportsAttributesWithNonStringExpressionValues() - { - // Arrange/Act - var component = CompileToComponent( - "@{ var myValue = 123; }" - + ""); - - // Assert - Assert.Collection(GetRenderTree(component), - frame => AssertFrame.Element(frame, "elem", 2, 0), - frame => AssertFrame.Attribute(frame, "attr", "123", 1)); - } - - [Fact] - public void SupportsAttributesWithInterpolatedStringExpressionValues() - { - // Arrange/Act - var component = CompileToComponent( - "@{ var myValue = \"world\"; var myNum=123; }" - + ""); - - // Assert - Assert.Collection(GetRenderTree(component), - frame => AssertFrame.Element(frame, "elem", 2, 0), - frame => AssertFrame.Attribute(frame, "attr", "Hello, WORLD with number 246!", 1)); - } - - [Fact] - public void SupportsAttributesWithInterpolatedTernaryExpressionValues() - { - // Arrange/Act - var component = CompileToComponent( - "@{ var myValue = \"world\"; }" - + ""); - - // Assert - Assert.Collection(GetRenderTree(component), - frame => AssertFrame.Element(frame, "elem", 2, 0), - frame => AssertFrame.Attribute(frame, "attr", "Hello, world!", 1)); - } - - [Fact] - public void SupportsHyphenedAttributesWithCSharpExpressionValues() - { - // Arrange/Act - var component = CompileToComponent( - "@{ var myValue = \"My string\"; }" - + ""); - - // Assert - Assert.Collection(GetRenderTree(component), - frame => AssertFrame.Element(frame, "elem", 2, 0), - frame => AssertFrame.Attribute(frame, "abc-def", "My string", 1)); - } - - [Fact] - public void SupportsDataDashAttributes() - { - // Arrange/Act - var component = CompileToComponent(@" -@{ - var myValue = ""Expression value""; -} -"); - - // Assert - Assert.Collection( - GetRenderTree(component), - frame => AssertFrame.Element(frame, "elem", 3, 0), - frame => AssertFrame.Attribute(frame, "data-abc", "Literal value", 1), - frame => AssertFrame.Attribute(frame, "data-def", "Expression value", 2)); - } - - [Fact] - public void SupportsUsingStatements() - { - // Arrange/Act - var component = CompileToComponent( - @"@using System.Collections.Generic - @(typeof(List).FullName)"); - var frames = GetRenderTree(component); - - // Assert - Assert.Collection(frames, - frame => AssertFrame.Text(frame, typeof(List).FullName, 0)); - } - - [Fact] - public async Task SupportsTwoWayBindingForTextboxes() - { - // Arrange/Act - var component = CompileToComponent(@" -@using Microsoft.AspNetCore.Components.Web - -@code { - public string MyValue { get; set; } = ""Initial value""; -}"); - var myValueProperty = component.GetType().GetProperty("MyValue"); - - var renderer = new TestRenderer(); - - // Assert - EventCallback setter = default; - var frames = GetRenderTree(renderer, component); - Assert.Collection(frames, - frame => AssertFrame.Element(frame, "input", 3, 0), - frame => AssertFrame.Attribute(frame, "value", "Initial value", 1), - frame => - { - AssertFrame.Attribute(frame, "onchange", 2); - setter = Assert.IsType(frame.AttributeValue); - }); - - // Trigger the change event to show it updates the property - // - // This should always complete synchronously. - var task = renderer.Dispatcher.InvokeAsync(() => setter.InvokeAsync(new ChangeEventArgs { Value = "Modified value", })); - Assert.Equal(TaskStatus.RanToCompletion, task.Status); - await task; - - Assert.Equal("Modified value", myValueProperty.GetValue(component)); - } - - [Fact] - public async Task SupportsTwoWayBindingForTextareas() - { - // Arrange/Act - var component = CompileToComponent(@" -@using Microsoft.AspNetCore.Components.Web - -@code { - public string MyValue { get; set; } = ""Initial value""; -}"); - var myValueProperty = component.GetType().GetProperty("MyValue"); - - var renderer = new TestRenderer(); - - // Assert - EventCallback setter = default; - var frames = GetRenderTree(renderer, component); - Assert.Collection(frames, - frame => AssertFrame.Element(frame, "textarea", 3, 0), - frame => AssertFrame.Attribute(frame, "value", "Initial value", 1), - frame => - { - AssertFrame.Attribute(frame, "onchange", 2); - setter = Assert.IsType(frame.AttributeValue); - }); - - // Trigger the change event to show it updates the property - // - // This should always complete synchronously. - var task = renderer.Dispatcher.InvokeAsync(() => setter.InvokeAsync(new ChangeEventArgs { Value = "Modified value", })); - Assert.Equal(TaskStatus.RanToCompletion, task.Status); - await task; - - Assert.Equal("Modified value", myValueProperty.GetValue(component)); - } - - [Fact] - public async Task SupportsTwoWayBindingForDateValues() - { - // Arrange/Act - var component = CompileToComponent(@" -@using Microsoft.AspNetCore.Components.Web - -@code { - public DateTime MyDate { get; set; } = new DateTime(2018, 3, 4, 1, 2, 3); -}"); - var myDateProperty = component.GetType().GetProperty("MyDate"); - - var renderer = new TestRenderer(); - - // Assert - EventCallback setter = default; - var frames = GetRenderTree(renderer, component); - Assert.Collection(frames, - frame => AssertFrame.Element(frame, "input", 3, 0), - frame => AssertFrame.Attribute(frame, "value", new DateTime(2018, 3, 4, 1, 2, 3).ToString(), 1), - frame => - { - AssertFrame.Attribute(frame, "onchange", 2); - setter = Assert.IsType(frame.AttributeValue); - }); - - // Trigger the change event to show it updates the property - // Trigger the change event to show it updates the property - // - // This should always complete synchronously. - var newDateValue = new DateTime(2018, 3, 5, 4, 5, 6); - var task = renderer.Dispatcher.InvokeAsync(() => setter.InvokeAsync(new ChangeEventArgs { Value = newDateValue.ToString(), })); - Assert.Equal(TaskStatus.RanToCompletion, task.Status); - await task; - - Assert.Equal(newDateValue, myDateProperty.GetValue(component)); - } - - [Fact] - public async Task SupportsTwoWayBindingForDateValuesWithFormatString() - { - // Arrange/Act - var testDateFormat = "ddd yyyy-MM-dd"; - var component = CompileToComponent($@" -@using Microsoft.AspNetCore.Components.Web - -@code {{ - public DateTime MyDate {{ get; set; }} = new DateTime(2018, 3, 4); -}}"); - var myDateProperty = component.GetType().GetProperty("MyDate"); - - var renderer = new TestRenderer(); - - // Assert - EventCallback setter = default; - var frames = GetRenderTree(renderer, component); - Assert.Collection(frames, - frame => AssertFrame.Element(frame, "input", 3, 0), - frame => AssertFrame.Attribute(frame, "value", new DateTime(2018, 3, 4).ToString(testDateFormat), 1), - frame => - { - AssertFrame.Attribute(frame, "onchange", 2); - setter = Assert.IsType(frame.AttributeValue); - }); - - // Trigger the change event to show it updates the property - // - // This should always complete synchronously. - var task = renderer.Dispatcher.InvokeAsync(() => setter.InvokeAsync(new ChangeEventArgs { Value = new DateTime(2018, 3, 5).ToString(testDateFormat), })); - Assert.Equal(TaskStatus.RanToCompletion, task.Status); - await task; - - Assert.Equal(new DateTime(2018, 3, 5), myDateProperty.GetValue(component)); - } - - [Fact] // In this case, onclick is just a normal HTML attribute - public void SupportsEventHandlerWithString() - { - // Arrange - var component = CompileToComponent(@" -", 0)); - } - - [Fact] - public void SupportsEventHandlerWithLambda() - { - // Arrange - var component = CompileToComponent(@" -@using Microsoft.AspNetCore.Components.Web - diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/Shared/RedirectToLogin.razor b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/Shared/RedirectToLogin.razor similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/Shared/RedirectToLogin.razor rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/Shared/RedirectToLogin.razor diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/Shared/SurveyPrompt.razor b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/Shared/SurveyPrompt.razor similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/Shared/SurveyPrompt.razor rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/Shared/SurveyPrompt.razor diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/_Imports.razor b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/_Imports.razor similarity index 63% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/_Imports.razor rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/_Imports.razor index fa501010b9..0029925574 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/_Imports.razor +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/_Imports.razor @@ -7,9 +7,9 @@ @using Microsoft.AspNetCore.Components.Web @using Microsoft.JSInterop @*#if (!Hosted) -@using BlazorWasm_CSharp -@using BlazorWasm_CSharp.Shared +@using ComponentsWebAssembly_CSharp +@using ComponentsWebAssembly_CSharp.Shared #else -@using BlazorWasm_CSharp.Client -@using BlazorWasm_CSharp.Client.Shared +@using ComponentsWebAssembly_CSharp.Client +@using ComponentsWebAssembly_CSharp.Client.Shared #endif*@ diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/bootstrap/bootstrap.min.css b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/bootstrap/bootstrap.min.css similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/bootstrap/bootstrap.min.css rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/bootstrap/bootstrap.min.css diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/bootstrap/bootstrap.min.css.map b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/bootstrap/bootstrap.min.css.map similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/bootstrap/bootstrap.min.css.map rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/bootstrap/bootstrap.min.css.map diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/FONT-LICENSE b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/FONT-LICENSE similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/FONT-LICENSE rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/FONT-LICENSE diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/ICON-LICENSE b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/ICON-LICENSE similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/ICON-LICENSE rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/ICON-LICENSE diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/README.md b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/README.md similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/README.md rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/README.md diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.svg b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.svg similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.svg rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.svg diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/site.css b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/site.css similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/css/site.css rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/css/site.css diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/favicon.ico b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/favicon.ico similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/favicon.ico rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/favicon.ico diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/icon-512.png b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/icon-512.png similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/icon-512.png rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/icon-512.png diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/index.html b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/index.html similarity index 95% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/index.html rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/index.html index 4847e62f33..53cb20753c 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/index.html +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/index.html @@ -4,7 +4,7 @@ - BlazorWasm-CSharp + ComponentsWebAssembly-CSharp diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/manifest.json b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/manifest.json similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/manifest.json rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/manifest.json diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/sample-data/weather.json b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/sample-data/weather.json similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/sample-data/weather.json rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/sample-data/weather.json diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/service-worker.js b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/service-worker.js similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/service-worker.js rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/service-worker.js diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/service-worker.published.js b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/service-worker.published.js similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Client/wwwroot/service-worker.published.js rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/service-worker.published.js diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/BlazorWasm-CSharp.sln b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/ComponentsWebAssembly-CSharp.sln similarity index 86% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/BlazorWasm-CSharp.sln rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/ComponentsWebAssembly-CSharp.sln index 93e9458089..e8cedfa73a 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/BlazorWasm-CSharp.sln +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/ComponentsWebAssembly-CSharp.sln @@ -2,11 +2,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.0.0 MinimumVisualStudioVersion = 16.0.0.0 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWasm-CSharp.Server", "Server\BlazorWasm-CSharp.Server.csproj", "{650B3CE7-2E93-4CC4-9F46-466686815EAA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComponentsWebAssembly-CSharp.Server", "Server\ComponentsWebAssembly-CSharp.Server.csproj", "{650B3CE7-2E93-4CC4-9F46-466686815EAA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWasm-CSharp.Client", "Client\BlazorWasm-CSharp.Client.csproj", "{5990939C-7E7B-4CFA-86FF-44CA5756498A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComponentsWebAssembly-CSharp.Client", "Client\ComponentsWebAssembly-CSharp.Client.csproj", "{5990939C-7E7B-4CFA-86FF-44CA5756498A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWasm-CSharp.Shared", "Shared\BlazorWasm-CSharp.Shared.csproj", "{0AFFA7FD-4E37-4636-AB91-3753E746DB98}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComponentsWebAssembly-CSharp.Shared", "Shared\ComponentsWebAssembly-CSharp.Shared.csproj", "{0AFFA7FD-4E37-4636-AB91-3753E746DB98}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -61,4 +61,4 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4C26868E-5E7C-458D-82E3-040509D0C71F} EndGlobalSection -EndGlobal +EndGlobal \ No newline at end of file diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Areas/Identity/Pages/Shared/_LoginPartial.cshtml b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Areas/Identity/Pages/Shared/_LoginPartial.cshtml similarity index 95% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Areas/Identity/Pages/Shared/_LoginPartial.cshtml rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Areas/Identity/Pages/Shared/_LoginPartial.cshtml index 26bfdde3cc..913f4c479b 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Areas/Identity/Pages/Shared/_LoginPartial.cshtml +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Areas/Identity/Pages/Shared/_LoginPartial.cshtml @@ -1,5 +1,5 @@ @using Microsoft.AspNetCore.Identity -@using BlazorWasm_CSharp.Server.Models +@using ComponentsWebAssembly_CSharp.Server.Models @inject SignInManager SignInManager @inject UserManager UserManager @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Controllers/OidcConfigurationController.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/OidcConfigurationController.cs similarity index 94% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Controllers/OidcConfigurationController.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/OidcConfigurationController.cs index a13f1c07b6..273fda395c 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Controllers/OidcConfigurationController.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/OidcConfigurationController.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; -namespace BlazorWasm_CSharp.Server.Controllers +namespace ComponentsWebAssembly_CSharp.Server.Controllers { public class OidcConfigurationController : Controller { diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Controllers/WeatherForecastController.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/WeatherForecastController.cs similarity index 92% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Controllers/WeatherForecastController.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/WeatherForecastController.cs index c6f2eb0ece..117055576d 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Controllers/WeatherForecastController.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/WeatherForecastController.cs @@ -1,4 +1,4 @@ -using BlazorWasm_CSharp.Shared; +using ComponentsWebAssembly_CSharp.Shared; using System; using System.Collections.Generic; using System.Linq; @@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; -namespace BlazorWasm_CSharp.Server.Controllers +namespace ComponentsWebAssembly_CSharp.Server.Controllers { #if (!NoAuth) [Authorize] diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/ApplicationDbContext.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/ApplicationDbContext.cs similarity index 84% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/ApplicationDbContext.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/ApplicationDbContext.cs index 4758c9b43b..ed95c4aba5 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/ApplicationDbContext.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/ApplicationDbContext.cs @@ -1,4 +1,4 @@ -using BlazorWasm_CSharp.Server.Models; +using ComponentsWebAssembly_CSharp.Server.Models; using IdentityServer4.EntityFramework.Options; using Microsoft.AspNetCore.ApiAuthorization.IdentityServer; using Microsoft.EntityFrameworkCore; @@ -8,7 +8,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace BlazorWasm_CSharp.Server.Data +namespace ComponentsWebAssembly_CSharp.Server.Data { public class ApplicationDbContext : ApiAuthorizationDbContext { diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlLite/00000000000000_CreateIdentitySchema.Designer.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlLite/00000000000000_CreateIdentitySchema.Designer.cs similarity index 95% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlLite/00000000000000_CreateIdentitySchema.Designer.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlLite/00000000000000_CreateIdentitySchema.Designer.cs index 7c6ab895cd..414379d1c2 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlLite/00000000000000_CreateIdentitySchema.Designer.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlLite/00000000000000_CreateIdentitySchema.Designer.cs @@ -1,12 +1,12 @@ // using System; -using BlazorWasm_CSharp.Server.Data; +using ComponentsWebAssembly_CSharp.Server.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -namespace BlazorWasm_CSharp.Server.Data.Migrations +namespace ComponentsWebAssembly_CSharp.Server.Data.Migrations { [DbContext(typeof(ApplicationDbContext))] [Migration("00000000000000_CreateIdentitySchema")] @@ -18,7 +18,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder .HasAnnotation("ProductVersion", "3.0.0-rc1.19455.8"); - modelBuilder.Entity("BlazorWasm_CSharp.Server.Models.ApplicationUser", b => + modelBuilder.Entity("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", b => { b.Property("Id") .HasColumnType("TEXT"); @@ -307,7 +307,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -316,7 +316,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -331,7 +331,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -340,7 +340,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlLite/00000000000000_CreateIdentitySchema.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlLite/00000000000000_CreateIdentitySchema.cs similarity index 99% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlLite/00000000000000_CreateIdentitySchema.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlLite/00000000000000_CreateIdentitySchema.cs index 9bf71dd82f..a1b61ddc1e 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlLite/00000000000000_CreateIdentitySchema.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlLite/00000000000000_CreateIdentitySchema.cs @@ -1,7 +1,7 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -namespace BlazorWasm_CSharp.Server.Data.Migrations +namespace ComponentsWebAssembly_CSharp.Server.Data.Migrations { public partial class CreateIdentitySchema : Migration { diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlLite/ApplicationDbContextModelSnapshot.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlLite/ApplicationDbContextModelSnapshot.cs similarity index 95% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlLite/ApplicationDbContextModelSnapshot.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlLite/ApplicationDbContextModelSnapshot.cs index 46707aab33..8352792068 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlLite/ApplicationDbContextModelSnapshot.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlLite/ApplicationDbContextModelSnapshot.cs @@ -1,11 +1,11 @@ // using System; -using BlazorWasm_CSharp.Server.Data; +using ComponentsWebAssembly_CSharp.Server.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -namespace BlazorWasm_CSharp.Server.Data.Migrations +namespace ComponentsWebAssembly_CSharp.Server.Data.Migrations { [DbContext(typeof(ApplicationDbContext))] partial class ApplicationDbContextModelSnapshot : ModelSnapshot @@ -16,7 +16,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder .HasAnnotation("ProductVersion", "3.0.0-rc1.19455.8"); - modelBuilder.Entity("BlazorWasm_CSharp.Server.Models.ApplicationUser", b => + modelBuilder.Entity("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", b => { b.Property("Id") .HasColumnType("TEXT"); @@ -305,7 +305,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -314,7 +314,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -329,7 +329,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -338,7 +338,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlServer/00000000000000_CreateIdentitySchema.Designer.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlServer/00000000000000_CreateIdentitySchema.Designer.cs similarity index 95% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlServer/00000000000000_CreateIdentitySchema.Designer.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlServer/00000000000000_CreateIdentitySchema.Designer.cs index 44cd41c4a4..9b11b6b060 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlServer/00000000000000_CreateIdentitySchema.Designer.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlServer/00000000000000_CreateIdentitySchema.Designer.cs @@ -1,13 +1,13 @@ // using System; -using BlazorWasm_CSharp.Server.Data; +using ComponentsWebAssembly_CSharp.Server.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -namespace BlazorWasm_CSharp.Server.Data.Migrations +namespace ComponentsWebAssembly_CSharp.Server.Data.Migrations { [DbContext(typeof(ApplicationDbContext))] [Migration("00000000000000_CreateIdentitySchema")] @@ -21,7 +21,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("BlazorWasm_CSharp.Server.Models.ApplicationUser", b => + modelBuilder.Entity("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", b => { b.Property("Id") .HasColumnType("nvarchar(450)"); @@ -314,7 +314,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -323,7 +323,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -338,7 +338,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -347,7 +347,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlServer/00000000000000_CreateIdentitySchema.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlServer/00000000000000_CreateIdentitySchema.cs similarity index 99% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlServer/00000000000000_CreateIdentitySchema.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlServer/00000000000000_CreateIdentitySchema.cs index fbcd6c8a16..00ba714717 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlServer/00000000000000_CreateIdentitySchema.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlServer/00000000000000_CreateIdentitySchema.cs @@ -1,7 +1,7 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -namespace BlazorWasm_CSharp.Server.Data.Migrations +namespace ComponentsWebAssembly_CSharp.Server.Data.Migrations { public partial class CreateIdentitySchema : Migration { diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlServer/ApplicationDbContextModelSnapshot.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlServer/ApplicationDbContextModelSnapshot.cs similarity index 95% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlServer/ApplicationDbContextModelSnapshot.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlServer/ApplicationDbContextModelSnapshot.cs index 448ccd3969..8df4c8457d 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Data/SqlServer/ApplicationDbContextModelSnapshot.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/SqlServer/ApplicationDbContextModelSnapshot.cs @@ -1,12 +1,12 @@ // using System; -using BlazorWasm_CSharp.Server.Data; +using ComponentsWebAssembly_CSharp.Server.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -namespace BlazorWasm_CSharp.Server.Data.Migrations +namespace ComponentsWebAssembly_CSharp.Server.Data.Migrations { [DbContext(typeof(ApplicationDbContext))] partial class ApplicationDbContextModelSnapshot : ModelSnapshot @@ -19,7 +19,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("BlazorWasm_CSharp.Server.Models.ApplicationUser", b => + modelBuilder.Entity("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", b => { b.Property("Id") .HasColumnType("nvarchar(450)"); @@ -312,7 +312,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -321,7 +321,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -336,7 +336,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -345,7 +345,7 @@ namespace BlazorWasm_CSharp.Server.Data.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.HasOne("BlazorWasm_CSharp.Server.Models.ApplicationUser", null) + b.HasOne("ComponentsWebAssembly_CSharp.Server.Models.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Models/ApplicationUser.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Models/ApplicationUser.cs similarity index 79% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Models/ApplicationUser.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Models/ApplicationUser.cs index 5aa9cb4030..216c5b3169 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Models/ApplicationUser.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Models/ApplicationUser.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace BlazorWasm_CSharp.Server.Models +namespace ComponentsWebAssembly_CSharp.Server.Models { public class ApplicationUser : IdentityUser { diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Program.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.cs similarity index 93% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Program.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.cs index 172bcf57d8..2b74d054a6 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Program.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -namespace BlazorWasm_CSharp.Server +namespace ComponentsWebAssembly_CSharp.Server { public class Program { diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Properties/launchSettings.json b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Properties/launchSettings.json similarity index 95% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Properties/launchSettings.json rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Properties/launchSettings.json index 83b55ad028..5840fdaa26 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Properties/launchSettings.json +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Properties/launchSettings.json @@ -20,7 +20,7 @@ "ASPNETCORE_ENVIRONMENT": "Development" } }, - "BlazorWasm-CSharp.Server": { + "ComponentsWebAssembly-CSharp.Server": { "commandName": "Project", "launchBrowser": true, //#if(RequiresHttps) diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Startup.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Startup.cs similarity index 96% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Startup.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Startup.cs index 97ea2d7383..591d098974 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Startup.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Startup.cs @@ -20,11 +20,11 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using System.Linq; #if (IndividualLocalAuth) -using BlazorWasm_CSharp.Server.Data; -using BlazorWasm_CSharp.Server.Models; +using ComponentsWebAssembly_CSharp.Server.Data; +using ComponentsWebAssembly_CSharp.Server.Models; #endif -namespace BlazorWasm_CSharp.Server +namespace ComponentsWebAssembly_CSharp.Server { public class Startup { diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/app.db b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/app.db similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/app.db rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/app.db diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/appsettings.Development.json b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/appsettings.Development.json similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/appsettings.Development.json rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/appsettings.Development.json diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/appsettings.json b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/appsettings.json similarity index 84% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/appsettings.json rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/appsettings.json index 1dfac21e6d..839c805918 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/appsettings.json +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/appsettings.json @@ -2,7 +2,7 @@ ////#if (IndividualLocalAuth) // "ConnectionStrings": { ////#if (UseLocalDB) -// "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-BlazorWasm_CSharp.Server-53bc9b9d-9d6a-45d4-8429-2a2761773502;Trusted_Connection=True;MultipleActiveResultSets=true" +// "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-ComponentsWebAssembly_CSharp.Server-53bc9b9d-9d6a-45d4-8429-2a2761773502;Trusted_Connection=True;MultipleActiveResultSets=true" ////#else // "DefaultConnection": "DataSource=app.db" ////#endif @@ -31,7 +31,7 @@ ////#if (IndividualLocalAuth) // "IdentityServer": { // "Clients": { -// "BlazorWasm_CSharp.Client": { +// "ComponentsWebAssembly_CSharp.Client": { // "Profile": "IdentityServerSPA" // } // } diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Shared/WeatherForecast.cs b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Shared/WeatherForecast.cs similarity index 87% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Shared/WeatherForecast.cs rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Shared/WeatherForecast.cs index f845d1c4b1..32e3d002de 100644 --- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Shared/WeatherForecast.cs +++ b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Shared/WeatherForecast.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace BlazorWasm_CSharp.Shared +namespace ComponentsWebAssembly_CSharp.Shared { public class WeatherForecast { diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/Directory.Build.props b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/Directory.Build.props similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/Directory.Build.props rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/Directory.Build.props diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/Directory.Build.targets b/src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/Directory.Build.targets similarity index 100% rename from src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/Directory.Build.targets rename to src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/Directory.Build.targets diff --git a/src/ProjectTemplates/test/ByteOrderMarkTest.cs b/src/ProjectTemplates/test/ByteOrderMarkTest.cs index 6618c8a8f1..7c023caf64 100644 --- a/src/ProjectTemplates/test/ByteOrderMarkTest.cs +++ b/src/ProjectTemplates/test/ByteOrderMarkTest.cs @@ -20,7 +20,7 @@ namespace Templates.Test } [Theory] - [InlineData("BlazorWasm.ProjectTemplates")] + [InlineData("ComponentsWebAssembly.ProjectTemplates")] public void JSAndJSONInAllTemplates_ShouldNotContainBOM(string projectName) { var currentDirectory = Directory.GetCurrentDirectory(); diff --git a/src/ProjectTemplates/test/Helpers/TemplatePackageInstaller.cs b/src/ProjectTemplates/test/Helpers/TemplatePackageInstaller.cs index 120f4ba05d..fd3bd8dc87 100644 --- a/src/ProjectTemplates/test/Helpers/TemplatePackageInstaller.cs +++ b/src/ProjectTemplates/test/Helpers/TemplatePackageInstaller.cs @@ -37,7 +37,7 @@ namespace Templates.Test.Helpers "Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0", "Microsoft.DotNet.Web.Spa.ProjectTemplates.3.1", "Microsoft.DotNet.Web.Spa.ProjectTemplates", - "Microsoft.AspNetCore.Blazor.Templates", + "Microsoft.AspNetCore.Components.WebAssembly.Templates", }; public static string CustomHivePath { get; } = typeof(TemplatePackageInstaller) diff --git a/src/ProjectTemplates/test/ProjectTemplates.Tests.csproj b/src/ProjectTemplates/test/ProjectTemplates.Tests.csproj index d80fc0c3a6..2d8c486e33 100644 --- a/src/ProjectTemplates/test/ProjectTemplates.Tests.csproj +++ b/src/ProjectTemplates/test/ProjectTemplates.Tests.csproj @@ -40,7 +40,7 @@ - + diff --git a/src/Shared/E2ETesting/WaitAssert.cs b/src/Shared/E2ETesting/WaitAssert.cs index 86126c9a73..f87c569320 100644 --- a/src/Shared/E2ETesting/WaitAssert.cs +++ b/src/Shared/E2ETesting/WaitAssert.cs @@ -47,6 +47,9 @@ namespace Microsoft.AspNetCore.E2ETesting public static IWebElement Exists(this IWebDriver driver, By finder) => Exists(driver, finder, default); + public static TElement Exists(this IWebDriver driver, Func actual, TimeSpan timeout) + => WaitAssertCore(driver, actual, timeout); + public static void DoesNotExist(this IWebDriver driver, By finder, TimeSpan timeout = default) => WaitAssertCore(driver, () => {