Skip to content

[Analyzer Proposal]: warn when calling GetType() on a System.Type #108200

Open
@ericstj

Description

@ericstj

I've noticed a few times where folks make a mistake through refactoring or copy-paste (or AI hallucinations) where they call GetType() on a System.Type object. This doesn't cause any compile errors since System.Type is an object and therefore has a GetType() method - but it's more often the wrong thing to do than not.

I suggest we add an analyzer that warns folks when they do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Runtimecode-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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions