The S1128 analyzer is useful to detect leftover usings, but our code standard allows for some default namespaces to always be there (to make intellisense more useful for developers). These include System, System.Linq, System.Collection.Generic etc.
Resharper has support for this, but we want to run the same analyzer on the dev machines as on the build server, and now we have to disable rule S1128 since generate tons of useless warnings.
I hope this will be opt-in, because I don't like the feature.
Hi @rickardp,
I am a little confused by your use-case. There are solutions to complete types and add the right using automatically (ex: Auto-Using for C#). What are the reasons for not using them and instead add unused using statements?
I ask this because this looks more like a tooling issue. It is usually not recommended to make the code more complex because of the tools you use.
Closing this issue as there was no answer from the user and this is not a real problem with the rule
@andrei-epure-sonarsource Sorry, I missed the notification on your previous response.
I agree this is more of a tooling issue, but the tool at hand (Visual Studio 2019) does not support this in its current version. In its default configuration, Visual Studio will not complete on Linq extension methods if the System.Linq using has been cleaned up, which is a pain since then you would have to type the full name of the method, then Ctrl+.
There is a workaround, which is to install Resharper that has cross-namespace completions. I personally prefer a "clean" visual studio, but many devs prefer to use Resharper, so I suppose this is a matter of taste. Anyway I realize this improvement suggestion is not for everyone, but it would have been great to have the choice.
EDIT: I realize now that Visual Studio in its latest update has gained the functionality in 16.5 (in preview). https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes-preview#intelliSense-completion-for-unimported-extension-methods
In addition, there's the Auto-Using for C# @nicolas-harraudeau-sonarsource mentioned. ReSharper is quite heavy-weight if used just for this purpose.
@andrei-epure-sonarsource Yes, there are plenty of solutions. I asked around in the dev teams here and most devs here either use vanilla VS or use a more customized environment (and those tend to prefer Resharper).
But since VS 2019 16.5 will get this functionality I think the usefulness of this feature request diminishes quite a lot.
Most helpful comment
Hi @rickardp,
I am a little confused by your use-case. There are solutions to complete types and add the right
usingautomatically (ex: Auto-Using for C#). What are the reasons for not using them and instead add unusedusingstatements?I ask this because this looks more like a tooling issue. It is usually not recommended to make the code more complex because of the tools you use.