Scan not flagging code from non-compliant example

I took the non-compliant code example from a rule page, and put it into a dotnet core project. On scanning, sonar does not flag the non-compliant code with a code smell.

dotnet-sonarscanner version 4.9.0
sonarqube version:

Hello @foragerr,

I just did it now with the latest version of the C# analyzer:

It works as expected.

You figured out that this rule is not enabled by default so you have to create a Quality Profile to enable it, right? Other than that, it’s likely your analysis which is misconfigured or something.