Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Deprecate Class that's not mine

Back to Forum: Tech Off
  • User profile image

    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

    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

    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.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.