Skip to content

Commit 7f1f2b4

Browse files
committed
C#: Fix GetHashCode/Equals on EscapingTextWriter
1 parent ca89560 commit 7f1f2b4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

csharp/extractor/Semmle.Extraction/EscapingTextWriter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Semmle.Extraction
1111
/// HTML escapes the characters `&`, `{`, `}`, `"`, `@`, and `#`, before
1212
/// writing to the underlying object.
1313
/// </summary>
14-
public class EscapingTextWriter : TextWriter
14+
public sealed class EscapingTextWriter : TextWriter
1515
{
1616
private readonly TextWriter wrapped;
1717
private readonly bool disposeUnderlying;
@@ -93,7 +93,7 @@ public override ValueTask DisposeAsync()
9393
=> throw new NotImplementedException();
9494

9595
public override bool Equals(object? obj)
96-
=> wrapped.Equals(obj);
96+
=> wrapped.Equals(obj) && obj is EscapingTextWriter other && disposeUnderlying == other.disposeUnderlying;
9797

9898
public override void Flush()
9999
=> wrapped.Flush();
@@ -102,7 +102,7 @@ public override Task FlushAsync()
102102
=> wrapped.FlushAsync();
103103

104104
public override int GetHashCode()
105-
=> wrapped.GetHashCode();
105+
=> HashCode.Combine(wrapped, disposeUnderlying);
106106

107107
public override string ToString()
108108
=> wrapped.ToString() ?? "";

0 commit comments

Comments
 (0)