Skip to content

Add netstandard support to appropriate packages #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Eilon opened this issue Jul 23, 2016 · 11 comments
Closed

Add netstandard support to appropriate packages #4

Eilon opened this issue Jul 23, 2016 · 11 comments

Comments

@Eilon
Copy link
Contributor

Eilon commented Jul 23, 2016

The Web API "client" packages should have support for the lowest netstandard TFM possible.

@dougbu
Copy link
Contributor

dougbu commented Dec 2, 2016

Blocked: Have a branch ready to go but #32 blocks applying it.

Can't create a true .NET Standard library without more-recent tooling. Also unable to avoid Microsoft.Net.Http package and its "unique" System.Net.Http.Primitives.dll dependency when building a Profile259 library.

@dougbu
Copy link
Contributor

dougbu commented Dec 6, 2016

Unblocked: A couple of the CI machines have VS 2015 installed and they should be up-to-date enough to build these new projects.

@dougbu
Copy link
Contributor

dougbu commented Dec 13, 2016

Git portion done in f830808. Will wait for a build on CI then do TFS portion…

@dougbu
Copy link
Contributor

dougbu commented Dec 13, 2016

Nightly build was successful after both checkins:

@Eilon
Copy link
Contributor Author

Eilon commented Dec 14, 2016

Yayyyyyyy!!!!!!!!

@Tratcher
Copy link
Member

why hasn't this shipped to nuget.org yet?

@CIPop
Copy link

CIPop commented Sep 26, 2017

/cc: @jasmineymlo @tameraw
@Eilon This is internally required for Azure IoT SDK. Any ETA on getting an RTM NuGet version for NetStandard 1.1?

@Eilon
Copy link
Contributor Author

Eilon commented Oct 2, 2017

We keep getting higher-priority items on our plate, so this keeps falling off our plate. I'll boost the priority on this item this week.

@YakhontovYaroslav
Copy link

@Eilon @dougbu
Ive just checked out latest .Client build here https://dotnet.myget.org/feed/aspnetwebstack-dev/package/nuget/Microsoft.AspNet.WebApi.Client and it seems to miss some old functionality. For example FormUrlEncodedMediaTypeFormatter is gone. Is it intended change and what are the replacements? Im using this formatter (as well as all other formatters from this assembly) for building dynamic client implementations with help of Castle.Core package.
Upgrading to this build version release will introduce many breaking changes for many users.

@dougbu
Copy link
Contributor

dougbu commented Oct 18, 2017

@YakhontovYaroslav the FormUrlEncodedMediaTypeFormatter class is a server-side i.e. input formatter and has never been included in Microsoft.AspNet.WebApi.Client. Are you looking for the Microsoft.AspNet.WebApi package?

More generally, if you're building an ASP.NET Core web application, please have a look at Microsoft.AspNetCore.Mvc and the packages it depends on. FormUrlEncodedMediaTypeFormatter does not exist in that framework because ASP.NET Core MVC model binds form-URL requests without input formatters.

@YakhontovYaroslav
Copy link

YakhontovYaroslav commented Oct 19, 2017

@dougbu
It was definitely in https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Client/ nuget.
Im talking about https://github.com/aspnet/AspNetWebStack/blob/master/src/System.Net.Http.Formatting/Formatting/FormUrlEncodedMediaTypeFormatter.cs this class. Its included in https://github.com/aspnet/AspNetWebStack/tree/master/src/System.Net.Http.Formatting , but missing from https://github.com/aspnet/AspNetWebStack/tree/master/src/System.Net.Http.Formatting.NetStandard an Core versions.

Im not looking for server side implementation. As i mentioned above, we are using this formatter (as well as Json and Xml from same namespace) to dynamically build HttpClient pipelines using DelegatingHandler and Castle.Core proxies. Its neat way to declare whole serialization\deserialization pipelines using just interface declaration with custom attributes like ContentType, Accept, Route, Method etc. Many 3rd party APIs still uses FormUrlEncoded in POST and GET requests, and we must somehow integrate with them. Removing FormUrlEncodedMediaTypeFormatter from Microsoft.AspNet.WebApi.Client package will force us (and many people who used it similar way) to create our own implementation of FormData formatter, which seems unnecessary, when package already contains this functionality, which can be easily ported to .netstandard.

Code Example of such interface:
`

[RestContract("http://example.com/api", timeout: 180)]
public interface IExampleApiClient
{
    [RestMethod("/v2/login", RestMethod.Post)]
    [Accept("application/x-www-form-urlencoded")]
    [ContenType("application/json")]
    Task<LoginResult> LoginAsync(LoginModel model, [Header("HeaderName")] headerValue);
}

`
Later we use helper method to create runtime implementation with necessary DelegatingHandlers and Formatters to serialize and deserialize data based on attributes. In the example above, generated proxy will use https://github.com/aspnet/AspNetWebStack/blob/master/src/System.Net.Http.Formatting/Formatting/JsonMediaTypeFormatter.cs for serializing requests and FormUrlEncodedMediaTypeFormatter for deserializing responses.

In fact there is no changes needed to achieve this, besides adding file link to csproj. I`ve event created pull request for this:
#76
This only affects .NetStandard project, as for some reason i cant open .Core version of project in VS, its crashing with NullReferenceException. But same change there would be good.
This pull request adds only FormUrlEncodedMediaTypeFormatter back, but there may be other files that simply left abandoned in new projects.

Cheers, and thanks for your attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants