diff --git a/samples/StandaloneApp/Home.cshtml b/samples/StandaloneApp/Home.cshtml new file mode 100644 index 0000000000..921a01483e --- /dev/null +++ b/samples/StandaloneApp/Home.cshtml @@ -0,0 +1 @@ +Hello, world! diff --git a/samples/StandaloneApp/Index.cshtml b/samples/StandaloneApp/Index.cshtml deleted file mode 100644 index 92491f81c2..0000000000 --- a/samples/StandaloneApp/Index.cshtml +++ /dev/null @@ -1,2 +0,0 @@ -

Hello, world!

-Hello from the Razor component. diff --git a/samples/StandaloneApp/Program.cs b/samples/StandaloneApp/Program.cs index 4d441d31f5..e092cb8238 100644 --- a/samples/StandaloneApp/Program.cs +++ b/samples/StandaloneApp/Program.cs @@ -2,8 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Blazor.Browser.Rendering; -using Microsoft.Blazor.Components; -using Microsoft.Blazor.RenderTree; namespace StandaloneApp { @@ -12,15 +10,7 @@ namespace StandaloneApp public static void Main(string[] args) { new BrowserRenderer() - .AddComponent("app", new PlaceholderComponent()); - } - - private class PlaceholderComponent : IComponent - { - public void BuildRenderTree(RenderTreeBuilder builder) - { - builder.AddText("Hello from the placeholder component."); - } + .AddComponent("app", new Home()); } } } diff --git a/src/Microsoft.Blazor.Build/Core/RazorCompilation/RazorCompiler.cs b/src/Microsoft.Blazor.Build/Core/RazorCompilation/RazorCompiler.cs index 346b4a77ab..35a51632be 100644 --- a/src/Microsoft.Blazor.Build/Core/RazorCompilation/RazorCompiler.cs +++ b/src/Microsoft.Blazor.Build/Core/RazorCompilation/RazorCompiler.cs @@ -90,6 +90,11 @@ namespace Microsoft.Blazor.Build.Core.RazorCompilation ? baseNamespace : $"{baseNamespace}.{itemNamespace}"; + // TODO: Pass through info about whether this is a design-time build, and if so, + // just emit enough of a stub class that intellisense will show the correct type + // name and any public members. Don't need to actually emit all the RenderTreeBuilder + // invocations. + var engine = new BlazorRazorEngine(); var sourceDoc = RazorSourceDocument.ReadFrom(inputFileContents, inputFilePath); diff --git a/test/Microsoft.Blazor.E2ETest/Tests/StandaloneAppTest.cs b/test/Microsoft.Blazor.E2ETest/Tests/StandaloneAppTest.cs index 28e36d964d..ded75789c9 100644 --- a/test/Microsoft.Blazor.E2ETest/Tests/StandaloneAppTest.cs +++ b/test/Microsoft.Blazor.E2ETest/Tests/StandaloneAppTest.cs @@ -3,6 +3,9 @@ using Microsoft.Blazor.E2ETest.Infrastructure; using Microsoft.Blazor.E2ETest.Infrastructure.ServerFixtures; +using OpenQA.Selenium; +using OpenQA.Selenium.Support.UI; +using System; using Xunit; namespace Microsoft.Blazor.E2ETest.Tests @@ -13,13 +16,27 @@ namespace Microsoft.Blazor.E2ETest.Tests public StandaloneAppTest(BrowserFixture browserFixture, DevHostServerFixture serverFixture) : base(browserFixture, serverFixture) { + Navigate("/", noReload: true); + WaitUntilLoaded(); } [Fact] public void HasTitle() { - Navigate("/"); Assert.Equal("Blazor standalone", Browser.Title); } + + [Fact] + public void HasBodyText() + { + var bodyText = Browser.FindElement(By.TagName("body")).Text; + Assert.Equal("Hello, world!", bodyText); + } + + private void WaitUntilLoaded() + { + new WebDriverWait(Browser, TimeSpan.FromSeconds(30)).Until( + driver => driver.FindElement(By.TagName("app")).Text != "Loading..."); + } } }