Code inspection: Possible unassigned object created by 'new' expression
This inspection reports object creation whose result is ignored. Creating an object as a standalone statement is often a mistake because the created instance is neither stored nor used.
throw new InvalidOperationException("Operation failed");
var exception = new InvalidOperationException("Operation failed");
Depending on the intent, the quick-fix can either throw the created exception or introduce a variable for the created object.
01 April 2026