[Mono-bugs] [Bug 594905] New: Invalid Warnings generated: Warning CS1720: Expression will always cause a `System.NullReferenceException'

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Apr 8 13:12:55 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=594905

http://bugzilla.novell.com/show_bug.cgi?id=594905#c0


           Summary: Invalid Warnings generated: Warning CS1720: Expression
                    will always cause a `System.NullReferenceException'
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.6.x
          Platform: Macintosh
        OS/Version: Mac OS X 10.6
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jojo.rudolph at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: Yes


Occurs in conjunction with Extension Methods, that could very well handle null
Arguments.

Repro: (NUnit test case, will pass and thereby show the warning is incorrect)

        public static TSource MaxBy<TSource, TKey>(this IEnumerable<TSource>
source, Func<TSource, TKey> selector)
        {
            if (source == null) throw new ArgumentNullException();
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void MaxByNullSequence()
        {
            ((IEnumerable<string>)null).MaxBy(x => x.Length);
        }

CSC does not generate this warning, this should be the expected behavior.

-- 
Configure bugmail: http://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