sonar-dotnet
sonar-dotnet copied to clipboard
Fix S2368 FN: inline arrays
An array of an inline array, while not being explicitly defined as a multidimensional or jagged array, has the same memory layout of those. Moreover, it is accessed in the same way (via double []
), and can be as "challenging for developers" (as mentioned by the RSPEC of S2368) and unintuitive as normal multidimensional arrays (c.p. this discussion).
For these reasons, S2368 should report on them.
public void AMethod1(Buffer[] a) { } // FN, Buffer[] is 2-dimensional
public void AMethod2(params Buffer[] a) { } // Compliant, params of Buffer
public void AMethod3(params Buffer[][] a) { } // Noncompliant, params of Buffer[]
Related issues:
- https://github.com/SonarSource/sonar-dotnet/issues/8083
Testing of this issue requires the UnitTest project to work with .NET 8, that is currently not possible due to issue described in this Trello card.