Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 159375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:50:52+00:00 2026-05-11T10:50:52+00:00

The Framework Design Guidelines (2nd Ed., page 327) say: CONSIDER providing method Close() ,

  • 0

The Framework Design Guidelines (2nd Ed., page 327) say:

CONSIDER providing method Close(), in addition to the Dispose(), if close is standard terminology in the area.

When doing so, it is important that you make the Close implementation identical to Dispose and consider implementing IDisposable.Dispose method explicitly.

So, following the provided example, I’ve got this class:

public class SomeClass : IDisposable {     private SomeDisposable someInnerDisposable;      public void Open() {         this.someInnerDisposable = new SomeDisposable();     }      void IDisposable.Dispose() {         this.Close();     }      public void Close() {         this.Dispose(true);         GC.SuppressFinalize(this);     }      protected virtual void Dispose(bool disposing) {         if (disposing) {             this.someInnerDisposable.Dispose();             this.someInnerDisposable = null;         }     } } 

FxCop doesn’t seem to like that:

CA1816 : Microsoft.Usage : ‘SomeClass.Close()’ calls ‘GC.SuppressFinalize(object)’, a method that is typically only called within an implementation of ‘IDisposable.Dispose’. Refer to the IDisposable pattern for more information.

CA1816 : Microsoft.Usage : Change ‘SomeClass.IDisposable.Dispose()’ to call ‘GC.SuppressFinalize(object)’. This will prevent unnecessary finalization of the object once it has been disposed and it has fallen out of scope.

CA1063 : Microsoft.Design : Modify ‘SomeClass.IDisposable.Dispose()’ so that it calls Dispose(true), then calls GC.SuppressFinalize on the current object instance (‘this’ or ‘Me’ in Visual Basic), and then returns.

CA1063 : Microsoft.Design : Rename ‘SomeClass.IDisposable.Dispose()’ to ‘Dispose’ and ensure that it is declared as public and sealed.

  • How do I implement the dispose pattern with close method correctly?

-or-

  • How do I suppress the warnings?

I tried

[SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly",     Justification = "Framework Design Guidelines say it's ok.")] void IDisposable.Dispose() {     this.Close(); } 

but FxCop 1.36 still reports them.

EDIT: Changing it around as suggested eliminates all but this warning:

CA1063 : Microsoft.Design : Rename ‘SomeClass.IDisposable.Dispose()’ to ‘Dispose’ and ensure that it is declared as public and sealed.

EDIT 2: CODE_ANALYSIS was indeed missing. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:50:53+00:00Added an answer on May 11, 2026 at 10:50 am

    Change it around.

    Have Close() call this.Dispose() and put the logic in the Dispose() method instead of the Close() method.

    ——————- Further info after edit —————

    Also, changing the declaration to:

    public void Dispose() 

    should get rid of the other error. Since you have it declared as:

    void IDisposable.Dispose() 

    It’s not marked as public and sealed, and FxCop complains. Personally, I prefer to get avoid the errors instead of suppressing them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 75k
  • Answers 75k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I've solved this by leveraging the fact that any CLR… May 11, 2026 at 2:43 pm
  • added an answer Is the function late bound / has a Variant return… May 11, 2026 at 2:43 pm
  • added an answer Calling [viewController view] will make sure that a given view… May 11, 2026 at 2:43 pm

Related Questions

After going through the Appendix A, C# Coding Style Conventions of the great book
Microsoft has naming guidelines on their website ( here ). Also I have the
A friend was having trouble figuring out how to assign Ctrl + + as
I remember reading once (I believe the book was the .NET Framework Design Guidelines)

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.