Agentic Refactoring at Scale: From Loosely Typed VB.NET to Modern C#
How do you remove over 100,000 lines of code and make more than 1,000,000 lines strictly typed in a live ERP system, without breaking it? At AFAS, we are modernizing millions of lines of loosely typed VB.NET (Option Strict Off), making it strictly typed as a stepping stone toward modern C#. That exposed a fundamental challenge: how do you transform a living system at scale while keeping it consistent, simple, and safe?
Traditional refactoring relies on static tooling and handcrafted rules, which are hard to evolve and expensive to maintain. We took a different approach: agentic refactoring powered by LLMs. We introduce our system of tool-using LLM loops, agents that go beyond generating text to generating-, testing-, and executing their own refactoring tools. They apply idiomatic patterns, remove legacy constructs, and enforce stricter coding standards across the entire codebase.
Safety is critical at this scale. We show how unit tests, LLM-based evaluations, and human-in-the-loop validation combine to catch bad transformations before they land, and how clear boundaries keep the system predictable and controllable. We also share what went wrong along the way, and the guardrails we added in response.
Complex refactorings that once required deep Roslyn expertise are now built and executed in a fraction of the time. This talk shows how AI turns refactoring from a rigid, manual process into a flexible, composable system that lets engineers deliver large-scale impact faster, more safely, and with far less effort.
Takeaways:
- How to build tool-using LLM loops that refactor code at scale
- A layered safety net you can copy: unit tests, LLM-based evals, and human review
- How to scope agents (e.g. never touch public APIs) so large-scale change stays predictable
- Real-world proof: 100,000+ lines removed and 1,000,000+ lines made strictly typed
About the speaker
Gerrit van den Geest
Gerrit van den Geest is a software engineer with over 20 years of experience building software systems, including ERP solutions in the healthcare sector. After studying Software Technology at Utrecht University, specializing in programming language design and software architecture, he worked in roles ranging from development management to product and portfolio management.
Today, Gerrit has returned to his original passion: programming. At AFAS, he helps build the next generation of ERP software using modern development practices and AI-assisted engineering.
