Roslyn-analyzers: CA1822 falsely triggered on members that use dynamic objects.

Created on 6 Oct 2017  路  2Comments  路  Source: dotnet/roslyn-analyzers

Analyzer package

Microsoft.CodeAnalysis.FxCopAnalyzers (v2.3.0-beta1)

Analyzer

MarkMembersAsStatic

Repro steps

See attached repro project: RoslynAnalyzers.CA1822.ExpressionBodiedMembers.zip

Expected behavior

No CA1822 violation.

Actual behavior

A CA1822 violation is raised. The error does not appear in the Error List in Visual Studio 2017, but is reported in the Build Output window and the project build is cancelled with error:

1>...RoslynAnalyzers.CA1822.ExpressionBodiedMembersRoslynAnalyzers.CA1822.ExpressionBodiedMembersApplicationConfiguration.cs(15,23,15,60): error CA1822: Member ApplicationInsightsInstrumentationKey does not access instance data and can be marked as static (Shared in VisualBasic)

Probably caused by the dynamic object reference in the arguments of the invoked member.

Area-Microsoft.CodeQuality.Analyzers Bug

All 2 comments

Likely fixed in latest bits, validate and close.

Confirmed, this no longer repros.

Was this page helpful?
0 / 5 - 0 ratings