Hello, we have this code smell raised, this is invalid (recent C# upates, shortcuts in writting constructors).
What is the best way to not have this code smell reported ?
Hi Bertrand, apologies for the delayed reply. The issues are raised because SonarC# does not support C# 7.* syntax yet and we cannot detect that the fields are actually assigned using the tuple decomposition syntax.
There are few ways to hide the issues:
- review all issues and mark them as
Won't fix
using the SonarQube UI (this will also prevent them from showing in SonarLint for Visual Studio if you are using the latest version). - surround the field declarations with pragma to locally disable the rule
- disable the rule in general (not recommended)
All of these are just workarounds for the well known limitation in SonarC#. Unfortunately it will take us some time to provide full support for C# 7+, but recently we made good progress validating it could be done without breaking the compatibility with the earlier versions of Visual Studio 2015 and 2017. So far I cannot say when we are going to start delivering the first support for C# 7 (hopefully in the coming weeks), but we are well aware this is problem for our users and it is high on our priority list.
Thank you very much Valeri. This is very clear.
We’ll do that and be looking forward to C# 7 compatibility. (we fully understand it takes time to follow every language new changes)