Skip to content
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

.NET 8 and C# 12: fix repros and UTs for rules starting with P in SonarWay #8118

Merged
merged 8 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class NullCoalescingAssignment
{
IEnumerable<int> NullableInlineArray(int? i) // FN
{
_ = i ?? throw new ArgumentNullException(nameof(i));
i ??= throw new ArgumentNullException(nameof(i));

yield return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public SomeClass()

namespace Repro_8072
{
public class Lambdas
class Lambdas
{
Func<int, int, int> F1 = (int a, int b) => a + b;

Expand All @@ -43,9 +43,9 @@ void InvokedFromLocalFunction()
var f1 = (int a, int b) => a + b;
var f2 = (int a, int b, int c) => a + b + c;

int FullyInverted(int a, int b) => f1(b, a);
int FullyInvertedWithAdditionalParamAfter(int a, int b, string c) => f1(b, a);
int FullyInvertedWithAdditionalParamBefore(string c, int a, int b) => f1(b, a);
int FullyInverted(int a, int b) => f1(b, a); // FN
int FullyInvertedWithAdditionalParamAfter(int a, int b, string c) => f1(b, a); // FN
int FullyInvertedWithAdditionalParamBefore(string c, int a, int b) => f1(b, a); // FN

int PartiallyInvertedFirstAndSecond(int a, int b, int c) => f2(b, a, c); // FN
int PartiallyInvertedFirstAndLast(int a, int b, int c) => f2(c, b, a); // FN
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
using System;

namespace Tests.Diagnostics
{
public interface IInterface
{
static virtual void SomeMethod(int a, int b) { } // Secondary
}

public class SomeClass<T> where T : IInterface
{
public SomeClass()
{
int a = 1;
int b = 2;

T.SomeMethod(b, a); // Noncompliant
}
}
}

// https://github.com/SonarSource/sonar-dotnet/issues/8071
namespace Repro_8071
{
Expand Down