Skip to content

New Rules for Lock class usage and to avoid public usage of lock (this) #106907

@elachlan

Description

@elachlan

Describe the problem you are trying to solve

In C#13 there is a new system.threading.lock class (dotnet/csharplang#7104). It may be more performant to use over a standard object lock. An analyzer that identifies object properties which are exclusively used for locking and suggests using the new Lock class instead, with a code fix.

Additionally, it would be nice to have a rule that identifies usages of lock (this) inside public classes to discourage the practice.

Additional context

References:

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-Metacode-analyzerMarks an issue that suggests a Roslyn analyzerneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions