Questions tagged [ca1001]

3 questions
3
votes
1 answer

Why won't the GC automatically dispose my class's members?

When I build the following C++/CLI code in VS2008, a code analysis warning CA1001 is displayed. ref class A { public: A() { m_hwnd = new HWND; } ~A() { this->!A(); } protected: !A() { delete m_hwnd; } HWND* m_hwnd; }; ref class…
demoncodemonkey
  • 11,730
  • 10
  • 61
  • 103
2
votes
4 answers

Is CA1001: TypesThatOwnDisposableFieldsShouldBeDisposable Valid?

If I have the following code: public class Foo { public void Bar() { var someTypeWithAnEvent = new SomeTypeWithAnEvent(); using (var signal = new ManualResetEvent(false)) { …
Dougc
  • 843
  • 11
  • 20
1
vote
1 answer

Correct usage of Using for disposable types

I have this code using(MyStopWatch st= new MyStopWatch()) { St.start(); St.stop(); } Which gives me CA1001 error when I run fxcop And MyStopWatch st= null; using( st= new MyStopWatch()) { St.start(); St.stop(); } Which does not give any fxcop…
Kryptonian
  • 860
  • 3
  • 10
  • 26