All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.plugins.vbnet.S4260.html Maven / Gradle / Ivy

There is a newer version: 10.5.0.109200
Show newest version

Why is this an issue?

When creating a custom Markup Extension that accepts parameters in WPF, the ConstructorArgument markup must be used to identify the discrete properties that match these parameters. However since this is done via a string, the compiler won’t give you any warning in case there are typos.

This rule raises an issue when the string argument to ConstructorArgumentAttribute doesn’t match any parameter of any constructor.

How to fix it

Code examples

Noncompliant code example

Imports System

Namespace MyLibrary
    Public Class MyExtension
        Inherits MarkupExtension

        Public Sub New()
        End Sub

        Public Sub New(ByVal value1 As Object)
            Value1 = value1
        End Sub

        <ConstructorArgument("value2")> ' Noncompliant
        Public Property Value1 As Object
    End Class
End Namespace

Compliant solution

Imports System

Namespace MyLibrary
    Public Class MyExtension
        Inherits MarkupExtension

        Public Sub New()
        End Sub

        Public Sub New(ByVal value1 As Object)
            Value1 = value1
        End Sub

        <ConstructorArgument("value1")>
        Public Property Value1 As Object
    End Class
End Namespace

Resources

Documentation





© 2015 - 2025 Weber Informatics LLC | Privacy Policy