From e25131416e82bdd8ea19ef37ebafa9d6d8edee35 Mon Sep 17 00:00:00 2001 From: Simon Whittemore Date: Wed, 12 May 2010 17:33:37 +0100 Subject: [PATCH] let's be good citizen's and clear up after ourselves --- .../TestExecutionReportGenerator.cs | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) 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(); + } } } }