Skip to content

Commit b135ce9

Browse files
committed
Upgrade to .NET 10.0 and improve project structure
Updated the target framework to .NET 10.0 across all projects. Refactored PostgreSQL handling in `AppHost.cs` for clarity. Introduced Azure Key Vault integration in `Program.cs`. Enhanced modal interactions and `ActionRowProperties` for better readability and maintainability. Reorganized `Directory.Packages.props` with categorized sections and updated package versions. Added `NuGet.config` for streamlined dependency management. Updated Dockerfile to use .NET 10.0 Alpine images. Removed unused code and improved formatting throughout.
1 parent 41ffabf commit b135ce9

26 files changed

Lines changed: 214 additions & 179 deletions

Directory.Packages.props

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,47 @@
11
<Project>
2-
<PropertyGroup>
3-
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4-
</PropertyGroup>
5-
<ItemGroup>
6-
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.4.2" />
7-
<PackageVersion Include="Aspire.Hosting.PostgreSQL" Version="9.4.2" />
8-
<PackageVersion Include="Aspire.Hosting.Redis" Version="9.4.2" />
9-
<PackageVersion Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.4.2" />
10-
<PackageVersion Include="Aspire.StackExchange.Redis.DistributedCaching" Version="9.4.2" />
11-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.9" />
12-
<PackageVersion Include="Microsoft.Extensions.Caching.Hybrid" Version="9.9.0" />
13-
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.9.0" />
14-
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="9.4.2" />
15-
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.63.0" />
16-
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.OpenAI" Version="1.63.0" />
17-
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" />
18-
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
19-
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
20-
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />
21-
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
22-
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" />
23-
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.11" />
24-
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="2.1.7" />
25-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.9" />
26-
<PackageVersion Include="Microsoft.Extensions.Http" Version="9.0.9" />
27-
<PackageVersion Include="Microsoft.AspNetCore.WebUtilities" Version="9.0.9" />
28-
<PackageVersion Include="NetCord.Hosting.Services" Version="1.0.0-alpha.410" />
29-
<PackageVersion Include="SkiaSharp" Version="3.119.0" />
30-
<PackageVersion Include="SkiaSharp.HarfBuzz" Version="3.119.0" />
31-
<PackageVersion Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.119.0" />
32-
</ItemGroup>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<!-- AppHost -->
8+
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.4.2" />
9+
<PackageVersion Include="Aspire.Hosting.PostgreSQL" Version="9.4.2" />
10+
<PackageVersion Include="Aspire.Hosting.Redis" Version="9.4.2" />
11+
12+
<!-- MainApp -->
13+
<PackageVersion Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.4.2" />
14+
<PackageVersion Include="Aspire.StackExchange.Redis.DistributedCaching" Version="9.4.2" />
15+
<PackageVersion Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.4.0" />
16+
<PackageVersion Include="Azure.Identity" Version="1.16.0" />
17+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.0-rc.1.25451.107" />
18+
<PackageVersion Include="Microsoft.Extensions.Caching.Hybrid" Version="9.9.0" />
19+
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.65.0" />
20+
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.OpenAI" Version="1.65.0" />
21+
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0-preview.4" />
22+
<PackageVersion Include="NetCord.Hosting.Services" Version="1.0.0-alpha.424" />
23+
24+
<!-- Shared -->
25+
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.9.0" />
26+
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="9.4.2" />
27+
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
28+
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
29+
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />
30+
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
31+
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" />
32+
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.11" />
33+
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="2.1.7" />
34+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0-rc.1.25451.107" />
35+
<PackageVersion Include="Microsoft.Extensions.Http" Version="10.0.0-rc.1.25451.107" />
36+
<PackageVersion Include="Microsoft.AspNetCore.WebUtilities" Version="2.3.0" />
37+
<PackageVersion Include="SkiaSharp" Version="3.119.0" />
38+
<PackageVersion Include="SkiaSharp.HarfBuzz" Version="3.119.0" />
39+
<PackageVersion Include="SkiaSharp.NativeAssets.Win32" Version="3.119.0" />
40+
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="3.119.0" />
41+
<PackageVersion Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.119.0" />
42+
43+
<!-- Transitive -->
44+
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0-rc.1" />
45+
<PackageVersion Include="KubernetesClient" Version="17.0.14" />
46+
</ItemGroup>
3347
</Project>

GitcgNetCord.slnx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Folder Name="/Solution Items/">
33
<File Path="Directory.Packages.props" />
44
<File Path="global.json" />
5+
<File Path="NuGet.config" />
56
<File Path="README.md" />
67
<File Path="LICENSE" />
78
<File Path=".gitignore" />
@@ -12,8 +13,8 @@
1213
<Project Path="src/GitcgPainter/GitcgPainter.csproj" />
1314
<Project Path="src/HoyolabHttpClient/HoyolabHttpClient.csproj" />
1415
<Project Path="src/SharedUtils/SharedUtils.csproj" />
15-
<Project Path="src\GitcgSharp.Shared\GitcgSharp.Shared.csproj" Type="Classic C#" />
16-
<Project Path="src\GitcgSkia\GitcgSkia.csproj" Type="Classic C#" />
16+
<Project Path="src\GitcgSharp.Shared\GitcgSharp.Shared.csproj" />
17+
<Project Path="src\GitcgSkia\GitcgSkia.csproj" />
1718
</Folder>
1819
<Project Path="src/AppHost/AppHost.csproj" />
1920
<Project Path="src/ServiceDefaults/ServiceDefaults.csproj" />

NuGet.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
6+
</packageSources>
7+
</configuration>

src/AppHost/AppHost.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@
1313
var useRemotePostgres = builder.Configuration
1414
.GetValue<bool>("AppBuilderOptions:UseRemotePostgres");
1515

16+
var postgresResourceName = "gitcgnetcorddb";
1617
if (useRemotePostgres)
1718
{
18-
var gitcgnetcorddbConnectionString = builder
19-
.AddConnectionString("gitcgnetcorddb");
19+
var isPostgresConnectionStringEmpty = string.IsNullOrWhiteSpace(
20+
builder.Configuration.GetConnectionString(postgresResourceName)
21+
);
22+
if (!isPostgresConnectionStringEmpty)
23+
{
24+
var gitcgnetcorddbConnectionString = builder
25+
.AddConnectionString(postgresResourceName);
2026

21-
main.WithReference(gitcgnetcorddbConnectionString);
27+
main.WithReference(gitcgnetcorddbConnectionString);
28+
}
2229
}
2330
else
2431
{
@@ -31,14 +38,14 @@
3138
name: "postgresql",
3239
password: postgresPassword
3340
);
34-
41+
3542
postgres
3643
.WithDataVolume()
3744
.WithPgAdmin();
3845

3946
var gitcgnetcorddb = postgres
4047
.AddDatabase("gitcgnetcord");
41-
48+
4249
main.WithReference(gitcgnetcorddb).WaitFor(gitcgnetcorddb);
4350
}
4451

src/AppHost/AppHost.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<PropertyGroup>
66
<OutputType>Exe</OutputType>
7-
<TargetFramework>net9.0</TargetFramework>
7+
<TargetFramework>net10.0</TargetFramework>
88
<ImplicitUsings>enable</ImplicitUsings>
99
<Nullable>enable</Nullable>
1010
<UserSecretsId>b793981b-6a48-4580-8729-76247f52f583</UserSecretsId>

src/GitcgNetCord.MainApp/Commands/Interactions/AddHoyolabAccountComponentInteraction.cs

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,39 @@ ButtonInteractionContext context
1717
)
1818
{
1919
await context.Interaction.SendResponseAsync(
20-
InteractionCallback.Modal(new ModalProperties(
21-
customId: PostCustomId,
22-
title: "Hoyolab account"
20+
InteractionCallback.Modal(
21+
new ModalProperties(
22+
customId: PostCustomId,
23+
title: "Hoyolab account"
24+
)
25+
{
26+
new LabelProperties(
27+
label: "Hoyolab user ID (ltuid_v2)",
28+
component: new TextInputProperties(
29+
customId: "hoyolab-user-id",
30+
style: TextInputStyle.Short
31+
)
32+
{
33+
MaxLength = 10,
34+
Placeholder = "ltuid_v2"
35+
}
36+
),
37+
new LabelProperties(
38+
label: "Hoyolab token (ltoken_v2)",
39+
component: new TextInputProperties(
40+
customId: "token",
41+
style: TextInputStyle.Paragraph)
42+
{
43+
MaxLength = 255,
44+
Placeholder = "v2_..."
45+
}
46+
)
47+
}
2348
)
24-
{
25-
new TextInputProperties(
26-
customId: "hoyolab-user-id",
27-
style: TextInputStyle.Short,
28-
label: "Hoyolab user ID (ltuid_v2)")
29-
.WithMaxLength(10)
30-
.WithPlaceholder("ltuid_v2"),
31-
new TextInputProperties(
32-
customId: "token",
33-
style: TextInputStyle.Paragraph,
34-
label: "Token (ltoken_v2)")
35-
.WithMaxLength(255)
36-
.WithPlaceholder("v2_...")
37-
})
3849
);
3950
}
4051

4152
public static async Task PostAsync(
42-
HoyolabHttpClientService hoyolab,
43-
HybridCache cache,
4453
IServiceProvider serviceProvider,
4554
ModalInteractionContext context
4655
)

src/GitcgNetCord.MainApp/Commands/Interactions/SelectDecksComponentInteraction.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ await context.Interaction.ModifyResponseAsync(message => message
7777
new TextDisplayProperties(
7878
$"`{s.SharingCode}`"
7979
),
80-
new ActionRowProperties().AddButtons(
80+
new ActionRowProperties
81+
{
8182
CopySharingCodeComponentInteraction
8283
.CreateCopySharingCodeButton(s.SharingCode)
83-
)
84+
}
8485
)
8586
)
8687
)

src/GitcgNetCord.MainApp/Commands/Interactions/UpdateActiveHoyolabAccountComponentInteraction.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ await context.Interaction.SendResponseAsync(
2020
title: "Update active hoyolab account"
2121
)
2222
{
23-
new TextInputProperties(
23+
new LabelProperties(
24+
label: "Genshin Impact UID",
25+
component: new TextInputProperties(
2426
customId: "uid",
25-
style: TextInputStyle.Short,
26-
label: "Genshin Impact UID")
27-
.WithMaxLength(10)
27+
style: TextInputStyle.Short)
28+
{
29+
MaxLength = 10
30+
}
31+
)
2832
})
2933
);
3034
}
@@ -54,7 +58,6 @@ await context.Interaction.SendResponseAsync(
5458
}
5559
}
5660

57-
5861
try
5962
{
6063
await activeHoyolabAccountService

src/GitcgNetCord.MainApp/Commands/Slash/DuelSlashCommand.cs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,25 @@ await context.Interaction.SendResponseAsync(
3030

3131
await context.Interaction.ModifyResponseAsync(message =>
3232
{
33-
message.Content = $"{context.User} has challenged {opponent} to a duel of type {type}.";
34-
message.AddComponents(new ActionRowProperties().AddButtons(
35-
new ButtonProperties(
36-
customId: "accept-duel",
37-
label: "Accept",
38-
style: ButtonStyle.Success
39-
),
40-
new ButtonProperties(
41-
customId: "decline-duel",
42-
label: "Decline",
43-
style: ButtonStyle.Danger
44-
)
45-
));
33+
message.Content =
34+
$"{context.User} has challenged " +
35+
$"{opponent} to a duel of type {type}.";
36+
37+
message.AddComponents(
38+
new ActionRowProperties()
39+
{
40+
new ButtonProperties(
41+
customId: "accept-duel",
42+
label: "Accept",
43+
style: ButtonStyle.Success
44+
),
45+
new ButtonProperties(
46+
customId: "decline-duel",
47+
label: "Decline",
48+
style: ButtonStyle.Danger
49+
)
50+
}
51+
);
4652
});
4753
}
4854
}

src/GitcgNetCord.MainApp/Commands/Slash/HoyolabAccountsSlashCommand.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ await context.Interaction.ModifyResponseAsync(message =>
7474
.AddMessageIfAccountsEmpty(gameRecordList)
7575
.WithColor(Color.Purple.ToNetCordColor())
7676
)
77-
.AddComponents(new ActionRowProperties()
78-
.AddButtons(
77+
.AddComponents(
78+
new ActionRowProperties()
79+
{
7980
new ButtonProperties(
8081
customId: AddHoyolabAccountComponentInteraction.CustomId,
8182
label: "Add account",
@@ -89,7 +90,8 @@ await context.Interaction.ModifyResponseAsync(message =>
8990
// customId: "remove-hoyolab-account",
9091
// label: "Remove account",
9192
// style: ButtonStyle.Danger)
92-
));
93+
}
94+
);
9395
});
9496
}
9597
}

0 commit comments

Comments
 (0)