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
If this isn't possible, can you suggest an alternative?
I don't think there's a way to do that. If it were me, I'd send an email around to the team.
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 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.