-
Notifications
You must be signed in to change notification settings - Fork 228
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
Fix S1144 FP: types used through reflection #9406
Fix S1144 FP: types used through reflection #9406
Conversation
15bdbcd
to
88f6d11
Compare
analyzers/src/SonarAnalyzer.CSharp/Helpers/CSharpSymbolUsageCollector.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Helpers/CSharpSymbolUsageCollector.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Helpers/CSharpSymbolUsageCollector.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Helpers/CSharpSymbolUsageCollector.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Helpers/CSharpSymbolUsageCollector.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Helpers/CSharpSymbolUsageCollector.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.Test/TestCases/UnusedPrivateMember.CSharp9.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It generally looks fine. It misses some UTs that might be worth adding. Feel free not to add them if you think it's not worth it.
analyzers/src/SonarAnalyzer.CSharp/Helpers/CSharpSymbolUsageCollector.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Helpers/CSharpSymbolUsageCollector.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.Test/TestCases/UnusedPrivateMember.CSharp9.cs
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.Test/TestCases/UnusedPrivateMember.CSharp9.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.Test/TestCases/UnusedPrivateMember.CSharp9.cs
Show resolved
Hide resolved
I removed the check through type parameters, because it nearly doubled the analysis time. |
How did you measure? If the rule was very, very fast, duplication is not a problem. Can you post some more info about the perf validation? |
analyzers/tests/SonarAnalyzer.Test/TestCases/UnusedPrivateMember.CSharp9.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.Test/TestCases/UnusedPrivateMember.CSharp9.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Helpers/CSharpSymbolUsageCollector.cs
Outdated
Show resolved
Hide resolved
I used the AnalyzerRunner from the Roslyn repo to compare the performance with and without the check for type parameters. I ran it on AutoMapper, Akka.Net, and an earlier version of the Roslyn repo. They all showed a degradation in performance ranging between 40% and 90%.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also update the RSpec? It needs the DynamicallyAccessedMembersAttribute
in the exception section. Consider only checking only the name of the attribute instead of namespace/name. This would allow users to create this attribute in unsupported platforms (which is every platform except Net5 upwards). The name is long enough to not be confused with anything else. If you go that route, tests are needed.
analyzers/packaging/output/Akka.API.Tests/net471/SonarProjectConfig.xml
Outdated
Show resolved
Hide resolved
70938b8
to
667d9fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I think a comment is helpful in this case.
analyzers/src/SonarAnalyzer.CSharp/Helpers/CSharpSymbolUsageCollector.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Helpers/CSharpSymbolUsageCollector.cs
Outdated
Show resolved
Hide resolved
Quality Gate passed for 'Sonar .NET Java Plugin'Issues Measures |
Quality Gate passed for 'SonarAnalyzer for .NET'Issues Measures |
Fixes #9379
RSpec change: SonarSource/rspec#3992