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

  • Home
  • SEARCH
  • 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 7078319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:31:59+00:00 2026-05-28T06:31:59+00:00

I have some code that will trigger Code Analysis warning CA1063: CA1063 : Microsoft.Design

  • 0

I have some code that will trigger Code Analysis warning CA1063:

CA1063 : Microsoft.Design : Remove IDisposable from the list of interfaces implemented by ‘Functionality’ and override the base class Dispose implementation instead.

However, I’m not sure what I need to do to fix this warning.

Briefly, I have an interface IFunctionality that derives from IDisposable. Class Functionality implements IFunctionality but derives from class Reusable to be able to reuse som code. Class Reusable also derives from IDisposable.

public class Reusable : IDisposable {

  ~Reusable() {
    Dispose(false);
  }

  public void Dispose() {
    Dispose(true);
    GC.SuppressFinalize(this);
  }

  protected virtual void Dispose(Boolean disposing) {
    // ...
  }

  public void DoSomething() {
    // ...
  }

}

public interface IFunctionality : IDisposable {

  void DoSomething();

  void DoSomethingElse();

}

public class Functionality : Reusable, IFunctionality {

  public void DoSomethingElse() {
    // ...
  }

#if WORK_AROUND_CA1063
  // Removes CA1063
  protected override void Dispose(Boolean disposing) {
    base.Dispose(disposing);
  }
#endif

}

I can get rid of the warning by overriding Dispose on Functionality and calling the base class Dispose even though doing that should not change the semantics of the code .

So is there something about IDisposable in this context I have overlooked or is it just CA1063 that misfires for this particular construct?

I know that I can suppress CA1063 but the rule is quite broad and I don’t want to miss any other problems in implementing IDisposable reported by this rule.

  • 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. Editorial Team
    Editorial Team
    2026-05-28T06:31:59+00:00Added an answer on May 28, 2026 at 6:31 am

    This is a false positive due to a minor bug in the rule itself. When trying to figure out if a class re-implements IDisposable (after figuring out that there’s a base class implementation that could be overridden), it only looks at whether the class’ interfaces include IDisposable. Unfortunately, the interface list that shows up in the assembly metadata includes the “exploded” list of interfaces, including any interfaces inherited via interfaces that the class explicitly implements in the original C# code. This means that FxCop is seeing a declaration that looks like the following for your Functionality class:

    public class Functionality : Reusable, IFunctionality, IDisposable
    {
        ...
    }
    

    Given this metadata representation, the ImplementIDisposableCorrectly rule should be a bit more intelligent about how it attempts to determine whether the class is actually re-implementing IDisposable (for example, by looking for an explicit Dispose() implementation if the base class has an overridable Dispose(bool)). However, given that the rule doesn’t do this, your best approach is to suppress the false positives.

    BTW, I would recommend seriously considering using SuppressMessageAttribute for suppressing the false positives instead of your current conditional compilation approach. e.g.:

    [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly",
        Justification = "False positive.  IDisposable is inherited via IFunctionality.  See http://stackoverflow.com/questions/8925925/code-analysis-ca1063-fires-when-deriving-from-idisposable-and-providing-implemen for details.")]
    public class Functionality : Reusable, IFunctionality
    {
        ...
    }
    

    Also, you might want to seriously consider getting rid of the finalizer…

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

Sidebar

Related Questions

I have some code that will be accessed from two threads: class Timer{ public:
Does anyone have some code that will take a TimeZoneInfo field from .NET and
I currently have some code that will produce a crash dump when my application
I have some Javascript code that will programmatically register an COM interop assembly by
I have some code that at one part will get executed a lot, and
I have some code that compiles and runs on MSVC++ but will not compile
I have some code in method C that will get executed based upon the
I’m after some C# code that will have the following methods that will return
I have two jQuery datepickers that once changed, will trigger some ajax to grab
I have some code that gives a user id to a utility that then

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.