diff --git a/Reporting/TestExecutionReport/TestExecutionReportGenerator.cs b/Reporting/TestExecutionReport/TestExecutionReportGenerator.cs index 26e9ec866..7be283ded 100644 --- a/Reporting/TestExecutionReport/TestExecutionReportGenerator.cs +++ b/Reporting/TestExecutionReport/TestExecutionReportGenerator.cs @@ -8,21 +8,22 @@ namespace TechTalk.SpecFlow.Reporting.TestExecutionReport public class TestExecutionReportGenerator { public void GenerateNUnitXmlFromGallio(string xmlTestResult) - { - XmlTextReader xmlTextReader = new ResourceXmlReader(Assembly.GetExecutingAssembly(), - "TechTalk.SpecFlow.Reporting.TestExecutionReport.Gallio2NUnit.xslt"); - - XDocument doc = XDocument.Load(xmlTestResult); - var tranny = new XslCompiledTransform(); - tranny.Load(xmlTextReader); - XmlReader reader = doc.CreateReader(); - const string outputFileName = "TestResult.xml"; - XmlWriter writer = XmlWriter.Create(outputFileName); - - if (writer != null) + { + using (XmlTextReader xmlTextReader = new ResourceXmlReader(Assembly.GetExecutingAssembly(), + "TechTalk.SpecFlow.Reporting.TestExecutionReport.Gallio2NUnit.xslt")) { - tranny.Transform(reader, writer); - writer.Close(); + XDocument doc = XDocument.Load(xmlTestResult); + var tranny = new XslCompiledTransform(); + tranny.Load(xmlTextReader); + XmlReader reader = doc.CreateReader(); + const string outputFileName = "TestResult.xml"; + XmlWriter writer = XmlWriter.Create(outputFileName); + + if (writer != null) + { + tranny.Transform(reader, writer); + writer.Close(); + } } } }