dotnet / roslyn-analyzers

MIT License
1.58k stars 463 forks source link

New Roslyn meta analyzer: avoid dynamic objects #1573

Open sharwell opened 6 years ago

sharwell commented 6 years ago

Analyzer package

Microsoft.CodeAnalysis.Analyzers

Analyzer

Avoid dynamic objects (new analyzer)

Expected behavior

This analyzer reports cases where an object of type dynamic is used for any operation aside from casting to object. This rule helps avoid performance regressions like that seen in dotnet/roslyn#24722.

Evangelink commented 4 years ago

@sharwell when you say any operation you mean any cast from dynamic to something else or really any operation with dynamics meaning that a lot of things would be flagged when working with excel or other tools?

sharwell commented 4 years ago

@Evangelink All uses of dynamic would be flagged. This would be a Roslyn meta analyzer, meaning it's only used when working in dotnet/roslyn.

Evangelink commented 4 years ago

@sharwell I have a small side question. You are talking about a Roslyn Meta Analyzer, which according to https://github.com/dotnet/roslyn-analyzers/blob/master/src/Utilities/Compiler/DiagnosticCategoryAndIdRanges.txt shall have an ID between RS0000-RS0999 and in your first comment you are talking about the Microsoft.CodeAnalysis.Analyzers project. I think it should be in Roslyn.Diagnostics.Analyzers, isn't it?

sharwell commented 4 years ago

I think it should be in Roslyn.Diagnostics.Analyzers, isn't it?

Yes this is correct