bool B { get; set; }
void M()
{
var v = B ? true : null; // S1125 on this line
}
In previous versions of C#, B ? true : null would not have compiled and required an explicit cast like: B ? (bool?)true : null. This rule does not trigger if you include the explicit cast, but now in C# 9 this cast is no longer necessary.
This issue is present in the SonarAnalyzer.CSharp nuget package version 8.30.0.37606
With your snippet I cannot reproduce the issue as the snippet does not compile. However I found a false positive and opened an issue for the following case:
bool B { get; set; }
void M()
{
bool? v = B ? true : null; // S1125 on this line
}