Skip to content

Commit a888745

Browse files
committed
fix overrides and ifdefs
1 parent c0cca1e commit a888745

File tree

2 files changed

+12
-28
lines changed

2 files changed

+12
-28
lines changed

src/ICSharpCode.SharpZipLib/GZip/GzipOutputStream.cs

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -164,26 +164,6 @@ public override void Write(byte[] buffer, int offset, int count)
164164
base.Write(buffer, offset, count);
165165
}
166166

167-
#if NETSTANDARD2_1_OR_GREATER
168-
/// <inheritdoc cref="DeflaterOutputStream.WriteAsync(byte[],int,int,CancellationToken)"/>
169-
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
170-
{
171-
172-
if (state_ == OutputState.Header)
173-
{
174-
await WriteHeaderAsync();
175-
}
176-
177-
if (state_ != OutputState.Footer)
178-
{
179-
throw new InvalidOperationException("Write not permitted in current state");
180-
}
181-
182-
crc.Update(new ArraySegment<byte>(buffer, offset, count));
183-
await base.WriteAsync(buffer, offset, count, cancellationToken);
184-
}
185-
#endif
186-
187167
/// <summary>
188168
/// Writes remaining compressed output data to the output stream
189169
/// and closes it.
@@ -270,8 +250,15 @@ public override void Finish()
270250
baseOutputStream_.Write(gzipFooter, 0, gzipFooter.Length);
271251
}
272252
}
273-
274-
#if NETSTANDARD2_1_OR_GREATER
253+
254+
/// <inheritdoc cref="Flush"/>
255+
public override async Task FlushAsync(CancellationToken ct)
256+
{
257+
await WriteHeaderAsync();
258+
await base.FlushAsync(ct);
259+
}
260+
261+
275262
/// <inheritdoc cref="Finish"/>
276263
public override async Task FinishAsync(CancellationToken ct)
277264
{
@@ -288,7 +275,6 @@ public override async Task FinishAsync(CancellationToken ct)
288275
await baseOutputStream_.WriteAsync(GetFooter(), ct);
289276
}
290277
}
291-
#endif
292278

293279
#endregion DeflaterOutputStream overrides
294280

@@ -362,19 +348,17 @@ private void WriteHeader()
362348
{
363349
if (state_ != OutputState.Header) return;
364350
state_ = OutputState.Footer;
365-
366351
var gzipHeader = GetHeader();
367352
baseOutputStream_.Write(gzipHeader, 0, gzipHeader.Length);
368353
}
369354

370-
#if NETSTANDARD2_1_OR_GREATER
371355
private async ValueTask WriteHeaderAsync()
372356
{
373357
if (state_ != OutputState.Header) return;
374358
state_ = OutputState.Footer;
375-
await baseOutputStream_.WriteAsync(GetHeader());
359+
var gzipHeader = GetHeader();
360+
await baseOutputStream_.WriteAsync(gzipHeader, 0, gzipHeader.Length);
376361
}
377-
#endif
378362

379363
#endregion Support Routines
380364
}

src/ICSharpCode.SharpZipLib/Zip/Compression/Streams/DeflaterOutputStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ protected override void Dispose(bool disposing)
412412
}
413413
}
414414

415-
#if NETSTANDARD2_1
415+
#if NETSTANDARD2_1_OR_GREATER
416416
/// <summary>
417417
/// Calls <see cref="FinishAsync"/> and closes the underlying
418418
/// stream when <see cref="IsStreamOwner"></see> is true.

0 commit comments

Comments
 (0)