Permalink
707b719 Jun 14, 2018
1 contributor

Users who have contributed to this file

68 lines (48 sloc) 1.03 KB

RCS1146: Use conditional access

Property Value
Id RCS1146
Category Usage
Default Severity Info
Enabled by Default
Supports Fade-Out -
Supports Fade-Out Analyzer -

Examples

Code with Diagnostic

if (s != null && s.StartsWith("a")) // RCS1146
{
}

Code with Fix

if (s?.StartsWith("a") == true)
{
}

Code with Diagnostic

if (dic != null && dic[0].StartsWith("a")) // RCS1146
{
}

Code with Fix

if (dic?[0].StartsWith("a") == true)
{
}

Code with Diagnostic

if (x != null) // RCS1146
    x.Foo();

Code with Fix

x?.Foo();

See Also

(Generated with DotMarkdown)