Skip to content

Fix S1215 FN: GC.GetTotalMemory(forceFullCollection: true) should not be called #9687

Closed
@fiotti

Description

@fiotti

Description

GC.GetTotalMemory(forceFullCollection: true) calls GC.Collect() internally.

It might make sense to consider it equivalent to GC.Collect() and trigger a S1215.

Repro steps

GC.Collect(); // S1215: Refactor the code to remove this use of 'GC.Collect'.

GC.GetTotalMemory(true); // No warning.

Expected behavior

GC.Collect(); // S1215: Refactor the code to remove this use of 'GC.Collect'.

GC.GetTotalMemory(true); // S1215: Refactor the code to remove this use of 'GC.GetTotalMemory', or do not set 'forceFullCollection' to true.

Actual behavior

No warning.

Known workarounds

None.

Related information

  • SonarLint for Visual Studio 2022 v8.5.0.10497

Metadata

Metadata

Assignees

No one assigned

    Labels

    False NegativeRule is NOT triggered when it should be.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions