Skip to content

Commit

Permalink
Update to .NET 6
Browse files Browse the repository at this point in the history
  • Loading branch information
danroth27 committed Nov 3, 2021
1 parent ab916cd commit b181427
Show file tree
Hide file tree
Showing 49 changed files with 607 additions and 416 deletions.
71 changes: 51 additions & 20 deletions BlazorWebAssemblyPrerendering.sln
Original file line number Diff line number Diff line change
@@ -1,34 +1,65 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
# Visual Studio Version 17
VisualStudioVersion = 17.1.31828.382
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWebAssemblyPrerendering.Client", "Client\BlazorWebAssemblyPrerendering.Client.csproj", "{39E56246-CA39-4ECE-9B9F-6B6A507FE4BE}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWebAssemblyPrerendering.Client", "Client\BlazorWebAssemblyPrerendering.Client.csproj", "{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWebAssemblyPrerendering.Shared", "Shared\BlazorWebAssemblyPrerendering.Shared.csproj", "{832A1DA6-5C16-4230-99D9-E305899754D5}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWebAssemblyPrerendering.Server", "Server\BlazorWebAssemblyPrerendering.Server.csproj", "{2102677E-045B-4032-8AAF-07DD4B0ABB4D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWebAssemblyPrerendering.Server", "Server\BlazorWebAssemblyPrerendering.Server.csproj", "{D643F5A2-5D13-4790-A55C-2AEA9D09975C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWebAssemblyPrerendering.Shared", "Shared\BlazorWebAssemblyPrerendering.Shared.csproj", "{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}"
EndProject
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F115665D-D5EF-4FDF-A6EF-15B3D14E6CCE}
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{39E56246-CA39-4ECE-9B9F-6B6A507FE4BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39E56246-CA39-4ECE-9B9F-6B6A507FE4BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39E56246-CA39-4ECE-9B9F-6B6A507FE4BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39E56246-CA39-4ECE-9B9F-6B6A507FE4BE}.Release|Any CPU.Build.0 = Release|Any CPU
{832A1DA6-5C16-4230-99D9-E305899754D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{832A1DA6-5C16-4230-99D9-E305899754D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{832A1DA6-5C16-4230-99D9-E305899754D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{832A1DA6-5C16-4230-99D9-E305899754D5}.Release|Any CPU.Build.0 = Release|Any CPU
{D643F5A2-5D13-4790-A55C-2AEA9D09975C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D643F5A2-5D13-4790-A55C-2AEA9D09975C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D643F5A2-5D13-4790-A55C-2AEA9D09975C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D643F5A2-5D13-4790-A55C-2AEA9D09975C}.Release|Any CPU.Build.0 = Release|Any CPU
{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}.Debug|x64.ActiveCfg = Debug|Any CPU
{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}.Debug|x64.Build.0 = Debug|Any CPU
{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}.Debug|x86.ActiveCfg = Debug|Any CPU
{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}.Debug|x86.Build.0 = Debug|Any CPU
{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}.Release|Any CPU.Build.0 = Release|Any CPU
{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}.Release|x64.ActiveCfg = Release|Any CPU
{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}.Release|x64.Build.0 = Release|Any CPU
{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}.Release|x86.ActiveCfg = Release|Any CPU
{9CEAB43D-FD2D-4104-8644-A7DC89C0C475}.Release|x86.Build.0 = Release|Any CPU
{2102677E-045B-4032-8AAF-07DD4B0ABB4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2102677E-045B-4032-8AAF-07DD4B0ABB4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2102677E-045B-4032-8AAF-07DD4B0ABB4D}.Debug|x64.ActiveCfg = Debug|Any CPU
{2102677E-045B-4032-8AAF-07DD4B0ABB4D}.Debug|x64.Build.0 = Debug|Any CPU
{2102677E-045B-4032-8AAF-07DD4B0ABB4D}.Debug|x86.ActiveCfg = Debug|Any CPU
{2102677E-045B-4032-8AAF-07DD4B0ABB4D}.Debug|x86.Build.0 = Debug|Any CPU
{2102677E-045B-4032-8AAF-07DD4B0ABB4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2102677E-045B-4032-8AAF-07DD4B0ABB4D}.Release|Any CPU.Build.0 = Release|Any CPU
{2102677E-045B-4032-8AAF-07DD4B0ABB4D}.Release|x64.ActiveCfg = Release|Any CPU
{2102677E-045B-4032-8AAF-07DD4B0ABB4D}.Release|x64.Build.0 = Release|Any CPU
{2102677E-045B-4032-8AAF-07DD4B0ABB4D}.Release|x86.ActiveCfg = Release|Any CPU
{2102677E-045B-4032-8AAF-07DD4B0ABB4D}.Release|x86.Build.0 = Release|Any CPU
{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}.Debug|x64.ActiveCfg = Debug|Any CPU
{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}.Debug|x64.Build.0 = Debug|Any CPU
{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}.Debug|x86.ActiveCfg = Debug|Any CPU
{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}.Debug|x86.Build.0 = Debug|Any CPU
{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}.Release|Any CPU.Build.0 = Release|Any CPU
{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}.Release|x64.ActiveCfg = Release|Any CPU
{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}.Release|x64.Build.0 = Release|Any CPU
{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}.Release|x86.ActiveCfg = Release|Any CPU
{8DDC8CA6-EA1D-4B69-8912-FE9126B93DF3}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
6 changes: 4 additions & 2 deletions Client/App.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<Router AppAssembly="@typeof(Program).Assembly">
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
17 changes: 6 additions & 11 deletions Client/BlazorWebAssemblyPrerendering.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview9.19465.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview9.19465.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.0.0-preview9.19465.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview9.19465.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Shared\BlazorWebAssemblyPrerendering.Shared.csproj" />
</ItemGroup>

<ProjectExtensions><VisualStudio><UserProperties properties_4launchsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>

</Project>
24 changes: 0 additions & 24 deletions Client/HttpWeatherForecastService.cs

This file was deleted.

10 changes: 6 additions & 4 deletions Client/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
@page "/counter"

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p>Current count: @currentCount</p>
<p role="status">Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="@IncrementCount">Click me</button>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
int currentCount = 0;
private int currentCount = 0;

void IncrementCount()
private void IncrementCount()
{
currentCount++;
}
Expand Down
33 changes: 30 additions & 3 deletions Client/Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
@page "/fetchdata"
@inject IWeatherForecastService WeatherService
@using BlazorWebAssemblyPrerendering.Shared
@implements IDisposable
@inject IWeatherForecastService ForecastService
@inject PersistentComponentState ApplicationState

<PageTitle>Weather forecast</PageTitle>

<h1>Weather forecast</h1>

Expand Down Expand Up @@ -35,10 +40,32 @@ else
}

@code {
IEnumerable<WeatherForecast> forecasts;
private WeatherForecast[] forecasts = Array.Empty<WeatherForecast>();
private PersistingComponentStateSubscription _persistingSubscription;

protected override async Task OnInitializedAsync()
{
forecasts = await WeatherService.GetForecastAsync(DateTime.Now);
_persistingSubscription = ApplicationState.RegisterOnPersisting(PersistForecasts);

if (!ApplicationState.TryTakeFromJson<WeatherForecast[]>("fetchdata", out var restored))
{
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
}
else
{
forecasts = restored!;
}
}

private Task PersistForecasts()
{
ApplicationState.PersistAsJson("fetchdata", forecasts);

return Task.CompletedTask;
}

void IDisposable.Dispose()
{
_persistingSubscription.Dispose();
}
}
2 changes: 2 additions & 0 deletions Client/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@page "/"

<PageTitle>Index</PageTitle>

<h1>Hello, world!</h1>

Welcome to your new app.
Expand Down
25 changes: 11 additions & 14 deletions Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
using Microsoft.AspNetCore.Blazor.Hosting;
using BlazorWebAssemblyPrerendering.Client;
using BlazorWebAssemblyPrerendering.Shared;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;

namespace BlazorWebAssemblyWithPrerendering.Client
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

public static IWebAssemblyHostBuilder CreateHostBuilder(string[] args) =>
BlazorWebAssemblyHost.CreateDefaultBuilder()
.UseBlazorStartup<Startup>();
}
}
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddScoped<IWeatherForecastService, WeatherForecastService>();

await builder.Build().RunAsync();
22 changes: 12 additions & 10 deletions Client/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
@inherits LayoutComponentBase

<div class="sidebar">
<NavMenu />
</div>

<div class="main">
<div class="top-row px-4">
<a href="http://blazor.net" target="_blank" class="ml-md-auto">About</a>
<div class="page">
<div class="sidebar">
<NavMenu />
</div>

<div class="content px-4">
@Body
</div>
<main>
<div class="top-row px-4">
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
</div>

<article class="content px-4">
@Body
</article>
</main>
</div>
81 changes: 81 additions & 0 deletions Client/Shared/MainLayout.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}

main {
flex: 1;
}

.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}

.top-row ::deep a, .top-row ::deep .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
text-decoration: none;
}

.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
text-decoration: underline;
}

.top-row ::deep a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}

@media (max-width: 640.98px) {
.top-row:not(.auth) {
display: none;
}

.top-row.auth {
justify-content: space-between;
}

.top-row ::deep a, .top-row ::deep .btn-link {
margin-left: 0;
}
}

@media (min-width: 641px) {
.page {
flex-direction: row;
}

.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}

.top-row {
position: sticky;
top: 0;
z-index: 1;
}

.top-row.auth ::deep a:first-child {
flex: 1;
text-align: right;
width: 0;
}

.top-row, article {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}
Loading

0 comments on commit b181427

Please sign in to comment.