Преглед изворни кода

Revert "Fix potential for double dispose when saving settings file."

This reverts commit ad1c3aefb007d461d5ab3a90858d3b5755785063.
Stephen Damm пре 5 година
родитељ
комит
d1adfaec62
1 измењених фајлова са 1 додато и 10 уклоњено
  1. 1 10
      SongBrowserPlugin/DataAccess/SongBrowserSettings.cs

+ 1 - 10
SongBrowserPlugin/DataAccess/SongBrowserSettings.cs

@@ -334,22 +334,13 @@ namespace SongBrowser.DataAccess
                 NewLineHandling = System.Xml.NewLineHandling.Entitize
             };
 
-            // https://docs.microsoft.com/en-gb/visualstudio/code-quality/ca2202-do-not-dispose-objects-multiple-times?view=vs-2015
-            StreamWriter stream = null;
-            try
+            using (var stream = new StreamWriter(path, false, Utf8Encoding))
             {
-                stream = new StreamWriter(path, false, Utf8Encoding);
                 using (var writer = XmlWriter.Create(stream, settings))
                 {
-                    stream = null;
                     SettingsSerializer.Serialize(writer, this);
                 }
             }
-            finally
-            {
-                if (stream != null)
-                    stream.Dispose();
-            }
         }
     }
 }