Describe the bug
Upgrading from 5.0.23 to 5.1.54 causes a build error due to some using directives not being added to the generated stubs. I have multiple libraries using refit and only one of them seems to break with this upgrade, I'll do some digging to see if I can figure out the cause or create a repro.
As a test, I've added the various using directives manually to the stubs, and that let me successfully build and run my app. Of course, cleaning the solution and rebuilding made those errors pop right back up again. Downgrading to 5.0.23 fixed the issue for the time being.
EDIT: the library fails to build with 5.1.27 as well. Will try prerelease builds next.
EDIT 2: some more info:
5.1.60 build, same errorsRefit feed. The first build causing the errors is actually just 5.0.39. Up to 5.0.32 builds just fine.cc. @clairernovotny is there somewhere to look up the exact list of commits between releases on the NuGet feed so that I can try seeing if I can spot the change that caused this to break? 馃槃
I've tried searching for them on the Azure Pipeline but I can't see packages before 5.0.59 there.
Steps To Reproduce
Not available yet, I'll first try all the intermediate versions from 5.0.23 to 5.1.54 to see if I can spot the first that's causing this crash to occur. Once I have that, I'll see if I can create a repro.
Expected behavior
Libraries using refit should build correctly.
Screenshots

Environment
5.1.545.0.23Additional context
I'm trying to build a .NET Standard 2.0 library.
I assume it is caused by this PR: https://github.com/reactiveui/refit/pull/803
Still, would be great to see repro case to understand what went wrong there.
Ah, yeah that seems very likely, thanks @Dreamescaper!
I'll see if I can create a repro, I have a whole bunch of .NET Standard projects using Refit and all of them are building fine, so it should (hopefully) be easy enough to just trim the one that's failing down until I can come up with a minimum repro. Will share more info as soon as I have something!
There is already one bug related to usings fixed: https://github.com/reactiveui/refit/issues/876
But you mentioned that it reproduces with latest build as well, so I assume it's something else.
Yeah, I've identified the first crashing build to be 5.0.39, but just in case I tested both the latest official release (5.1.54), and the latest prerelease build (5.1.60), and both fail to build as well 馃槦
@Dreamescaper I've found the issue, looks like it's caused by an incorrect handling of using directives for types used by base interfaces for REST services. I think we should've had more unit tests to make sure future changes wouldn't break the support for interface inheritance 馃槙
Here's a repro. Note: this _only_ breaks if the classes are defined in different files.
namespace Rest.Models
{
public sealed class User { }
}
namespace Rest.Services
{
public interface IA
{
[Get("/users/{id}.json")]
Task<User> GetUserAsync(string id);
}
}
namespace Rest.Services
{
public interface IB : IA
{
[Post("/api/foo/{id}.json")]
Task<string> FooAsync(string id);
}
}
This also seems to depend quite a bit on the exact file configuration. For instance, defining all these models/services in the same file causes no issues. Also, interestingly enough, if each model is fully qualified (even when the actual fully qualified name isn't necessary, as the file already contains the right using directive), then refit builds fine, as it just copies over that fully qualified name.
Hope this helps!
Makes sense.
Previously all usings were common in generated stubs, therefore usings, added by base types, worked for inherited as well. And since we have separate usings for each original file now - here we are.
Should be easy to fix, I'll take a look.
Awesome, thank you for your help! 馃槉
Most helpful comment
Makes sense.
Previously all usings were common in generated stubs, therefore usings, added by base types, worked for inherited as well. And since we have separate usings for each original file now - here we are.
Should be easy to fix, I'll take a look.