New AiGen Functionality in CodeRush for Visual Studio
CodeRush's AiGen is Faster and Smarter for Everyday Development
Improved Context Acquisition & Architectural Awareness
- Identifies which related types matter for the request
- Traverses the solution hierarchy as needed
- Optimally packs a reasonable portion of the context window with only the most relevant information
- Sends that optimized and packed context to the reasoning model
Example: Consolidating Validation Logic Using the Type Hierarchy

ValidateCore() method, you’ll see some validation logic.protected override void ValidateCore(Order order, ValidationResult result) {
if (order is null) {
result.Add("Order is required.");
return;
}
// TODO: Ask AiGen to consolidate this based on what we have in the base class.
var customer = order.Customer;
if (customer is null) {
result.Add("Customer is required.");
if (StopOnFirstError) return;
}
if (customer?.BillingAddress is null) {
result.Add("Billing address is required.");
if (StopOnFirstError) return;
}
if (string.IsNullOrWhiteSpace(customer?.BillingAddress?.CountryCode)) {
result.Add("Billing address country is required.");
if (StopOnFirstError) return;
}
if (string.IsNullOrWhiteSpace(order.OrderId)) {
result.Add("OrderId is required.");
}
}
BaseValidator<T> -- check out its RequireCustomer() method).// Shared helpers that derived validators can (and should) reuse.
protected void RequireCustomer(Customer? customer, ValidationResult result) {
if (customer is null) {
result.Add("Customer is required.");
if (StopOnFirstError)
return;
}
if (customer?.BillingAddress is null) {
result.Add("Billing address is required.");
if (StopOnFirstError)
return;
}
if (string.IsNullOrWhiteSpace(customer?.BillingAddress?.CountryCode)) {
result.Add("Billing address country is required.");
}
}ValidateCore()method, Rather than telling AiGen exactly how to fix it, we can talk to it the way we might speak to a human teammate.Invoke AiGen (double-tap and hold the right Ctrl key if speaking or press Caps+G if you prefer to type -- see AiGen setup for more details). Then say something like (one of the following):
“Consolidate this logic with what we already have in the base class.”
“Take a look at the ancestor class and see if we can reuse any of that code here.”
order-specific checks local.After applying this change, the AiGen Navigator will appear. You can click the "Show Difference View" button to see the before and after for the changes applied to this method:
”
Here, AiGen consolidates the duplicated validation logic into a single call to RequireCustomer(), while maintaining the existing StopOnFirstError behavior.
Speed Where It Matters: Fine-grained Deltas
- Speed — generating fewer output tokens (to support the fine grained delta) is faster than regenerating all the code that doesn't change.
- Cost — output tokens are significantly more expensive than input tokens.
- Precision — small, focused changes reduce churn and unintended side effects.
Example: Small Business Rule Change Inside a Large Method
ComputeTaxes() method is non-trivial and could resemble real production code, with multiple early exits, counters, and guard clauses.// TODO: Apply the customer's discount tax policy when calculating taxableBase.This is a subtle rule change. We don’t want to rewrite the method -- we just want to adjust how the taxable base is calculated under specific conditions.
“Let's incorporate the customer discount policy.
AiGen should:
- Change only the minimal code region required
- Leave the rest of the method untouched
- Apply the update directly in the editor (no manual copy/paste)
Turning this:
decimal taxableBase = order.Subtotal - order.DiscountAmount;into something like this:
decimal taxableBase = customer.DiscountPolicy switch {
Customer.Discounts.ReduceTaxableBase => order.Subtotal - order.DiscountAmount,
Customer.Discounts.FullyTaxable => order.Subtotal,
_ => order.Subtotal - order.DiscountAmount
};Note both the size of the method and how little code AiGen needs to generate to apply the change.
The prompt doesn’t require exact symbol names or structured references — we describe intent, and AiGen resolves the implementation from surrounding context.
This example demonstrates fine-grained deltas in practice: smaller outputs, lower token usage, reduced latency, and a more immediate turnaround — especially when working inside large methods.
After AiGen applies the change, you can find evidence of the smaller delta in two places:
- AiGen Navigator status bar: Check the Reasoning out token count and the elapsed time (114 output tokens and 3.2 seconds, respectively, in the screenshot below). Fine-grained deltas yield small output token counts — typically far smaller than the count required to regenerate an entire method.image

- Editor selection: Selecting a change in the AiGen Navigator (e.g., "∆ selection") highlights the inserted/modified region, making the delta boundary immediately visible. In the screenshot below, the selection represents the small portion of the method that was regenerated. The rest of the method was untouched by AI.

What's also exciting about these optimized deltas, you are free to edit (or apply tooling to) surrounding code while waiting for AI to return.
Which brings us to our next topic....
Working While AI Is Running: In-Flight Changes & Conflict Navigation
Scenario A: Non-Conflicting Changes -- AI + Human
Submit() method contains several failure points -- exactly the kind of code where you might want better diagnostics. To prepare for this simultaneous edit demo, first, copy the following text to the clipboard:> Logs any failures.
Submit() method and invoke AiGen with a request like:
- The logging changes are applied correctly.
- Your manual documentation edit is preserved.
- No manual merging is required.

Scenario B: Parallel, Non-Conflicting Changes -- Multiple AI Agents
TrackOperationAttribute declared in the Shared folder).Start by opening TrackOperationAttribute.cs from the Shared folder and examining the class. This is the custom attribute we'll use for telemetry. Note that it includes properties for:
- Name -- describes whatever we're tracking
- Category -- groups related telemetry events
Next, switch back to OrderSubmissionService.cs and place the caret in the Submit() method. The next two steps should be performed back to back.
- Launch the first agent with: “Add logging around failures in this method.”
- Launch the second agent with: "Add the track operation attribute. Category is orders."
The goal here is to start up a second agent while the first is still inflight. If the first AI response lands before you can launch the second, perform an undo (close the AiGen Navigator) and then copy the second prompt to the clipboard. Then after launching the first agent by voice, invoke the second agent with Caps+G (plus a paste).

When multiple AI responses land, the AiGen Navigator shows multiple landings using tabs. In the screenshot below, notice the agents landed in reverse order from take-off, with the tracking attribute finishing first.

Notice AiGen correctly discovered the TrackOperationAttribute from the Shared folder and added it with appropriate values for both Name and Category. Also note the orange arrow in the screenshot above -- it points to the second AI landing ("Failure logging" in this example -- your tabs may have different tab titles and agents may complete in a different order than they were launched).
AiGen Navigator tabs may display one or more of the following icons:
- ⭐ Star -- the landing has not yet been viewed (typically a recent result).
- ✔️ Check -- all changes were successfully integrated (no conflicts)
- ❗ Exclamation -- one or more conflicts occurred on landing
- One agent modifies the **method body** (logging)
- The other modifies the **method metadata** (the attribute)
- The requested changes **do not overlap**, and
- Each agent’s task can be completed **independently** of the others.
Scenario C: Conflicting Changes
OrderSubmissionService.Submit()to its original state.throw with an early return null;.
- The original code as it existed when the request was launched
- The current code at apply time
- The reasoning model's attempted replacement
- which change was blocked,
- why it was blocked, and
- exactly what AiGen was prepared to do.
The change for this member was skipped because the target code changed inflight.
if (order.Customer is null)
throw new InvalidOperationException("Customer is required.");
if (order.Customer is null)
return null;if (order.Customer is null) {
Console.Error.WriteLine($"[{nameof(OrderSubmissionService)}] Order submission failed: {nameof(order.Customer)} is required. OrderId='{order.OrderId ?? "<null>"}'.");
throw new InvalidOperationException("Customer is required.");«Caret»
}Everything else proceeds as expected -- no rollback, no guesswork, and no silent overwrites.
Runtime State to Tests: Debug-Time Object Reconstruction
Example: Turning a Debug-Time Bug into a Targeted Test
BuildShippingLabel() method formats a shipping label from customer and address data.Regionis empty or whitespace
- The computed label (which includes
cityRegionPostal) contains a dangling comma and extra spaces

BuildShippingLabel() method), invoke AiGen and say:order parameter. It has a Customer property that in turn holds the BillingAddress with the empty region that led to this bug.
- Reconstruct the runtime object graph for the
orderparameter using live debug-time values - Locate the appropriate
OrderAddressFormatterTestsfixture - Generate a new xUnit test that reproduces the observed state and behavior
- Add targeted assertions that detect the formatting defectUnderstand the object graph in scope (including nested properties/objects)
[Fact]
public void BuildShippingLabel_RegionBlank_NoDoubleSpaces_AndNoDanglingComma() {
// Arrange (debug-time values)
var address = new Address {
City = "Seattle",
Region = " ", // blank/whitespace
PostalCode = "98101",
CountryCode = "US",
Line1 = "123 Example St"
};
var customer = new Customer { DisplayName = "Ada Lovelace", BillingAddress = address, Id = "C-42" };
var order = new Order {
Customer = customer,
DiscountAmount = 10m,
Subtotal = 120m,
OrderId = "DBG-1001",
TaxAmount = 0m
};
var formatter = new OrderAddressFormatter();
// Act
string label = formatter.BuildShippingLabel(order);
// Assert
Assert.DoesNotContain(" ", label); // no double spaces anywhere
Assert.DoesNotContain(", ", label); // no dangling comma + space
Assert.DoesNotMatch(@",\s*(—|$)", label); // no comma before em-dash or end
Assert.DoesNotMatch(@",\s+\d", label); // no comma followed by spaces then digits (e.g., ", 98101")
Assert.Contains("Seattle", label);
Assert.Contains("98101", label);
}This workflow makes it practical to capture real-world edge cases in the moment they are discovered. Instead of manually attempting to duplicate observed state, you can promote live runtime data directly into a durable, repeatable test.

- Easily capture real-world edge cases
- Generate focused, high-signal tests
- Preserve the conditions that exposed the issue
Large-Scale Architectural Changes: Evolving Interfaces Across Many Implementations
Example: Generating and Evolving Order Rules
namespace CodeRush.AiGen.Main.ArchitecturalEdits;
public interface IOrderRule {
RuleResult Apply(Order order);
}IOrderRule — each reflecting realistic order-processing concerns such as fraud detection, pricing validation, eligibility checks, and fulfillment constraints.
- Generate multiple production-quality types in a single request
- Maintain a shared contract across many implementations
- Respect namespace organization and solution structure
- Coordinate multi-file changes across a codebase
Evolving the Contract Across the Hierarchy
- Large-scale architectural refactorings
- Contract evolution across many implementers
- Coordinated multi-file updates without manual intervention
- High-level structural changes (in addition to surgical edits)
Fixing Code Using Active Compiler Errors
Until now, we’ve focused on how AiGen understands source code, hierarchy, and runtime state. But AiGen can also reason over active compiler errors — both at the caret and across the Visual Studio Errors list.
This allows you to resolve broken code using short, natural prompts, without needing to restate what the error is or why it occurred.
Example: Fixing a Real Compiler Error with “Fix this”
// Demo toggle:
// TODO: Uncomment the line below to intentionally introduce a compiler error on the `where` clause, below.
//#define DEMO_ACTIVE_ERRORSWhere() call in the broken LINQ query and invoke AiGen. Simply say:public async Task<int> GetHighValueOrderCountAsync(decimal minSubtotal) {
var orders = await GetOrdersAsync().ConfigureAwait(false);
return orders.Count(o => o.Subtotal >= minSubtotal);
}- Read live compiler diagnostics from the editor
- Infer intent from the actual error, not just the source text
- Generate a non-trivial corrective refactor with a minimal prompt
- Resolve failures without requiring developers to restate what the compiler already knows
What This Update Unlocks
- You can ask for surgically precise changes inside large methods without paying or waiting for redundant regeneration.
- You can continue working while AI requests are in-flight, or even launch multiple agents in parallel when tasks impact non-overlapping areas of code.
- Individual conflicts -- caused by overlapping edits while AI requests are in-flight -- are isolated and surfaced in the UI, rather than forcing all-or-nothing outcomes.
- Debug-time state observations can be turned into targeted tests, grounded in real execution data.
Limitations
AiGen is optimized to work fast in C# files and XAML. However, as with any tooling involving AI models, AiGen has some limitations:
- AiGen can generate new files in any programming language and add them to the active project, but it can only modify C# and XAML files.
- Multi-agent support and editing while AI is in-flight is currently available in C# only, For XAML, wait for the AI response to land before making changes to the same XAML file.
- Blazor support is pending
- There are some reasonable depth limitations on reconstructing debug-time object graphs and on traversing class hierarchies for the context window.
- AiGen cannot delete files or remove files from the project.
- Aside from adding new files and installing NuGet packages, AiGen cannot modify the project file or the solution file (so there's currently no way to create or add new projects or add/modify project properties).
- AiGen is not a chat window based tool, and there is no history/memory of previous actions. Context is derived entirely from your prompt, the editor view, surrounding code, the solution source, debug values, etc..
- There are the usual limitations and disclaimers on the power of AI itself. Sometimes AI "hallucinates" (this is especially true when generating code based on frameworks that have changed or where API evolution has introduced breaking changes over time). Also, it is possible to have a request so complex AI has difficulty implementing it correctly.