Back to Browse

GitHub Copilot AI Refactoring Spaghetti Code | Legacy ASP.NET Rewrite

135 views
May 6, 2026
5:41

Rewriting a legacy ASP.NET car classifieds application using GitHub Copilot in Visual Studio 2026. In the previous episode of this series, I migrated the **entities and data access layer** from a 16-year-old .NET Framework project into a modern codebase. In this video, I begin rewriting one of the core business features: listing placement. The original implementation is… messy. The legacy codebase contains **spaghetti code, minimal architecture, and tightly coupled logic**, making it difficult to understand or modify. To tackle this, I use **GitHub Copilot to analyze the existing code**, generate explanations, and even produce a **workflow diagram** that makes the system easier to reason about. However, when refactoring a critical feature like listing placement, letting AI rewrite everything blindly would be risky. Instead, I stay **hands-on with the architecture**, while using Copilot to assist with implementation details. In this episode you'll see: • How I design a **ListingPlacementService** to orchestrate the feature • Breaking a monolithic class into **smaller architecture-friendly services** • Using a **DataAccessFacade** to simplify repository interactions • Implementing a **Unit of Work pattern** with a fluent repository API • Generating temporary **AI-assisted unit tests** • Refactoring outdated **image upload logic** • Letting Copilot run in **Autopilot mode** to generate infrastructure code • How **Claude Haiku 4.5** produces architecture-aware code inside a layered solution One surprising result: even the cheaper model (Haiku 4.5) correctly separates responsibilities between **utilities, services, and domain logic** — generating code that fits the structure of the project without manual restructuring. This series documents a real experiment: Can AI act as a development partner while modernizing a legacy .NET application? --- 📺 **Full Rewrite Series** https://www.youtube.com/playlist?list=PLphsQTGN5DbKDXbh-kkC3_wX604dExCXm --- #githubcopilot #visualstudio #aicoding

Download

1 formats

Video Formats

360pmp46.3 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

GitHub Copilot AI Refactoring Spaghetti Code | Legacy ASP.NET Rewrite | NatokHD