Skip to content

Commit

Permalink
.NET 8 Upgrade (#25)
Browse files Browse the repository at this point in the history
* net 8 demo upgrade
* .net8 upgrade
* Switch to new server blazor model for demo
  • Loading branch information
lolochristen authored Dec 10, 2023
1 parent 9a6c567 commit 3d3ef8d
Show file tree
Hide file tree
Showing 33 changed files with 133 additions and 140 deletions.
2 changes: 2 additions & 0 deletions OpenLayers.Blazor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ Global
{558FC061-5215-43DC-A7C1-CE3DA8D3112A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{558FC061-5215-43DC-A7C1-CE3DA8D3112A}.Release|Any CPU.Build.0 = Release|Any CPU
{56CA5376-8AD9-481C-81B1-D82D0716989A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56CA5376-8AD9-481C-81B1-D82D0716989A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56CA5376-8AD9-481C-81B1-D82D0716989A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56CA5376-8AD9-481C-81B1-D82D0716989A}.Release|Any CPU.Build.0 = Release|Any CPU
{0FEB3FC9-8E58-4AE7-B09B-7FA248687EC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0FEB3FC9-8E58-4AE7-B09B-7FA248687EC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D235BF12-E194-49CA-AB16-27E23D87B9C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/OpenLayers.Blazor.Demo.Components/Pages/BingMapDemo.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@page "/bingmapdemo"
@rendermode Components.RenderMode.DefaultRenderMode

<div class="card mt-2 mb-2">

<div class="card-header">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/customdemo"
@rendermode Components.RenderMode.DefaultRenderMode

<div class="card mt-2 mb-2">
<div class="card-header">
Expand Down
1 change: 1 addition & 0 deletions src/OpenLayers.Blazor.Demo.Components/Pages/DrawDemo.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/drawdemo"
@rendermode Components.RenderMode.DefaultRenderMode

<div class="card mt-2 mb-2">
<div class="card-header">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/geojsondemo"
@rendermode Components.RenderMode.DefaultRenderMode
@using System.Text.Json
@using Shape = OpenLayers.Blazor.Shape

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/gdzdemo"
@rendermode Components.RenderMode.DefaultRenderMode

<div class="card mt-2 mb-2">
<div class="card-header">
Expand Down
1 change: 1 addition & 0 deletions src/OpenLayers.Blazor.Demo.Components/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/"
@rendermode Components.RenderMode.DefaultRenderMode
@using System.Text.Json

<div class="card mt-2 mb-2">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/layersdemo"
@rendermode Components.RenderMode.DefaultRenderMode

<div class="card mt-2 mb-2">
<div class="card-header">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/markersdemo"
@rendermode Components.RenderMode.DefaultRenderMode

<div class="card mt-2 mb-2">
<div class="card-header">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/openstreetmapdemo"
@rendermode Components.RenderMode.DefaultRenderMode

<div class="card mt-2 mb-2">
<div class="card-header">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/shapesdemo"
@rendermode Components.RenderMode.DefaultRenderMode
@using System.Text.Json

<div class="card mt-2 mb-2">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/swissmaplayersdemo"
@rendermode Components.RenderMode.DefaultRenderMode
@using System.Xml.Linq
@using System.Threading
@using System.Text.Json
Expand Down
7 changes: 7 additions & 0 deletions src/OpenLayers.Blazor.Demo.Components/RenderMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Microsoft.AspNetCore.Components;
namespace OpenLayers.Blazor.Demo.Components;

public static class RenderMode
{
public static IComponentRenderMode DefaultRenderMode = new Microsoft.AspNetCore.Components.Web.InteractiveWebAssemblyRenderMode();
}
2 changes: 1 addition & 1 deletion src/OpenLayers.Blazor.Demo.Components/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using OpenLayers.Blazor
@using OpenLayers.Blazor.Demo.Components
@using OpenLayers.Blazor.Demo.Components
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
Expand Down Expand Up @@ -50,8 +50,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 0 additions & 12 deletions src/OpenLayers.Blazor.Demo.Server/App.razor

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
@page "/"
@using Microsoft.AspNetCore.Components.Web
@namespace OpenLayers.Blazor.Demo.Server.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" />
<base href="/" />
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css" />
<script src="lib/bootstrap/js/bootstrap.min.js"></script>
<link href="css/app.css" rel="stylesheet" />
Expand All @@ -19,28 +15,18 @@
<link rel="icon" type="image/png" href="favicon.png" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/dark.min.css" rel="stylesheet" />
<link rel="stylesheet" href="lib/font-awesome/css/all.min.css" />
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
<HeadOutlet />
</head>
<body>
<component type="typeof(App)" render-mode="ServerPrerendered" />

<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<body>
<Routes />
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
<script src="_framework/blazor.server.js"></script>

<script src="_framework/blazor.web.js"></script>
<script>
window.highlightSnippet = function () {
hljs.highlightAll();
}
</script>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ main {
}

.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
background-image: linear-gradient(180deg, rgba(58,99,180,1) 0%, rgba(69,150,252,1) 100%);
}

.top-row {
Expand Down
36 changes: 36 additions & 0 deletions src/OpenLayers.Blazor.Demo.Server/Components/Pages/Error.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@page "/Error"
@using System.Diagnostics

<PageTitle>Error</PageTitle>

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

@code{
[CascadingParameter]
private HttpContext? HttpContext { get; set; }

private string? RequestId { get; set; }
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

protected override void OnInitialized() =>
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
}
6 changes: 6 additions & 0 deletions src/OpenLayers.Blazor.Demo.Server/Components/Routes.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
</Router>
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using OpenLayers.Blazor.Demo.Server
@using OpenLayers.Blazor.Demo.Server.Shared
@using OpenLayers.Blazor
@using OpenLayers.Blazor.Demo.Components
@using OpenLayers.Blazor.Demo.Server
@using OpenLayers.Blazor.Demo.Server.Components
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OpenLayers.Blazor.Demo.Components\OpenLayers.Blazor.Demo.Components.csproj" />
<ProjectReference Include="..\OpenLayers.Blazor\OpenLayers.Blazor.csproj" />
</ItemGroup>

</Project>
42 changes: 0 additions & 42 deletions src/OpenLayers.Blazor.Demo.Server/Pages/Error.cshtml

This file was deleted.

27 changes: 0 additions & 27 deletions src/OpenLayers.Blazor.Demo.Server/Pages/Error.cshtml.cs

This file was deleted.

21 changes: 11 additions & 10 deletions src/OpenLayers.Blazor.Demo.Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using OpenLayers.Blazor.Demo.Server.Components;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();

builder.Services.AddHttpClient();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();

app.UseStaticFiles();

app.UseRouting();
app.UseAntiforgery();

// workaround to make support different rendermodes
OpenLayers.Blazor.Demo.Components.RenderMode.DefaultRenderMode = new Microsoft.AspNetCore.Components.Web.InteractiveServerRenderMode();

app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.MapRazorComponents<App>()
.AddAdditionalAssemblies(typeof(OpenLayers.Blazor.Demo.Components.Pages.Index).Assembly)
.AddInteractiveServerRenderMode();

app.Run();
Loading

0 comments on commit 3d3ef8d

Please sign in to comment.