Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ericstj opened this issue Sep 24, 2024 · 1 comment
Open

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

ericstj opened this issue Sep 24, 2024 · 1 comment
Labels
area-System.Runtime code-analyzer Marks an issue that suggests a Roslyn analyzer needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Milestone

Comments

@ericstj
Copy link
Member

ericstj commented Sep 24, 2024

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.

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Sep 24, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Sep 24, 2024
@teo-tsirpanis teo-tsirpanis added area-System.Runtime code-analyzer Marks an issue that suggests a Roslyn analyzer and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Sep 24, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

@jeffhandley jeffhandley added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed untriaged New issue has not been triaged by the area owner labels Sep 30, 2024
@jeffhandley jeffhandley added this to the Future milestone Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Runtime code-analyzer Marks an issue that suggests a Roslyn analyzer needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Projects
None yet
Development

No branches or pull requests

3 participants