roslyn
roslyn copied to clipboard
False positive IDE0059 with anonymous types
This issue has been moved from a ticket on Developer Community.
[severity:It bothers me. A fix would be nice] Visual Studio incorrectly generates an IDE0059 (Unnecessary assignment of a value to 'foo') on the first line of this code. The assignment is required because there is no way to create an anonymous type without also creating an object of that type.
var foo = new { systemRunDate = default(DateTime) };
Bar(out foo);
Console.WriteLine(foo);
static void Bar<T>(out T? foo)
{
foo = default; // In production code, deserialize from JSON.
}
Original Comments
Feedback Bot on 6/13/2023, 08:31 PM:
(private comment, text removed)
Original Solutions
(no solutions)