[Mono-bugs] [Bug 667418] CheckParametersNullityInVisibleMethodsRule fix leads to AvoidCodeDuplicatedInSameClassRule break in VB

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Feb 9 19:18:21 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=667418

https://bugzilla.novell.com/show_bug.cgi?id=667418#c1


Sebastien Pouliot <spouliot at novell.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |spouliot at novell.com

--- Comment #1 from Sebastien Pouliot <spouliot at novell.com> 2011-02-10 00:18:20 UTC ---
So the pattern in VB looks like:

Sub Foo (ByVal bar As Bar)
    If Information.IsNothing (bar) Then
        Throw New ArgumentNullException ("bar")
    End If
    ...
End Sub

which, translated in C#, would be:

void Foo (Bar bar)
{
    if (Information.IsNothing (bar))
        throw new ArgumentNullException ("bar");
    ....
}

instead of the more common (at least in C# ;-):

void Foo (Bar bar)
{
    if (bar == null)
        throw new ArgumentNullException ("bar");
    ....
}

Adding a call to Information.IsNothing makes the code "large enough" to be
considered a pattern. In turns this means many methods will have the same
pattern and the rule will report them.

For a short term solution I believe you could do the same "direct" (no call)
null-check in VB.NET, which would not report defects. Ideally we would ignore
it (but that could be complex or maybe, gasp, a special "VB-case"). I'll look
into this again once 2.10 is released.

Thanks for the test cases :-)

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list