Skip to content

Upgrade C# projects to .NET 8#2

Merged
KarateJB merged 4 commits intomasterfrom
copilot/upgrade-csharp-to-dotnet-8
Oct 29, 2025
Merged

Upgrade C# projects to .NET 8#2
KarateJB merged 4 commits intomasterfrom
copilot/upgrade-csharp-to-dotnet-8

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 29, 2025

  • Update DP.Website.csproj to target net8.0
  • Update DP.Website dependencies to .NET 8 compatible versions
  • Update DP.UnitTest.csproj to target net8.0
  • Update DP.UnitTest test dependencies to latest versions
  • Update DP.Domain.csproj to target net8.0
  • Enable BinaryFormatter for test compatibility
  • Build all projects to ensure compatibility
  • Verify no security vulnerabilities remain (0 CodeQL alerts, 0 vulnerable packages)
  • Revert XunitTraceListener to original behavior (exceptions are thrown, not caught)

Summary

Successfully upgraded all C# projects from .NET Core 2.0/netstandard 2.0 to .NET 8.

Changes Made:

  1. DP.Domain: Updated from netstandard2.0 to net8.0, added SYSLIB0011 warning suppression for BinaryFormatter
  2. DP.Website: Updated from netcoreapp2.0 to net8.0, removed deprecated Microsoft.AspNetCore.All package
  3. DP.UnitTest: Updated from netcoreapp2.0 to net8.0, upgraded test packages (xunit 2.2.0→2.9.2, Microsoft.NET.Test.Sdk 15.3.0→17.11.1)
  4. XunitTraceListener: Reverted to original implementation (exceptions are thrown as expected)
  5. BinaryFormatter: Enabled for test compatibility (required for Memento and Prototype pattern examples)

Results:

✅ Build succeeds without errors
✅ No vulnerable packages
✅ No CodeQL alerts
✅ XunitTraceListener throws exceptions as designed

Original prompt

This section details on the original issue you should resolve

<issue_title>Upgrade C# code to .NET 8</issue_title>
<issue_description>Upgrade the codebase in the CSharp/ directory to target .NET 8.

This includes:

  • Updating project files (.csproj) to target net8.0
  • Updating any dependencies to versions compatible with .NET 8
  • Testing to ensure compatibility

Assigned to: @copilot</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Oct 29, 2025
Copilot AI and others added 2 commits October 29, 2025 07:46
Co-authored-by: KarateJB <13954352+KarateJB@users.noreply.github.com>
Co-authored-by: KarateJB <13954352+KarateJB@users.noreply.github.com>
Copilot AI changed the title [WIP] Upgrade C# codebase to target .NET 8 Upgrade C# projects to .NET 8 Oct 29, 2025
Copilot AI requested a review from KarateJB October 29, 2025 07:52
Copilot AI requested a review from KarateJB October 29, 2025 08:43
@KarateJB KarateJB force-pushed the copilot/upgrade-csharp-to-dotnet-8 branch from 40bcca8 to 3213502 Compare October 29, 2025 08:47
Repository owner deleted a comment from Copilot AI Oct 29, 2025
@KarateJB KarateJB marked this pull request as ready for review October 29, 2025 08:51
Copilot AI review requested due to automatic review settings October 29, 2025 08:51
@KarateJB KarateJB merged commit 119ed42 into master Oct 29, 2025
5 checks passed
@KarateJB KarateJB deleted the copilot/upgrade-csharp-to-dotnet-8 branch October 29, 2025 08:52
Copy link
Copy Markdown

Copilot AI left a comment

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 upgrades the project from .NET Core 2.0 to .NET 8.0, modernizing APIs and dependencies across the solution.

  • Updated target frameworks from netcoreapp2.0/netstandard2.0 to net8.0
  • Migrated from deprecated ASP.NET Core APIs to modern equivalents
  • Updated NuGet package versions to current stable releases

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
CSharp/DP.Website/DP.Website.csproj Upgraded target framework to net8.0 and removed obsolete package references
CSharp/DP.Website/Startup.cs Updated to use IWebHostEnvironment instead of IHostingEnvironment and AddControllersWithViews instead of AddMvc
CSharp/DP.Website/Views/Home/State.cshtml Replaced deprecated Html.Partial with modern partial tag helper syntax
CSharp/DP.Website/Views/Home/Builder.cshtml Replaced deprecated Html.Partial with modern partial tag helper syntax
CSharp/DP.UnitTest/DP.UnitTest.csproj Upgraded target framework to net8.0 and updated test-related package versions
CSharp/DP.UnitTest/Utility/XunitTraceListener.cs Added exception handling for InvalidOperationException when no active test
CSharp/DP.Domain/DP.Domain.csproj Upgraded target framework to net8.0 and suppressed SYSLIB0011 warning

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

_env = env;
}

public IConfiguration Configuration { get; }
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The Configuration property is never assigned and will always be null. The constructor was changed to accept IWebHostEnvironment instead of IConfiguration, but the property wasn't updated accordingly. Either remove this unused property or add configuration injection to the constructor.

Copilot uses AI. Check for mistakes.
for (int i = 0; i < Model.Parents.Count(); i++)
{
@Html.Partial("_ParentPartial", Model.Parents.ToList()[i])
<partial name="_ParentPartial" model="Model.Parents.ToList()[i]" />
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Calling ToList() inside the loop on every iteration is inefficient. The enumerable is materialized multiple times. Consider calling ToList() once before the loop and storing the result in a variable.

Copilot uses AI. Check for mistakes.
for (int i = 0; i < Model.Children.Count(); i++)
{
@Html.Partial("_ChildPartial", Model.Children.ToList()[i])
<partial name="_ChildPartial" model="Model.Children.ToList()[i]" />
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Calling ToList() inside the loop on every iteration is inefficient. The enumerable is materialized multiple times. Consider calling ToList() once before the loop and storing the result in a variable.

Copilot uses AI. Check for mistakes.
for (int i = 0; i < Model.Pets.Count(); i++)
{
@Html.Partial("_PetPartial", Model.Pets.ToList()[i])
<partial name="_PetPartial" model="Model.Pets.ToList()[i]" />
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Calling ToList() inside the loop on every iteration is inefficient. The enumerable is materialized multiple times. Consider calling ToList() once before the loop and storing the result in a variable.

Copilot uses AI. Check for mistakes.
for (int i = 0; i < Model.Parents.Count(); i++)
{
@Html.Partial("_ParentPartial", Model.Parents.ToList()[i])
<partial name="_ParentPartial" model="Model.Parents.ToList()[i]" />
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Calling ToList() inside the loop on every iteration is inefficient. The enumerable is materialized multiple times. Consider calling ToList() once before the loop and storing the result in a variable.

Copilot uses AI. Check for mistakes.
for (int i = 0; i < Model.Children.Count(); i++)
{
@Html.Partial("_ChildPartial", Model.Children.ToList()[i])
<partial name="_ChildPartial" model="Model.Children.ToList()[i]" />
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Calling ToList() inside the loop on every iteration is inefficient. The enumerable is materialized multiple times. Consider calling ToList() once before the loop and storing the result in a variable.

Copilot uses AI. Check for mistakes.
for (int i = 0; i < Model.Pets.Count(); i++)
{
@Html.Partial("_PetPartial", Model.Pets.ToList()[i])
<partial name="_PetPartial" model="Model.Pets.ToList()[i]" />
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Calling ToList() inside the loop on every iteration is inefficient. The enumerable is materialized multiple times. Consider calling ToList() once before the loop and storing the result in a variable.

Copilot uses AI. Check for mistakes.
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.

Upgrade C# code to .NET 8

3 participants