Open andrei-epure-sonarsource opened 3 years ago
Improving performance is a good thing! Personally I value this rule highly, as it potentially removes a lot of code, which makes code easier to read. Visual Studio also has tooling for this, I'm not sure if sonar can build on top of that (might help performance wise).
I agree that performance is important, @Corniel. As our analyzers are used on CI systems, as well as local builds outside the IDE - we cannot rely on Visual Studio. It would be interesting to see their implementation, though.
This rule needs complete redesign. New idea:
using
statement. FileStream
from using System.IO;
)Leaving this here as an FYI:
Global using retrieval will be available from MSBuild version 17.3 onwards through this API, exposed via semanticModel.GetImportScopes
.
S1128 (UnnecessaryUsings) is a code smell which doesn't bring a lot of functional value, so we don't want it to have a big performance impact on the msbuild time.
We should re-think how we use the Semantic Model inside the rule, in order to improve the performance.
From this investigation, the rule takes 38 seconds to run - 4%.