Skip to content

Introduce analyzers for modification API same as Roslyn RS1014 #58

@FrediKats

Description

@FrediKats

Roslyn have analyzers for usage of tree modification api: https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/RulesMissingDocumentation.md?plain=1#L18

Today I spend some time for searching bug in this code:

public void MyMethod(...)
{
  XmlDocumentSyntax document = ...;
  document.ReplaceNode(...);
  return document;
}

Same code in Roslyn return diagnostic:

Warning	RS1014	'ClassDeclarationSyntax' is immutable and 'AddBaseListTypes' will not have any effect on it. Consider using the return value from 'AddBaseListTypes'.

Many objects exposed by Roslyn are immutable. The return value from a method invocation on these objects should not be ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions