Skip to content

Commit

Permalink
Fixes issue #952 - we did not actually write everything to output str…
Browse files Browse the repository at this point in the history
…eam.
  • Loading branch information
cocytus committed Nov 26, 2020
1 parent 670e2ea commit f01a96b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
8 changes: 8 additions & 0 deletions Refit.Tests/RefitStubs.Net46.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2542,6 +2542,14 @@ Task IRequestBin.PostGeneric<T>(T param)
var func = requestBuilder.BuildRestResultFuncForMethod("PostGeneric", new Type[] { typeof(T) }, new Type[] { typeof(T) });
return (Task)func(Client, arguments);
}

/// <inheritdoc />
Task IRequestBin.PostBig(BigObject big)
{
var arguments = new object[] { big };
var func = requestBuilder.BuildRestResultFuncForMethod("PostBig", new Type[] { typeof(BigObject) });
return (Task)func(Client, arguments);
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions Refit.Tests/RefitStubs.Net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2542,6 +2542,14 @@ Task IRequestBin.PostGeneric<T>(T param)
var func = requestBuilder.BuildRestResultFuncForMethod("PostGeneric", new Type[] { typeof(T) }, new Type[] { typeof(T) });
return (Task)func(Client, arguments);
}

/// <inheritdoc />
Task IRequestBin.PostBig(BigObject big)
{
var arguments = new object[] { big };
var func = requestBuilder.BuildRestResultFuncForMethod("PostBig", new Type[] { typeof(BigObject) });
return (Task)func(Client, arguments);
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions Refit.Tests/RefitStubs.NetCore2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2542,6 +2542,14 @@ Task IRequestBin.PostGeneric<T>(T param)
var func = requestBuilder.BuildRestResultFuncForMethod("PostGeneric", new Type[] { typeof(T) }, new Type[] { typeof(T) });
return (Task)func(Client, arguments);
}

/// <inheritdoc />
Task IRequestBin.PostBig(BigObject big)
{
var arguments = new object[] { big };
var func = requestBuilder.BuildRestResultFuncForMethod("PostBig", new Type[] { typeof(BigObject) });
return (Task)func(Client, arguments);
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions Refit.Tests/RefitStubs.NetCore3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2542,6 +2542,14 @@ Task IRequestBin.PostGeneric<T>(T param)
var func = requestBuilder.BuildRestResultFuncForMethod("PostGeneric", new Type[] { typeof(T) }, new Type[] { typeof(T) });
return (Task)func(Client, arguments);
}

/// <inheritdoc />
Task IRequestBin.PostBig(BigObject big)
{
var arguments = new object[] { big };
var func = requestBuilder.BuildRestResultFuncForMethod("PostBig", new Type[] { typeof(BigObject) });
return (Task)func(Client, arguments);
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions Refit/Buffers/PooledBufferWriter.Stream.NETStandard21.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ internal sealed partial class PooledBufferWriter
private sealed partial class PooledMemoryStream : Stream
{
/// <inheritdoc/>
public override void CopyTo(Stream destination, int bufferSize)
public Task CopyToInternalAsync(Stream destination, CancellationToken cancellationToken)
{
if (pooledBuffer is null) ThrowObjectDisposedException();

var bytesAvailable = length - position;
var spanLength = Math.Min(bytesAvailable, bufferSize);

var source = pooledBuffer.AsSpan(position, spanLength);
var source = pooledBuffer.AsMemory(position, bytesAvailable);

position += source.Length;

destination.Write(source);
return destination.WriteAsync(source, cancellationToken).AsTask();
}

/// <inheritdoc/>
Expand Down
5 changes: 4 additions & 1 deletion Refit/Buffers/PooledBufferWriter.Stream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ public override Task CopyToAsync(Stream destination, int bufferSize, Cancellatio

try
{
#if NETSTANDARD2_1 || NET5_0
return CopyToInternalAsync(destination, cancellationToken);
#else
CopyTo(destination, bufferSize);

return Task.CompletedTask;
#endif
}
catch (OperationCanceledException e)
{
Expand Down

0 comments on commit f01a96b

Please sign in to comment.