I’m reviewing some code and I thought it would be useful for Visual Studio to throw a warning anytime an SPWeb or SPSite object is initiated without using “using(SPSite x = …){}”.
Is there a way to configure this in Visual Studio?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Sometimes you need to dispose (e.g. var site = new SPSite()), sometimes you should not dispose (e.g. var web = site.RootWeb). So you can’t do warnings based on absolutes.
Your best bet is to use SPDisposeCheck.