Stacks

Migrate a deprecated API across every callsite in C# with Atlas in 2026

Updated 8 min read

Atlas empowers C# developers in 2026 to systematically migrate deprecated APIs across an entire codebase, ensuring no callsite is missed. By leveraging the `lsp` tool to find all references, creating `todowrite` entries for each, and applying changes with `apply_patch` followed by `xUnit via dotnet test` verification, Atlas provides a robust, auditable workflow for complete refactoring within your C# projects.

How Atlas finds all deprecated C# API callsites

Atlas ensures a complete migration of deprecated C# APIs by first enumerating every callsite, leaving zero to chance. In 2026, Atlas uses the `lsp` tool's `findReferences` operation to query the language server for a precise list of all callers, then cross-checks with `grep` for dynamic string-based usages.

To begin a deprecated API migration in C#, Atlas first establishes a comprehensive list of all affected callsites. It achieves this by running within your C# solution, whether it's a `.csproj` or `.sln` file, allowing it to understand your project's structure, namespaces, and NuGet packages. The `lsp` tool's `findReferences` operation queries the C# language server, which leverages its deep understanding of the Abstract Syntax Tree (AST) declarations to yield a complete and accurate set of direct callers for the deprecated symbol. This AST-based indexing, powered by tree-sitter, is more precise than blind line windows. To catch any potential edge cases, such as dynamic invocations or string-based references that the language server might miss, Atlas then performs a `grep` search across the codebase. This dual approach guarantees that every single callsite of the deprecated C# API is identified, forming the foundation for a truly complete migration.

Tracking C# API migration progress with Atlas

To manage the complexity of migrating a deprecated C# API across potentially hundreds of files, Atlas creates a `todowrite` entry for each callsite. This ensures partial progress is always visible and no single migration step is silently skipped, providing a clear roadmap for the 100% completion goal.

Once all callsites of the deprecated C# API have been enumerated, Atlas transforms this list into actionable work items using the `todowrite` tool. Each individual callsite becomes a distinct `todowrite` entry, providing granular visibility into the migration progress. This approach is crucial for large C# codebases where a migration might span many files and require multiple steps. Instead of a monolithic task, the work is broken down into manageable units. As each callsite is successfully migrated and verified, its corresponding `todowrite` entry is marked complete. This transparent tracking mechanism ensures that no callsite is accidentally overlooked or silently skipped, making partial progress visible and driving the project towards a guaranteed 100% completion rate for the C# API migration.

Safely applying C# code changes with Atlas's `apply_patch`

Atlas applies each C# API migration with the `apply_patch` tool, which prioritizes safety and precision over guesswork. This tool seeks the exact hunk context and `old_lines` before making any change, failing explicitly with 'Failed to find expected lines' rather than misapplying to a drifted file, a critical feature in 2026.

The core of Atlas's C# API migration capability lies in its `apply_patch` tool, designed for maximum safety and reliability. When migrating a callsite, Atlas generates a context-anchored patch. This patch includes not only the `old_lines` to be replaced and the `new_lines` to be inserted, but also surrounding context lines. Before applying any change to a C# file, `apply_patch` rigorously verifies that the expected `old_lines` and their context still exist precisely as anticipated. If the file has drifted due to other concurrent changes, `apply_patch` will not guess or force the change; instead, it will explicitly fail with a 'Failed to find expected lines' error. This prevents misapplication of patches and ensures that every C# code modification is accurate. Furthermore, Atlas computes a unified diff for every file edit and surfaces it for your approval, allowing you to review and confirm changes before they are written to disk. After applying changes, Atlas can also run `dotnet format` to ensure consistent code style across the modified C# files.

Verifying C# API migrations with `xUnit via dotnet test`

After each C# file modification, Atlas immediately runs the affected tests using `xUnit via dotnet test` to verify the migration's correctness. A `todowrite` entry is marked complete only once its corresponding tests pass, providing real-time feedback and preventing the accumulation of 1 or more regressions.

A critical safety net in the C# API migration workflow is the immediate verification of changes through testing. After Atlas applies a patch to a C# file, it uses its `bash` tool to execute `xUnit via dotnet test` for the affected components. This ensures that the migration has not introduced any regressions or unexpected behavior. The `todowrite` entry for that specific callsite is only marked as completed if and when the `xUnit via dotnet test` command reports a successful run. This tight feedback loop is essential for maintaining code quality throughout the migration process. It prevents the accumulation of errors, allowing developers to address any issues immediately rather than discovering them much later in the development cycle. This integration with the standard C# testing toolchain provides confidence that each migrated callsite functions correctly within the broader C# application.

Completing and cleaning up deprecated C# APIs

The final stage of migrating a deprecated C# API involves a rigorous confirmation that zero remaining usages exist across the codebase. Atlas performs a final `grep` for the deprecated symbol, ensuring 100% removal before the old implementation is safely deleted, preventing future accidental reintroduction.

Once all `todowrite` entries for the deprecated C# API have been marked complete, Atlas performs a final, crucial verification step. It executes a comprehensive `grep` search across the entire codebase for the deprecated symbol. This final check serves as an ultimate confirmation that absolutely zero instances of the old API remain. This 100% verification is vital to prevent any lingering usages that might have been missed or introduced inadvertently. Only after this final `grep` confirms a clean slate is the old, deprecated C# implementation safely deleted from the codebase. This systematic approach ensures that the migration is not only complete but also thoroughly cleaned up, preventing future developers from accidentally reintroducing the deprecated functionality. Atlas's ability to read git branches, status, and diffs, and to stage and create commits on your behalf, further streamlines this final cleanup and commit process.

Step by step

  1. 01Run Atlas in your C# solution, ensuring it can read your `.csproj` or `.sln` files, namespaces, and NuGet packages.
  2. 02Use `atlas lsp findReferences <DeprecatedSymbol>` to enumerate all direct callers of the deprecated C# API, then cross-check with `atlas grep <DeprecatedSymbol>` for dynamic usages.
  3. 03Create `todowrite` entries for each identified C# callsite, ensuring every migration task is tracked.
  4. 04For each `todowrite` entry, use `atlas apply_patch` to perform the C# code migration, reviewing the unified diff for approval.
  5. 05After each `apply_patch` operation, execute `atlas bash "dotnet test --filter <AffectedTests>"` to run `xUnit via dotnet test` for the modified C# code.
  6. 06Mark the `todowrite` entry as complete only after the `xUnit via dotnet test` command passes successfully.
  7. 07Periodically run `atlas bash "dotnet format"` to ensure all C# code changes adhere to project formatting standards.
  8. 08Perform a final `atlas grep <DeprecatedSymbol>` across the entire codebase to confirm zero remaining usages of the deprecated C# API.
  9. 09Delete the old C# implementation of the deprecated API.
  10. 10Use Atlas's git integration to stage and create a commit for the completed C# API migration.

Frequently asked questions

How does Atlas ensure it finds *all* C# callers of a deprecated method?
Atlas combines `lsp findReferences` for precise language server data with `grep` for dynamic or string-based C# usages, ensuring comprehensive enumeration across your `.csproj` or `.sln` projects.
Can Atlas handle C# projects with multiple `.csproj` files or a `.sln`?
Yes, Atlas is designed to run within a C# solution containing `.csproj` or `.sln` files, allowing it to read namespaces, project references, and NuGet packages for accurate code indexing.
What happens if Atlas tries to apply a patch to a C# file that has drifted?
Atlas's `apply_patch` tool will explicitly fail with 'Failed to find expected lines' if the hunk's context or `old_lines` do not match the current C# file, preventing incorrect modifications and ensuring safety.
How does Atlas integrate with C# testing frameworks like xUnit?
Atlas uses its `bash` tool to execute `xUnit via dotnet test` commands after each C# file modification, verifying changes immediately and marking `todowrite` entries complete only upon test success.
Does Atlas help maintain C# code style during migrations?
Yes, Atlas can integrate `dotnet format` into the workflow, ensuring that all C# code changes adhere to your project's established formatting standards and maintain consistency.
Can Atlas use local C# embedding models for code indexing?
Yes, Atlas can build its code index using local Ollama embeddings, keeping your C# code off third-party servers and enhancing privacy while still providing powerful semantic search.
How does Atlas ensure I review C# code changes before they are written?
Atlas computes a unified diff for every C# file edit and surfaces it for your approval before writing. It also drafts a plan in a read-only plan agent and asks for permission before switching to a build agent.

Try Atlas in your terminal

The terminal-native AI coding agent. Free core, single binary.

Install Atlas

Related guides

Migrate a Deprecated API Across Every Callsite with Atlas (2026 Workflow)

How to migrate a deprecated API across every callsite with Atlas in 2026: the lsp tool's findReferences enumerates callers, todowrite tracks them, apply_patch migrates each one.

Atlas for C# in 2026

Atlas is a terminal-native AI coding agent for C# and the .NET SDK in 2026. Run it in a solution with a .csproj or .sln and approve every diff before dotnet build.

Diagnose a Hanging or Long-Running Command in C# with Atlas (2026)

Work out whether a dotnet build is genuinely slow or silently blocked on input, using Atlas in 2026, and get NuGet restore and dotnet test unstuck for good.

Refactor a legacy module in C# with Atlas (2026)

How Atlas refactors a legacy C# module in 2026: lsp findReferences enumerates every callsite, apply_patch anchors on context, and xUnit via dotnet test pins behavior.

Onboard to an Unfamiliar C# Codebase with Atlas (2026)

How Atlas onboards you to an unfamiliar C# solution in 2026: codebase_search for meaning, glob for the .csproj layout, and a read-only explore subagent for wide sweeps.

Self-Review Your Working Diff Before Committing in C# with Atlas (2026)

Self-review a C# working diff in 2026 with Atlas: read the full diff and every changed file, grep for leftovers, revert from a snapshot, then run xUnit via dotnet test.

Review a Pull Request in C# With Atlas (2026)

Review a C# pull request with the context a line-by-line read misses. Atlas pulls the raw diff, reads whole files, and checks callers with the lsp tool's findReferences.

Automate GitHub Issue and Pull Request Triage in C# with Atlas in 2026

Automate GitHub issue and pull request triage for C# projects in 2026 using Atlas. Safely manage workflows, enforce trusted user access, and integrate with dotnet tools like xUnit and NuGet.

Browse this resource hub