Skip to content

Commit

Permalink
Move PushStreamContent Namespace (#467)
Browse files Browse the repository at this point in the history
* Move PushStreamContent Namespace

Previous behavior caused issues of �mbiguous reference around
PushStreamContent when both Refit and System.Net.Http.Formatting are
included in a project. This is essentially a show stopper to upgrading
to the latest Refit.

The solution is to change the internal implementation of PushStreamContent
namespace from System.Net.Http -> Refit.Net.Http and to update
the usages internally. Note this may be a breaking change to those who
have taken a dependency on PushStreamContent in their own projects from
the Refit assemblies.

* Make types internal
  • Loading branch information
khalidabuhakmeh authored and Oren Novotny committed May 15, 2018
1 parent a2d3cde commit 3e8d4a8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
12 changes: 10 additions & 2 deletions Refit.Tests/RefitStubs.Net46.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,19 @@ public virtual IObservable<string> GetIndexObservable()
}

/// <inheritdoc />
public virtual Task NothingToSeeHere()
public virtual Task<User> NothingToSeeHere()
{
var arguments = new object[] { };
var func = methodImpls.GetOrAdd("NothingToSeeHere()", _ => requestBuilder.BuildRestResultFuncForMethod("NothingToSeeHere", new Type[] { }));
return (Task)func(Client, arguments);
return (Task<User>)func(Client, arguments);
}

/// <inheritdoc />
public virtual Task<ApiResponse<User>> NothingToSeeHereWithMetadata()
{
var arguments = new object[] { };
var func = methodImpls.GetOrAdd("NothingToSeeHereWithMetadata()", _ => requestBuilder.BuildRestResultFuncForMethod("NothingToSeeHereWithMetadata", new Type[] { }));
return (Task<ApiResponse<User>>)func(Client, arguments);
}

/// <inheritdoc />
Expand Down
12 changes: 10 additions & 2 deletions Refit.Tests/RefitStubs.NetCore2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,19 @@ public virtual IObservable<string> GetIndexObservable()
}

/// <inheritdoc />
public virtual Task NothingToSeeHere()
public virtual Task<User> NothingToSeeHere()
{
var arguments = new object[] { };
var func = methodImpls.GetOrAdd("NothingToSeeHere()", _ => requestBuilder.BuildRestResultFuncForMethod("NothingToSeeHere", new Type[] { }));
return (Task)func(Client, arguments);
return (Task<User>)func(Client, arguments);
}

/// <inheritdoc />
public virtual Task<ApiResponse<User>> NothingToSeeHereWithMetadata()
{
var arguments = new object[] { };
var func = methodImpls.GetOrAdd("NothingToSeeHereWithMetadata()", _ => requestBuilder.BuildRestResultFuncForMethod("NothingToSeeHereWithMetadata", new Type[] { }));
return (Task<ApiResponse<User>>)func(Client, arguments);
}

/// <inheritdoc />
Expand Down
6 changes: 4 additions & 2 deletions Refit/PushStreamContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.IO;
using System.Net;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
using System.Net.Http;

namespace System.Net.Http
{
Expand All @@ -36,7 +38,7 @@ namespace System.Net.Http
/// </summary>
// https://github.com/ASP-NET-MVC/aspnetwebstack/blob/d5188c8a75b5b26b09ab89bedfd7ee635ae2ff17/src/System.Net.Http.Formatting/PushStreamContent.cs
[ExcludeFromCodeCoverage]
public class PushStreamContent : HttpContent
class PushStreamContent : HttpContent
{
private readonly Func<Stream, HttpContent, TransportContext, Task> _onStreamAvailable;

Expand Down Expand Up @@ -182,7 +184,7 @@ protected override void Dispose(bool disposing)
/// </summary>
// https://github.com/ASP-NET-MVC/aspnetwebstack/blob/d5188c8a75b5b26b09ab89bedfd7ee635ae2ff17/src/System.Net.Http.Formatting/Internal/DelegatingStream.cs
[ExcludeFromCodeCoverage]
internal abstract class DelegatingStream : Stream
abstract class DelegatingStream : Stream
{
Stream innerStream;

Expand Down

0 comments on commit 3e8d4a8

Please sign in to comment.