Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 461 Bytes

RCS1180.md

File metadata and controls

32 lines (21 loc) · 461 Bytes

RCS1180: Inline lazy initialization

Property Value
Id RCS1180
Severity Info

Example

Code with Diagnostic

List<object> items = null;

// ...

if (items == null) // RCS1180
{
    items = new List<object>();
}

items.Add(x);

Code with Fix

(items ?? (items = new List<object>())).Add(x);

(Generated with DotMarkdown)