diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index fb34312..94ea338 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -1,6 +1,13 @@
# Release Notes
-## XMLUnit.NET 2.8.1 - /not released, yet/
+## XMLUnit.NET 2.9.0 - /not released, yet/
+
+* `ISource` now extends `IDisposable` to allow releasing unmanaged
+ resources used when building sources from files or URIs.
+
+ This change is backwards incompatible if you are providing `ISource`
+ implementations of your own.
+ [#33](https://github.com/xmlunit/xmlunit.net/pull/33).
## XMLUnit.NET 2.8.0 - /Released 2020-05-12/
diff --git a/appveyor.yml b/appveyor.yml
index 31a3ac4..e054d41 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,4 +1,4 @@
-version: 2.8.1.{build}
+version: 2.9.0.{build}
image:
- Visual Studio 2013
diff --git a/src/doc/monodoc/core/index.xml b/src/doc/monodoc/core/index.xml
index 1f718e0..32eb6f8 100644
--- a/src/doc/monodoc/core/index.xml
+++ b/src/doc/monodoc/core/index.xml
@@ -45,5 +45,5 @@
under the
Apache License, Version 2.0.
-
XMLUnit.NET 2.8.1-alpha-01
+ XMLUnit.NET 2.9.0-alpha-01
diff --git a/src/main/net-core/ISource.cs b/src/main/net-core/ISource.cs
index 58b856d..ca08922 100644
--- a/src/main/net-core/ISource.cs
+++ b/src/main/net-core/ISource.cs
@@ -18,7 +18,7 @@ namespace Org.XmlUnit {
/// Representation of the various ways to provide pieces of XML to
/// XMLUnit.
///
- public interface ISource {
+ public interface ISource : System.IDisposable {
///
/// Provides the content.
///
diff --git a/src/main/net-core/Input/AbstractSource.cs b/src/main/net-core/Input/AbstractSource.cs
index 0c7918d..8ed502f 100644
--- a/src/main/net-core/Input/AbstractSource.cs
+++ b/src/main/net-core/Input/AbstractSource.cs
@@ -21,6 +21,7 @@ namespace Org.XmlUnit.Input
///
public abstract class AbstractSource : ISource
{
+ private bool disposed;
private string systemId;
private readonly XmlReader reader;
///
@@ -61,5 +62,16 @@ public override string ToString()
return string.Format("{0} with systemId {1}", GetType().Name,
SystemId);
}
+
+ public void Dispose() {
+ Dispose(false);
+ }
+
+ protected virtual void Dispose(bool disposing) {
+ if (!disposed) {
+ reader.Close();
+ disposed = true;
+ }
+ }
}
}
diff --git a/src/main/net-core/Input/ByteArraySource.cs b/src/main/net-core/Input/ByteArraySource.cs
index 8b36a61..9855505 100644
--- a/src/main/net-core/Input/ByteArraySource.cs
+++ b/src/main/net-core/Input/ByteArraySource.cs
@@ -59,5 +59,7 @@ public override string ToString()
{
return string.Format("ByteArraySource with systemId {0}", SystemId);
}
+
+ public void Dispose() { }
}
}
diff --git a/src/main/net-core/Input/CommentLessSource.cs b/src/main/net-core/Input/CommentLessSource.cs
index 5bae3a8..4986982 100644
--- a/src/main/net-core/Input/CommentLessSource.cs
+++ b/src/main/net-core/Input/CommentLessSource.cs
@@ -31,6 +31,7 @@ namespace Org.XmlUnit.Input {
///
///
public sealed class CommentLessSource : ISource {
+ private bool disposed;
private readonly XmlReader reader;
private string systemId;
@@ -100,6 +101,13 @@ public string SystemId
}
}
+ public void Dispose() {
+ if (!disposed) {
+ reader.Close();
+ disposed = true;
+ }
+ }
+
private static ISource GetStylesheet(string xsltVersion) {
return new StreamSource(new System.IO.StringReader(GetStylesheetContentCached(xsltVersion)));
}
diff --git a/src/main/net-core/Input/NormalizedSource.cs b/src/main/net-core/Input/NormalizedSource.cs
index 4d50a64..5f14e5c 100644
--- a/src/main/net-core/Input/NormalizedSource.cs
+++ b/src/main/net-core/Input/NormalizedSource.cs
@@ -36,6 +36,7 @@ namespace Org.XmlUnit.Input {
///
///
public class NormalizedSource : ISource {
+ private bool disposed;
private string systemId;
private readonly XmlReader reader;
private readonly XmlNode node;
@@ -107,5 +108,16 @@ public override string ToString()
return string.Format("{0} with systemId {1}", GetType().Name,
SystemId);
}
+
+ public void Dispose() {
+ Dispose(false);
+ }
+
+ protected virtual void Dispose(bool disposing) {
+ if (!disposed) {
+ reader.Close();
+ disposed = true;
+ }
+ }
}
}
diff --git a/src/main/net-core/Input/StringSource.cs b/src/main/net-core/Input/StringSource.cs
index bc28990..7f1f625 100644
--- a/src/main/net-core/Input/StringSource.cs
+++ b/src/main/net-core/Input/StringSource.cs
@@ -60,5 +60,7 @@ public override string ToString()
return string.Format("StringSource with content{0} and systemId {1}", content,
SystemId);
}
+
+ public void Dispose() { }
}
}
diff --git a/src/shared/CommonAssemblyInfo.cs b/src/shared/CommonAssemblyInfo.cs
index 8a4ef47..fc63347 100644
--- a/src/shared/CommonAssemblyInfo.cs
+++ b/src/shared/CommonAssemblyInfo.cs
@@ -25,7 +25,7 @@ namespace Org.XmlUnit
{
internal static class XmlUnitVersion
{
- internal const string ApiVersion = "2.8.1";
+ internal const string ApiVersion = "2.9.0";
internal const string AssemblyVersion = ApiVersion + ".198";
internal const string Version = ApiVersion + "-alpha-01";
}