ReSharper 2026.1 Help

Code inspection: Use 'with' expression to copy record

This inspection reports record creation where a new record is built mostly by copying values from another record of the same type and changing only a small part of it. In that situation, a with expression is the idiomatic way to express the copy.

Example

record Person(string Name, int Age); var original = new Person("Kate", 41); var updated = new Person(original.Name, 42);
record Person(string Name, int Age); var original = new Person("Kate", 41); var updated = original with { Age = 42 };

Quick-fix

Using with removes repetitive field or property copying and makes the actual modification more obvious.

30 March 2026