I've been trying to find over the internet if it was possible to disable the use of the messagebox.show()
function, but so far I haven't found anything useful.
The reason I want to do this is quite simple, in my opinion; I'm starting a new project, where other people will be doing code over the next few years. I've created a new class to handle all of the messages shown to the user, which does a little more than just sending a message to the user. But I want to make sure that this will be the class used, 开发者_开发知识库when a programmer other than me works on the project.
So is there a way to show an error in the visual studio's error list to the programmer? Or any other way to make sure that my message class will be used?
The only option I'm aware of is to use a custom code analysis rule: http://blog.tatham.oddie.com.au/2010/01/06/custom-code-analysis-rules-in-vs2010-and-how-to-make-them-run-in-fxcop-and-vs2008-too/
If the code analysis rule suggested by Chris isn't enough for you, consider using an AOP (aspect oriented programming) toolkit, such as PostSharp. It allows you to intercept and replace all calls made to Messagebox.Show() with your own code (presumably redirecting it to your implementation).
Note that it might be too heavy-handed for your purposes.
精彩评论