There are many questions that SO is mourned by the fact that the CA2000 code analysis rule is applied too strictly VS2010, but I seem to have come across a situation where it should be applied, but it is not.
Consider the following code:
Image srcImage = Image.FromFile(source); Bitmap newImage = new Bitmap(newWidth, newHeight); using (Graphics gr = Graphics.FromImage(newImage)) { gr.DrawImage(srcImage, new Rectangle(0, 0, newWidth, newHeight)); } newImage.Save(destination, ImageFormat.Jpeg);
Now, if I run Code Analysis in Visual Studio 2010, it will complain about newImage , which will not be deleted (easy to fix, put it in another block), but it does not complain about srcImage (which also has the Dispose () method, which I never I do not call). Does anyone know why Code Analysis is not complaining here?
source share