SonarAnalyzer.VisualBasic S1172 false positive for necessary unused procedure parameters

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

It’s saying that certain unused procedure parameters should be removed (S1172) but they need to stay to conform to the required format.
I’ve been either suppressing the warning or using the unused procedures unnecessarily.

Basic class example:

Imports System.ComponentModel
Public Class FalsePositive
    Inherits DependencyObject
    Implements INotifyPropertyChanged

    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged

    Public Property DP() As Object
            Return GetValue(DPProperty)
        End Get
        Set(Value As Object)
            SetValue(DPProperty, Value)
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(NameOf(DP)))
        End Set
    End Property

    Public Shared ReadOnly DPProperty As DependencyProperty = DependencyProperty.Register("DP", GetType(Object), GetType(FalsePositive),
                                                                                            New FrameworkPropertyMetadata(Nothing, FrameworkPropertyMetadataOptions.None,
                                                                                                                          New PropertyChangedCallback(AddressOf DPChanged),
                                                                                                                          New CoerceValueCallback(AddressOf CoerceDP)))

    Private Shared Sub DPChanged(d As DependencyObject, e As DependencyPropertyChangedEventArgs)
        Dim Field As Object
    End Sub

    Private Shared Function CoerceDP(d As DependencyObject, Value As Object) As Object
        Return Nothing
    End Function
End Class

Not the most practical example but it occurs four times in this code.

Hi @ATac ,

Thank you for reporting this case. It has the same root cause as the other thread you’ve posted SonarAnalyzer.VisualBasic S1172 with Option Strict On and should be fixed with the same issue as well Fix S1172 FP: Method used with AddressOf operator VB.NET · Issue #5185 · SonarSource/sonar-dotnet · GitHub.

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