SonarAnalyzer.VisualBasic S1172 with Option Strict On

I posted this before but didn’t realize that the issue is caused by Option Strict and the analyzer combined.

Using SonarAnalyzer.VisualBasic, VB.Net and .Net Framework 4.8.0.

The following causes a false positive:
S1172: Remove unused procedure parameter ‘SubArg’.

Public Class SurroundingClass
    Public Delegate Sub ErrorDelegate(Arg As String)
    Public Property Prop As ErrorDelegate

    Public Sub Unrelated()
        Prop = AddressOf ErrorSub
    End Sub

    Private Sub ErrorSub(SubArg As String) 'S1172 False positive here.
        Dim Stuff As Boolean
    End Sub
End Class

Removing the (SubArg As String) to satisfy S1172 causes:
BC36663: Option Strict On does not allow narrowing in implicit type conversions between method ‘Private Sub SubR()’ and delegate ‘Delegate Sub SurroundingClass.ErrorDelegate(Arg As String)’.

Hi @ATac ,

Thank you for reporting this case, I can confirm it as a False Postive. Here’s an issue that you can track:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.