Skip to content

Modernize: Update to .NET 10 and fix minor issues#35

Open
gunnbr wants to merge 26 commits into
masterfrom
feature/modernize
Open

Modernize: Update to .NET 10 and fix minor issues#35
gunnbr wants to merge 26 commits into
masterfrom
feature/modernize

Conversation

@gunnbr

@gunnbr gunnbr commented May 18, 2026

Copy link
Copy Markdown
Owner

Update to .NET 10 and fix minor issues

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR attempts to modernize the bot solution for .NET 10, update dependency/runtime configuration, refactor startup toward Generic Host, and add SQL Server-backed test infrastructure.

Changes:

  • Retargets selected projects and Docker images to .NET 10 with package updates.
  • Reworks GthxNetBot startup/Serilog configuration.
  • Adds SQL Server Testcontainers setup, a unit-test Dockerfile, and upgrade-tracking documentation.

Reviewed changes

Copilot reviewed 28 out of 29 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
wait-for-sql.sh Adds SQL Server readiness polling script.
README.md Updates SDK instructions from .NET 6 to .NET 10.
GthxNetBot/Program.cs Replaces custom startup/DI with Generic Host and Serilog setup.
GthxNetBot/IrcBot.cs Removes an unused using.
GthxNetBot/GthxNetBot.csproj Retargets app project and updates package references.
GthxNetBot.sln Updates solution metadata and adds unit-test Dockerfile as solution item.
Gthx.Test/SqlServerTestContainerSetUp.cs Adds global NUnit SQL Server container setup.
Gthx.Test/SqlServerTestContainerFixture.cs Adds SQL Server Testcontainers fixture.
Gthx.Test/IntegrationTests.cs Uses host builder/test server and container connection override.
Gthx.Test/GthxTests.cs Reorders dependency injection using.
Gthx.Test/GthxSqlDataTest.cs Adds container connection override and explicit Queryable calls.
Gthx.Test/Gthx.Test.csproj Retargets test project and updates/adds test dependencies.
Gthx.Bot/Gthx.Bot.csproj Retargets bot library and updates Serilog logging package.
Dockerfile-UnitTests Adds Docker image for running tests with SQL Server.
Dockerfile Updates build/runtime base images to .NET 10.
.github/upgrades/scenarios/dotnet-version-upgrade/tasks/05-validation-and-testing/task.md Adds validation task notes.
.github/upgrades/scenarios/dotnet-version-upgrade/tasks/04-address-api-incompatibilities/task.md Adds API incompatibility task notes.
.github/upgrades/scenarios/dotnet-version-upgrade/tasks/03-refactor-console-app-di/task.md Adds DI refactor task notes.
.github/upgrades/scenarios/dotnet-version-upgrade/tasks/02-update-nuget-packages/task.md Adds package update task notes.
.github/upgrades/scenarios/dotnet-version-upgrade/tasks/01-update-target-frameworks/task.md Adds target framework task notes.
.github/upgrades/scenarios/dotnet-version-upgrade/tasks.md Adds upgrade task progress summary.
.github/upgrades/scenarios/dotnet-version-upgrade/scenario.json Adds upgrade scenario metadata.
.github/upgrades/scenarios/dotnet-version-upgrade/scenario-instructions.md Adds upgrade scenario instructions.
.github/upgrades/scenarios/dotnet-version-upgrade/plan.md Adds upgrade plan.
.github/upgrades/scenarios/dotnet-version-upgrade/execution-log.md Adds upgrade execution log.
.github/upgrades/scenarios/dotnet-version-upgrade/assessment.md Adds generated upgrade assessment.
.github/upgrades/scenarios/dotnet-version-upgrade/assessment.json Adds machine-readable upgrade assessment.
.github/upgrades/scenarios/dotnet-version-upgrade/assessment.csv Adds CSV upgrade assessment.
Comments suppressed due to low confidence (2)

Dockerfile-UnitTests:35

  • The test project now has a global Testcontainers fixture that starts its own SQL Server container, but this image also starts an embedded SQL Server and then runs dotnet test without providing Docker access. In a normal run of this Dockerfile, Testcontainers will not be able to create its container, and the local SQL Server started here will not be used by the tests.
CMD /opt/mssql/bin/sqlservr & \
    /wait-for-sql.sh && \
    dotnet test --no-build --logger:trx

.github/upgrades/scenarios/dotnet-version-upgrade/tasks.md:12

  • This task is marked complete, but several changed project files still pin pre-.NET-10-era Microsoft/Serilog packages (for example Microsoft.AspNetCore.TestHost 7.0.17 and Microsoft.Extensions.Configuration 7.0.0) and Gthx.Bot still carries System.Threading.Tasks.Dataflow 5.0.0. The status overstates the dependency upgrade and conflicts with the assessment recommendations in this same upgrade folder.
- ✅ 02-update-nuget-packages: Upgrade all NuGet packages and replace deprecated ones

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread GthxNetBot/Program.cs
new EmailSinkOptions
{
From = emailOptions.FromName,
To = new List<string> { emailOptions.ToEmail }
Comment thread GthxNetBot/Program.cs
Comment thread wait-for-sql.sh Outdated
Comment thread wait-for-sql.sh Outdated
Comment thread Gthx.Test/SqlServerTestContainerFixture.cs Outdated
Comment thread GthxNetBot.sln Outdated
Comment thread Gthx.Test/IntegrationTests.cs Outdated
Comment thread Gthx.Test/SqlServerTestContainerSetUp.cs
Comment thread .github/upgrades/scenarios/dotnet-version-upgrade/tasks.md
Comment thread GthxNetBot/Program.cs Outdated
gunnbr and others added 2 commits May 17, 2026 18:20
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI commented May 18, 2026

Copy link
Copy Markdown

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.thingiverse.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/GthxNetBot/GthxNetBot/bin/Debug/net10.0/Gthx.Test.runtimeconfig.json --depsfile /home/REDACTED/work/GthxNetBot/GthxNetBot/bin/Debug/net10.0/Gthx.Test.deps.json /home/REDACTED/work/GthxNetBot/GthxNetBot/bin/Debug/net10.0/testhost.dll --port 39279 --endpoint 127.0.0.1:039279 --role client --parentprocessid 5751 --telemetryoptedin false cc1cc4947824994d313fc386a5955d67e1f/7f44d8213e5015add366b3488fb587bb3065f3e28735ec8f70b703681a6a/run/containerd/containerd.sock (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/GthxNetBot/GthxNetBot/bin/Debug/net10.0/Gthx.Test.runtimeconfig.json --depsfile /home/REDACTED/work/GthxNetBot/GthxNetBot/bin/Debug/net10.0/Gthx.Test.deps.json /home/REDACTED/work/GthxNetBot/GthxNetBot/bin/Debug/net10.0/testhost.dll --port 33339 --endpoint 127.0.0.1:033339 --role client --parentprocessid 8901 --telemetryoptedin false (dns block)
  • www.youtube.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/GthxNetBot/GthxNetBot/bin/Debug/net10.0/Gthx.Test.runtimeconfig.json --depsfile /home/REDACTED/work/GthxNetBot/GthxNetBot/bin/Debug/net10.0/Gthx.Test.deps.json /home/REDACTED/work/GthxNetBot/GthxNetBot/bin/Debug/net10.0/testhost.dll --port 39279 --endpoint 127.0.0.1:039279 --role client --parentprocessid 5751 --telemetryoptedin false cc1cc4947824994d313fc386a5955d67e1f/7f44d8213e5015add366b3488fb587bb3065f3e28735ec8f70b703681a6a/run/containerd/containerd.sock (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/GthxNetBot/GthxNetBot/bin/Debug/net10.0/Gthx.Test.runtimeconfig.json --depsfile /home/REDACTED/work/GthxNetBot/GthxNetBot/bin/Debug/net10.0/Gthx.Test.deps.json /home/REDACTED/work/GthxNetBot/GthxNetBot/bin/Debug/net10.0/testhost.dll --port 33339 --endpoint 127.0.0.1:033339 --role client --parentprocessid 8901 --telemetryoptedin false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of gunnbr May 18, 2026 01:29
gunnbr and others added 12 commits May 24, 2026 16:18
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Even though it's the version that Visual Studio itself added

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Fix unit tests to compile properly again.
Add --console flag to run the console app.
Change launch settings to start debugging in console mode.
Update to latest Gthx.Data
Fix default connection string to work with podman.
@gunnbr gunnbr marked this pull request as ready for review May 26, 2026 00:15
@gunnbr gunnbr requested a review from Copilot May 26, 2026 00:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 32 out of 33 changed files in this pull request and generated 10 comments.

Comment thread GthxNetBot/Program.cs
Comment on lines +41 to +55
if (!string.IsNullOrWhiteSpace(emailOptions.EmailSubject) &&
!string.IsNullOrWhiteSpace(emailOptions.FromName) &&
!string.IsNullOrWhiteSpace(emailOptions.MailServer) &&
!string.IsNullOrWhiteSpace(emailOptions.Password) &&
!string.IsNullOrWhiteSpace(emailOptions.ToEmail) &&
!string.IsNullOrWhiteSpace(emailOptions.UserName) &&
emailOptions.Port != null)
{
FromEmail = emailOptions.FromName,
ToEmail = emailOptions.ToEmail,
EmailSubject = emailOptions.EmailSubject,
MailServer = emailOptions.MailServer,
Port = emailOptions.Port.Value,
EnableSsl = true,
NetworkCredentials = new NetworkCredential
{
UserName = emailOptions.UserName,
Password = emailOptions.Password
},
},
"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}",
batchPostingLimit: 20,
restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Warning);
logger = loggerConfig.CreateLogger();
logger.Information("Logger configured with email to {user}", emailOptions.ToEmail);
}

Log.Logger = logger;
try
{
_serviceProvider = RegisterServices();

Log.Information("gthx running with: {args}", args);

var scope = _serviceProvider.CreateScope();
var myBot = scope.ServiceProvider.GetRequiredService<IBotRunner>();
myBot.Run();
DisposeServices();
}
catch (Exception ex)
{
Log.Error($"Gthx failed to start: {ex.Message}");
Console.WriteLine($"Gthx Failure: {ex}");
}
finally
configuration.WriteTo.Email(
new EmailSinkOptions
{
From = emailOptions.FromName,
To = new List<string> { emailOptions.ToEmail }
}
);
Comment thread GthxNetBot/Program.cs
Comment on lines +113 to +120
// Register bot runners
services.AddSingleton<IrcBot>();
services.AddSingleton<ConsoleTestBot>();
services.AddSingleton<IBotRunner>(provider =>
useConsoleTestBot
? provider.GetRequiredService<ConsoleTestBot>()
: provider.GetRequiredService<IrcBot>());
})
Comment thread GthxNetBot/Program.cs
Comment thread GthxNetBot/GthxNetBot.csproj Outdated
Comment on lines +23 to +26
"ConnectionStrings": {
"GthxDb": "Server=127.0.0.1,14333;Database=Gthx;User Id=sa;Password=Your_password123;TrustServerCertificate=True;",
"GthxDb_Type": "sqlserver"
},
Comment thread wait-for-sql.sh
Comment on lines +6 to +16
host="localhost"
port="1433"
user="sa"
password="Your_password123"
timeout=60
sql_ready=0

echo "Waiting for SQL Server to be available..."

for i in $(seq 1 $timeout); do
if /opt/mssql-tools/bin/sqlcmd -S $host,$port -U $user -P $password -Q "SELECT 1" > /dev/null 2>&1; then
Comment thread Dockerfile-UnitTests
Comment on lines +7 to +10
# Set environment variables for SQL Server
ENV SA_PASSWORD=Your_password123
ENV ACCEPT_EULA=Y
ENV MSSQL_PID=Express
Comment thread Dockerfile-UnitTests
Comment on lines +1 to +35
# Use the official Microsoft SQL Server 2022 image as the base
FROM mcr.microsoft.com/mssql/server:2022-latest AS sql

# Install .NET SDK
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build

# Set environment variables for SQL Server
ENV SA_PASSWORD=Your_password123
ENV ACCEPT_EULA=Y
ENV MSSQL_PID=Express

# Copy the SQL Server binaries from the sql image
COPY --from=sql /opt/mssql /opt/mssql

# Expose SQL Server port
EXPOSE 1433

# Create a working directory
WORKDIR /app

# Copy your solution and test project files
COPY . .

# Copy wait-for-sql script and make it executable
COPY wait-for-sql.sh /wait-for-sql.sh
RUN chmod +x /wait-for-sql.sh

# Restore and build your test project (adjust path as needed)
RUN dotnet restore
RUN dotnet build --configuration Release

# Start SQL Server in the background, wait for it to be ready, then run tests
CMD /opt/mssql/bin/sqlservr & \
/wait-for-sql.sh && \
dotnet test --no-build --logger:trx
Comment thread Dockerfile-UnitTests
Comment on lines +24 to +35
# Copy wait-for-sql script and make it executable
COPY wait-for-sql.sh /wait-for-sql.sh
RUN chmod +x /wait-for-sql.sh

# Restore and build your test project (adjust path as needed)
RUN dotnet restore
RUN dotnet build --configuration Release

# Start SQL Server in the background, wait for it to be ready, then run tests
CMD /opt/mssql/bin/sqlservr & \
/wait-for-sql.sh && \
dotnet test --no-build --logger:trx
Comment on lines +128 to +134
var host = hostBuilder.Start();
_server = host.GetTestServer();
_Db = host.Services.GetRequiredService<GthxDataContext>();
_data = host.Services.GetService<IGthxData>() as GthxSqlData;
_client = host.Services.GetService<IIrcClient>() as MockIrcClient;
_botNick = host.Services.GetService<IBotNick>();
_gthx = host.Services.GetRequiredService<GthxBot>();
gunnbr and others added 2 commits May 25, 2026 17:25
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants