Skip to content

Commit ca33534

Browse files
authored
PR #445: Make InvalidHeaderException serializable
1 parent 274df70 commit ca33534

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/ICSharpCode.SharpZipLib/Tar/InvalidHeaderException.cs

+18
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using System;
2+
using System.Runtime.Serialization;
23

34
namespace ICSharpCode.SharpZipLib.Tar
45
{
56
/// <summary>
67
/// This exception is used to indicate that there is a problem
78
/// with a TAR archive header.
89
/// </summary>
10+
[Serializable]
911
public class InvalidHeaderException : TarException
1012
{
1113
/// <summary>
@@ -33,5 +35,21 @@ public InvalidHeaderException(string message, Exception exception)
3335
: base(message, exception)
3436
{
3537
}
38+
39+
/// <summary>
40+
/// Initializes a new instance of the InvalidHeaderException class with serialized data.
41+
/// </summary>
42+
/// <param name="info">
43+
/// The System.Runtime.Serialization.SerializationInfo that holds the serialized
44+
/// object data about the exception being thrown.
45+
/// </param>
46+
/// <param name="context">
47+
/// The System.Runtime.Serialization.StreamingContext that contains contextual information
48+
/// about the source or destination.
49+
/// </param>
50+
protected InvalidHeaderException(SerializationInfo info, StreamingContext context)
51+
: base(info, context)
52+
{
53+
}
3654
}
3755
}

test/ICSharpCode.SharpZipLib.Tests/Serialization/SerializationTests.cs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class SerializationTests
2323
[Category("Serialization")]
2424
[TestCase(typeof(BZip2Exception))]
2525
[TestCase(typeof(GZipException))]
26+
[TestCase(typeof(InvalidHeaderException))]
2627
[TestCase(typeof(InvalidNameException))]
2728
[TestCase(typeof(LzwException))]
2829
[TestCase(typeof(SharpZipBaseException))]

0 commit comments

Comments
 (0)