Skip to content

Mention this analyzer also checks for the [Pure] attribute #48767

@aelij

Description

@aelij

Type of issue

Typo

Description

CA1806 emits the following diagnostic for [Pure] methods:

{0} calls {1} but does not use the value the method returns. Because {1} is marked as a Pure method, it cannot have side effects. Use the result in a conditional statement, assign the result to a variable, or pass it as an argument to another method.

It would also be useful to mention this in the PureAttribute docs, since it currently says:

This attribute is not enforced by the current analysis tools; you should use this attribute only if you are sure that the methods are pure.

https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.contracts.pureattribute

Page URL

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1806

Content source URL

https://github.com/dotnet/docs/blob/main/docs/fundamentals/code-analysis/quality-rules/ca1806.md

Document Version Independent Id

59d0b85d-87f3-c4e4-6891-3002e2f60158

Platform Id

a91b8153-7420-d312-601a-b29f874cf8ae

Article author

@gewarren

Metadata

  • ID: 0f51f0a0-29e7-be15-ffdc-ee210cf7ef1c
  • PlatformId: a91b8153-7420-d312-601a-b29f874cf8ae
  • Service: dotnet-fundamentals

Related Issues


Associated WorkItem - 500370

Metadata

Metadata

Type

No type

Projects

Status

👀 In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions