Skip to content

CA1062 not firing if '?.' is used on the previous line #3531

Open

Description

Analyzer package

Microsoft.CodeAnalysis.FxCopAnalyzers

Package Version

v3.0.0-beta3.final (latest pre-release)

Diagnostic ID

Example: CA1062

Repro steps

namespace CA1062Test
{
    public static class Thing
	{
		public static void Fn(int[] items)
		{
			var l1 = items?.Length;

			// This should fire a CA1062, but it does not.
			var l2 = items.Length;
		}
	}
}

Expected behavior

CA1062 on line declaring l2

Actual behavior

No CA1062

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Area-Microsoft.CodeAnalysis.NetAnalyzersBugThe product is not behaving according to its current intended designDataFlowFalse_NegativeNo diagnostic is reported for a problematic casehelp wantedThe issue is up-for-grabs, and can be claimed by commenting

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions