Tech Off Thread

3 posts

Deprecate Class that's not mine

Back to Forum: Tech Off
  • User profile image
    ploe

    Is there a way to deprecate a C# class that isn't in my assembly?

     

    In our assembly, we have our own implementation of what the built in MessageBox class. It's called PopupBox. I'd like to discourage the use of MessageBox in our application. I thought a good way would be to make MessageBox deprecated so that it threw a compiler warning.

     

    If this isn't possible, can you suggest an alternative?

  • User profile image
    spivonious

    I don't think there's a way to do that. If it were me, I'd send an email around to the team.

  • User profile image
    wkempf

    No, there isn't. Nor should there be.

     

    That said, if you stop focusing on how to accomplish this and instead focus on what you're requirement is, there is an answer. You don't need to deprecate MessageBox, you just need to "discourage" it's use. If you're not already using it, turn on Code Analysis/FXCop. Then add a custom rule to produce a warning when MessageBox is used.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.