Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to .net9 #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions .github/workflows/dotnet-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,35 @@ name: Build and run Test

on:
pull_request:
branches: [ "main" ]
paths:
- '**.cs'
- '**.razor'
- '**.csproj'
branches: ["main"]
paths:
- "**.cs"
- "**.razor"
- "**.csproj"
workflow_dispatch:

env:
NET_VERSION: '8.x'
NET_VERSION: "9.x"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET Core SDK ${{ env.NET_VERSION }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.NET_VERSION }}

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET Core SDK ${{ env.NET_VERSION }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.NET_VERSION }}

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
36 changes: 18 additions & 18 deletions .github/workflows/publish-http.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@ name: Publish Http project to NuGet

on:
push:
branches: [ 'main' ]
paths:
- 'src/KITT.Web.ReCaptcha.Http/**'
branches: ["main"]
paths:
- "src/KITT.Web.ReCaptcha.Http/**"
workflow_dispatch:

env:
NET_VERSION: '8.x'
PROJECT_PATH: 'src/KITT.Web.ReCaptcha.Http'
PROJECT_FILE: 'KITT.Web.ReCaptcha.Http.csproj'
NET_VERSION: "9.x"
PROJECT_PATH: "src/KITT.Web.ReCaptcha.Http"
PROJECT_FILE: "KITT.Web.ReCaptcha.Http.csproj"

jobs:
publish:
name: Publish package to NuGet
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET Core SDK ${{ env.NET_VERSION }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.NET_VERSION }}
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create nupkg file
run: dotnet pack -c Release -o . '${{ env.PROJECT_PATH }}/${{ env.PROJECT_FILE }}'
- name: Setup .NET Core SDK ${{ env.NET_VERSION }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.NET_VERSION }}

- name: Publish on NuGet
run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_APIKEY }} -s https://api.nuget.org/v3/index.json
- name: Create nupkg file
run: dotnet pack -c Release -o . '${{ env.PROJECT_PATH }}/${{ env.PROJECT_FILE }}'

- name: Publish on NuGet
run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_APIKEY }} -s https://api.nuget.org/v3/index.json
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ This repository contains a set of packages which allows you to add Google reCapt
## KITT.Web.ReCaptcha.Blazor

This project add Google reCaptcha to your Blazor apps.<br/>
This project targets **.NET 8** as supported Framework version.
This project targets **.NET 9** as supported Framework version.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to remove support for .NET 8 since it's the current LTS. Maybe better support both .NET 8 and .NET 9. What do you think?


### Installation

This project is available on NuGet.

It can be installed using the ```dotnet add package``` command or the NuGet wizard on your favourite IDE.
It can be installed using the `dotnet add package` command or the NuGet wizard on your favourite IDE.

```bash
dotnet add package KITT.Web.ReCaptcha.Blazor
Expand All @@ -22,13 +22,13 @@ More informations are available on the project [README](https://github.com/albx/
## KITT.Web.ReCaptcha.Http

This project add Google reCaptcha to your ASP.NET Core apps giving the service to validate your reCaptcha client response.<br/>
This project targets **.NET 6** and **.NET 8** as supported Framework versions.
This project targets **.NET 6** and **.NET 9** as supported Framework versions.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case maybe it's better keep .NET 8 and removing .NET 6, since it's not supported anymore. This will be a breaking change IMHO. What do you think?


### Installation

This project is available on NuGet.

It can be installed using the ```dotnet add package``` command or the NuGet wizard on your favourite IDE.
It can be installed using the `dotnet add package` command or the NuGet wizard on your favourite IDE.

```bash
dotnet add package KITT.Web.ReCaptcha.Http
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

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

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\KITT.Web.ReCaptcha.Http\KITT.Web.ReCaptcha.Http.csproj" />
<ProjectReference Include="..\KITT.Web.ReCaptcha.Samples.v2.Blazor.Client\KITT.Web.ReCaptcha.Samples.v2.Blazor.Client.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>35c49c18-040c-4752-b489-40218717aa41</UserSecretsId>
Expand All @@ -10,7 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\KITT.Web.ReCaptcha.Http\KITT.Web.ReCaptcha.Http.csproj" />
<ProjectReference Include="..\KITT.Web.ReCaptcha.Samples.v3.Blazor.Client\KITT.Web.ReCaptcha.Samples.v3.Blazor.Client.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As told before. In this case I'd keep .NET 8 and add support to .NET 9

<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Authors>Alberto Mori</Authors>
Expand All @@ -22,8 +22,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
46 changes: 29 additions & 17 deletions src/KITT.Web.ReCaptcha.Blazor/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# KITT.Web.ReCaptcha.Blazor

This project add Google reCaptcha to your Blazor apps.<br/>
This project targets **.NET 8** as supported Framework version.
This project targets **.NET 9** as supported Framework version.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As told before in the general readme. I'd support both .NET 8 and .NET 9


## Installation

This project is available on [NuGet](https://www.nuget.org/packages/KITT.Web.ReCaptcha.Blazor).

It can be installed using the ```dotnet add package``` command or the NuGet wizard on your favourite IDE.
It can be installed using the `dotnet add package` command or the NuGet wizard on your favourite IDE.

```bash
dotnet add package KITT.Web.ReCaptcha.Blazor
```

## reCaptcha v2

### Usage

The project gives you a Razor component which add the reCaptcha v2 widget.

Add the namespace ```KITT.Web.ReCaptcha.Blazor.v2``` to your Razor Components or in the ```_Imports.razor``` file.
Add the namespace `KITT.Web.ReCaptcha.Blazor.v2` to your Razor Components or in the `_Imports.razor` file.

After that you can use the ```<ReCaptcha />``` component in your ```EditForm``` like in this sample:
After that you can use the `<ReCaptcha />` component in your `EditForm` like in this sample:

```csharp
<ReCaptcha SiteKey="<your reCaptcha v2 client key>"
Expand All @@ -36,50 +37,61 @@ After that you can use the ```<ReCaptcha />``` component in your ```EditForm```

### Parameters

The component needs to be used inside an ```EditForm```. It exposes the following properties:
The component needs to be used inside an `EditForm`. It exposes the following properties:

|Property|Description|
|---|---|
|**SiteKey** (Required)|*string*: the value of the v2 client site key|
|**@bind-Value**|*string*: the property to bind|
|**Theme**|*Theme* enum: the theme to use (default: *Theme.Light*)|
|**Size**|*Size* enum: the size of the widget (default: *Size.Normal*)|
|**TabIndex**|*int*: the tabIndex value (default: *0*)|
|**Id**|*string*: the id of the HTML element used to render the reCaptcha widget (*default*: "recaptcha")|
| Property | Description |
| ---------------------- | ------------------------------------------------------------------------------------------------- |
| **SiteKey** (Required) | _string_: the value of the v2 client site key |
| **@bind-Value** | _string_: the property to bind |
| **Theme** | _Theme_ enum: the theme to use (default: _Theme.Light_) |
| **Size** | _Size_ enum: the size of the widget (default: _Size.Normal_) |
| **TabIndex** | _int_: the tabIndex value (default: _0_) |
| **Id** | _string_: the id of the HTML element used to render the reCaptcha widget (_default_: "recaptcha") |

## reCaptcha v3

### Usage

You can register reCaptcha using the ```AddReCaptchaV3``` extension method:
You can register reCaptcha using the `AddReCaptchaV3` extension method:

```csharp
using KITT.Web.ReCaptcha.Blazor.v3;
//...
builder.Services.AddReCaptchaV3(options => options.SiteKey = "<YOUR CLIENT SITE KEY VALUE>");
```
After that you have to add the *ReCaptchaScript* component.

After that you have to add the _ReCaptchaScript_ component.

#### Blazor Web App
With the new Blazor Web App you can add the *ReCaptchaScript* component to your App.razor:

With the new Blazor Web App you can add the _ReCaptchaScript_ component to your App.razor:

```razor
....
<ReCaptchaScript />
<script src="_framework/blazor.web.js"></script>
```

#### Blazor WebAssembly

If you're using Blazor WebAssembly, simply register it to the RootComponents calling the extension method:

```csharp
builder.RootComponents.RegisterReCaptchaScript();
```

#### Blazor Server
If you're using Blazor Server, edit the *_Host.cshtml* page in this way:

If you're using Blazor Server, edit the _\_Host.cshtml_ page in this way:

```razor
....
<script src="_framework/blazor.server.js"></script>
<component type="typeof(ReCaptchaScript)" render-mode="ServerPrerendered" />
```

After that you can inject the ReCaptchaService to your component and call the VerifyAsync method:

```razor
@inject ReCaptchaService ReCaptcha
...
Expand Down
4 changes: 2 additions & 2 deletions src/KITT.Web.ReCaptcha.Http/KITT.Web.ReCaptcha.Http.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net9.0</TargetFrameworks>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As told before. I'd remove .NET 6 since it's not supported anymore and keep .NET 8, adding the support to .NET 9. This will be a breaking change

<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
Expand All @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading