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

[BUG] 5.0.23 to 5.1.54 update causes build errors (missing using directives in stub) #892

Closed
Sergio0694 opened this issue Apr 7, 2020 · 8 comments · Fixed by #895
Closed
Labels

Comments

@Sergio0694
Copy link
Contributor

Sergio0694 commented Apr 7, 2020

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:

  • I tried the latest 5.1.60 build, same errors
  • Went through all the prerelease builds available on NuGet through the Refit 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

image

Environment

  • OS: Windows 10 Pro x64 18363.720
  • Device: Desktop
  • Version: 5.1.54
  • Working Version: 5.0.23

Additional context

I'm trying to build a .NET Standard 2.0 library.

@Sergio0694 Sergio0694 added the bug label Apr 7, 2020
@Dreamescaper
Copy link
Contributor

I assume it is caused by this PR: #803
Still, would be great to see repro case to understand what went wrong there.

@Sergio0694
Copy link
Contributor Author

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!

@Dreamescaper
Copy link
Contributor

There is already one bug related to usings fixed: #876

But you mentioned that it reproduces with latest build as well, so I assume it's something else.

@Sergio0694
Copy link
Contributor Author

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 😟

@Sergio0694
Copy link
Contributor Author

@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!

@Dreamescaper
Copy link
Contributor

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.

@Sergio0694
Copy link
Contributor Author

Awesome, thank you for your help! 😊

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants