Skip to content
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

Missing System.Web.Http using in generated file #86

Open
luk355 opened this issue Feb 25, 2016 · 5 comments
Open

Missing System.Web.Http using in generated file #86

luk355 opened this issue Feb 25, 2016 · 5 comments

Comments

@luk355
Copy link

luk355 commented Feb 25, 2016

Generated proxy class file is missing System.Web.Http using therefore compilation of project is falling afterwards.

.Net framework - 4.5.2
WebApiProxy-CSharp version - 1.0.5.35849

@YetAnotherPhil
Copy link

This is still an issue with the latest version (1.3.6021.11899).
Please can you add using System.Web.Http; to avoid error:

CS0246 The type or namespace name 'IHttpActionResult' could not be found (are you missing a using directive or an assembly reference?)

Here is an example method: IHttpActionResult Delete(int MyID); that generates the error.

TY

@faniereynders
Copy link
Member

faniereynders commented Jun 26, 2016

Adding a reference to System.Web.Http will solve the problem but leaving it with another reference to another assembly that it really doesn't need on the client side. We don't want to do this.

The return type IHttpActionResult is an abstraction of a HttpResponseMessage and therefore needs to be generated as HttpResponseMessage instead of an interface, (given that ResponseType isn't explicitly specified on the method of the controller).

I've noticed that this does indeed gets generated like mentioned above, but only some of the methods and will push out a bug fix that addresses this shortly.

In the meanwhile I would suggest explicitly specifying the return type using ResponseType when using IHttpActionResult responses.

@YetAnotherPhil
Copy link

YetAnotherPhil commented Jun 26, 2016

Fair comment, thx for the speedy reply. Cheers

@faniereynders
Copy link
Member

After further investigation on this issue (and hoping it was changed by an accidental merge earlier on), I found that this specific scenario is implemented by design to enforce the use of ResponseType on actions.

It generates 3 methods, 2 of which returns a standard HttpResponseMessage by default:

  1. A special async message e.g. Task<HttpResponseMessage> FooAsyncMsg()
  2. A normal async e.g. Task<HttpResponseMessage> FooAsync()
  3. A concrete e.g. Bar Foo()

Really don't know what the actual difference (or use) is between nr. 1 & 2, therefor I suggest the following:

  1. A special async (as message) e.g. Task<HttpResponseMessage> FooAsyncMessage()
  2. A async e.g. Task<Bar> FooAsync()
  3. A concrete e.g. Bar Foo()

@faniereynders
Copy link
Member

The only thing is that it still shouldn't break if one doesn't use ResponseType. It should fall back to HttpResponseMessage IMHO

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

No branches or pull requests

3 participants