[Mono-bugs] [Bug 667325] New: TypesWithDisposableFieldsShouldBeDisposableRule doesn't detect fields which are instantiated with a ctor of a more derived class than its compile time type

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Jan 26 11:04:16 EST 2011


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

https://bugzilla.novell.com/show_bug.cgi?id=667325#c0


           Summary: TypesWithDisposableFieldsShouldBeDisposableRule
                    doesn't detect fields which are instantiated with a
                    ctor of a more derived class than its compile time
                    type
    Classification: Mono
           Product: Mono: Tools
           Version: 2.10.x
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Gendarme
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: knocte at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; es-ES; rv:1.9.2.13)
Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13

TypesWithDisposableFieldsShouldBeDisposableRule doesn't detect fields which are
instantiated with a ctor of a more derived class than its compile time type

Testcase:

    interface ISomeInterface
    {
        string Name { get;  }
    }

    class A
    {
        private ISomeInterface someMember;

        public ISomeInterface SomeMember {
            get {
                if (someMember == null)
                    someMember = new B();
                return someMember;
            }
        }
    }

    class B : ISomeInterface, IDisposable
    {
        private FileStream stream;

        public string Name { get { return "test"; } }
        public B () {
            stream = new FileStream("whatever", FileMode.Append);
        }

        public void Dispose()
        {
            if (stream != null)
                stream.Dispose();
        }
    }

Discussed in:

http://groups.google.com/group/gendarme/browse_thread/thread/a203238210bf9da7

Reproducible: Always

-- 
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