Skip to content

Commit 651c2f0

Browse files
committed
reverse to .net 9
1 parent 5a473bb commit 651c2f0

15 files changed

Lines changed: 158 additions & 819 deletions

File tree

.github/workflows/cd.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- name: Install WASM experimental workload
19-
run: dotnet workload install wasm-experimental
18+
2019
- uses: actions/checkout@v4.2.2
2120
with:
2221
fetch-depth: 0
2322
- name: Setup .NET
2423
uses: actions/setup-dotnet@v4
2524
with:
2625
dotnet-version: 9.0.x
26+
# allow-prerelease: true
27+
- name: Install WASM experimental workload
28+
run: dotnet workload install wasm-experimental wasm-tools
2729
- name: Install GitVersioning
2830
run: dotnet tool install --global nbgv
2931
- name: Set version
@@ -38,6 +40,4 @@ jobs:
3840
- name: Pack Abies Only
3941
run: dotnet pack ./Abies/Abies.csproj --configuration Release --output ./nupkg /p:PackageVersion=${{ steps.version.outputs.VERSION }}
4042
- name: Publish to NuGet
41-
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
42-
- name: Publish to GitHub Packages
43-
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.PUSH_GITHUB_PACKAGES }} --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
43+
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

Abies.Benchmarks/Abies.Benchmarks.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
45
<OutputType>Exe</OutputType>
56
</PropertyGroup>
67

Abies.Conduit/Abies.Conduit.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
44
<PublishTrimmed>false</PublishTrimmed>
5-
5+
<TargetFramework>net9.0</TargetFramework>
66
</PropertyGroup>
77
<ItemGroup>
88
<ProjectReference Include="..\Abies\Abies.csproj" />

Abies.Conduit/Main.cs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
using System;
2-
using System.Diagnostics;
31
using Abies.Conduit.Routing;
4-
using Abies;
5-
using static Abies.Option.Extensions;
6-
using static Abies.Html.Elements;
7-
using static Abies.Html.Attributes;
8-
using static Abies.Html.Events;
9-
using Abies.Html;
102
using static Abies.Conduit.Main.Message.Event;
113
using static Abies.UrlRequest;
12-
using static Abies.Url;
134
using static Abies.Navigation.Command;
14-
using System.Collections.Generic;
155

166
namespace Abies.Conduit.Main;
177

@@ -20,13 +10,13 @@ public record struct UserName(string Value);
2010

2111
public record struct Slug(string Value);
2212

23-
public record Model(Page Page, Route CurrentRoute);
13+
public record Model(Page Page, Routing.Route CurrentRoute);
2414

2515
public interface Message : Abies.Message
2616
{
2717
public interface Command : Message
2818
{
29-
public sealed record ChangeRoute(Route? Route) : Command;
19+
public sealed record ChangeRoute(Routing.Route? Route) : Command;
3020
}
3121

3222
public interface Event : Message
@@ -66,17 +56,17 @@ public class Application : Application<Model, Arguments>
6656
/// <returns>The next model.</returns>
6757
private static Model GetNextModel(Url url)
6858
{
69-
Route currentRoute = Route.FromUrl(Route.Match, url);
59+
Routing.Route currentRoute = Routing.Route.FromUrl(Routing.Route.Match, url);
7060
return currentRoute switch
7161
{
72-
Route.Home => new(new Page.Home(new Conduit.Page.Home.Model()), currentRoute),
73-
Route.Settings => new(new Page.Settings(new Conduit.Page.Settings.Model()), currentRoute),
74-
Route.Login => new(new Page.Login(new Conduit.Page.Login.Model()), currentRoute),
75-
Route.Register => new(new Page.Register(new Conduit.Page.Register.Model()), currentRoute),
76-
Route.Profile profile => new(new Page.Profile(new Conduit.Page.Profile.Model(profile.UserName)), currentRoute),
77-
Route.Article article => new(new Page.Article(new Conduit.Page.Article.Model(article.Slug)), currentRoute),
78-
Route.Redirect => new(new Page.Redirect(), currentRoute),
79-
Route.NewArticle => new(new Page.NewArticle(new Conduit.Page.Article.Model(new Slug(""))), currentRoute),
62+
Routing.Route.Home => new(new Page.Home(new Conduit.Page.Home.Model()), currentRoute),
63+
Routing.Route.Settings => new(new Page.Settings(new Conduit.Page.Settings.Model()), currentRoute),
64+
Routing.Route.Login => new(new Page.Login(new Conduit.Page.Login.Model()), currentRoute),
65+
Routing.Route.Register => new(new Page.Register(new Conduit.Page.Register.Model()), currentRoute),
66+
Routing.Route.Profile profile => new(new Page.Profile(new Conduit.Page.Profile.Model(profile.UserName)), currentRoute),
67+
Routing.Route.Article article => new(new Page.Article(new Conduit.Page.Article.Model(article.Slug)), currentRoute),
68+
Routing.Route.Redirect => new(new Page.Redirect(), currentRoute),
69+
Routing.Route.NewArticle => new(new Page.NewArticle(new Conduit.Page.Article.Model(new Slug(""))), currentRoute),
8070
_ => new(new Page.NotFound(), currentRoute),
8171
};
8272
}
@@ -101,8 +91,8 @@ private static (Model model, IEnumerable<Command>) HandleUrlChanged(Url url, Mod
10191
private static (Model model, IEnumerable<Command>) HandleLinkClicked(UrlRequest urlRequest, Model model)
10292
=> urlRequest switch
10393
{
104-
Internal @internal => (model with { CurrentRoute = Route.FromUrl(Route.Match, @internal.Url) }, new List<Command> { new PushState(@internal.Url) }),
105-
External externalUrl => (model, new List<Command> { new Load(Create(new Decoded.String(externalUrl.Url))) }),
94+
Internal @internal => (model with { CurrentRoute = Abies.Conduit.Routing.Route.FromUrl(Abies.Conduit.Routing.Route.Match, @internal.Url) }, new List<Command> { new PushState(@internal.Url) }),
95+
External externalUrl => (model, new List<Command> { new Load(Url.Create(externalUrl.Url)) }),
10696
_ => (model, new List<Command>())
10797
};
10898

Abies.Conduit/Route.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using Abies.Conduit.Main;
2-
using System;
3-
using static Abies.Parse;
4-
using static Abies.Url.Parse.Segment;
5-
using static Abies.Url.Parse;
2+
using static Abies.Route.Parse;
63

74
namespace Abies.Conduit.Routing;
85

@@ -42,11 +39,11 @@ public static Route FromUrl(Parser<Route> parser, Url url)
4239
/// </summary>
4340
public static Parser<Route> Match =>
4441
// match the path /profile/{username} where {username} is a string
45-
(Segment.String("profile") / Url.Parse.String).Map(Handlers.Profile)
42+
(Segment.String("profile") / Abies.Route.Parse.String).Map(Handlers.Profile)
4643
// match the path /article/{slug} where {slug} is a string
47-
| (Segment.String("article") / Url.Parse.String).Map(Handlers.Article)
44+
| (Segment.String("article") / Abies.Route.Parse.String).Map(Handlers.Article)
4845
// match the path /editor/{slug} where {slug} is a string
49-
| (Segment.String("editor") / Url.Parse.String).Map(Handlers.EditArticle)
46+
| (Segment.String("editor") / Abies.Route.Parse.String).Map(Handlers.EditArticle)
5047
// match the path /editor
5148
| Segment.String("editor").Map(Handlers.NewArticle)
5249
// match the path /home

Abies.Counter/Abies.Counter.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk.WebAssembly">
22
<PropertyGroup>
3+
<TargetFramework>net9.0</TargetFramework>
34
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
45
<PublishTrimmed>false</PublishTrimmed>
56

Abies.Tests/Abies.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
45
<IsPackable>false</IsPackable>
56
</PropertyGroup>
67

Abies.Tests/RouteParsingTests.cs

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
using Abies.Conduit.Routing;
1+
using Route = Abies.Conduit.Routing.Route;
22
using FsCheck;
33
using FsCheck.Xunit;
4-
using static Abies.Url;
54

65
namespace Abies.Tests;
76

@@ -30,38 +29,38 @@ public void RouteParser_ShouldCorrectlyParseKnownRoutes(string path)
3029
var url = Url.Create(new($"http://localhost:80{path}"));
3130

3231
// Act
33-
var route = Route.FromUrl(Route.Match, url);
32+
var route = Abies.Conduit.Routing.Route.FromUrl(Abies.Conduit.Routing.Route.Match, url);
3433

3534
// Assert
3635
switch (path)
3736
{
3837
case "/":
3938
case "/home":
40-
Assert.IsType<Route.Home>(route);
39+
Assert.IsType<Abies.Conduit.Routing.Route.Home>(route);
4140
break;
4241
case "/login":
43-
_ = Assert.IsType<Route.Login>(route);
42+
_ = Assert.IsType<Abies.Conduit.Routing.Route.Login>(route);
4443
break;
4544
case "/settings":
46-
Assert.IsType<Route.Settings>(route);
45+
Assert.IsType<Abies.Conduit.Routing.Route.Settings>(route);
4746
break;
4847
case "/register":
49-
Assert.IsType<Route.Register>(route);
48+
Assert.IsType<Abies.Conduit.Routing.Route.Register>(route);
5049
break;
5150
case "/editor":
52-
Assert.IsType<Route.NewArticle>(route);
51+
Assert.IsType<Abies.Conduit.Routing.Route.NewArticle>(route);
5352
break;
5453
case var p when p.StartsWith("/profile/"):
55-
Assert.IsType<Route.Profile>(route);
54+
Assert.IsType<Abies.Conduit.Routing.Route.Profile>(route);
5655
break;
5756
case var p when p.StartsWith("/article/"):
58-
Assert.IsType<Route.Article>(route);
57+
Assert.IsType<Abies.Conduit.Routing.Route.Article>(route);
5958
break;
6059
case var p when p.StartsWith("/editor/"):
61-
Assert.IsType<Route.EditArticle>(route);
60+
Assert.IsType<Abies.Conduit.Routing.Route.EditArticle>(route);
6261
break;
6362
default:
64-
Assert.IsType<Route.NotFound>(route);
63+
Assert.IsType<Abies.Conduit.Routing.Route.NotFound>(route);
6564
break;
6665
}
6766
}
@@ -74,7 +73,7 @@ public void RouteParser_ShouldReturnNotFound_ForUnknownRoutes(NonEmptyString ran
7473
var url = Url.Create(new($"http://localhost:80{path}"));
7574

7675
// Act
77-
var route = Route.FromUrl(Route.Match, url);
76+
var route = Abies.Conduit.Routing.Route.FromUrl(Abies.Conduit.Routing.Route.Match, url);
7877

7978
// Assert
8079
// Assuming known routes are limited to those defined earlier
@@ -94,25 +93,7 @@ public void RouteParser_ShouldReturnNotFound_ForUnknownRoutes(NonEmptyString ran
9493
var isKnownRoute = knownRoutes.Any(r => path == r || path.StartsWith(r));
9594
if (!isKnownRoute)
9695
{
97-
Assert.IsType<Route.NotFound>(route);
96+
Assert.IsType<Abies.Conduit.Routing.Route.NotFound>(route);
9897
}
9998
}
100-
101-
//[Property]
102-
//public Property RouteParser_ShouldHandleAnyValidPath()
103-
//{
104-
// // Generate any string that can represent a path
105-
// return Prop.ForAll(Arb.Generate<string>(), path =>
106-
// {
107-
// // Arrange
108-
// var url = Url.Create(new($"http://localhost:80{path}"));
109-
110-
// // Act
111-
// var route = Route.FromUrl(Route.Match, url);
112-
113-
// // Assert
114-
// // The parser should not throw exceptions
115-
// return true.ToProperty();
116-
// });
117-
//}
11899
}

0 commit comments

Comments
 (0)