Skip to content

[Bug]: "doesn't look like a Refit interface" when inheriting empty interface from interface with refit function #1687

Closed

Description

@pagdot

Describe the bug 🐞

Inheriting an empty interface from a base interface with refit methods causing it to not be detected. Seems like this issue occurs during roselyn code generation because no classes are generated for the derived interface(s)

Step to reproduce

using System;
using System.Threading;
using System.Threading.Tasks;
using Refit;
		
public interface IBaseService
{
    [Get("/resources")]
    Task<string> GetResource(string id);
}

public interface IDerivedServiceA : IBaseService
{
}

public class Program
{
	public static void Main()
	{
		var api = RestService.For<IDerivedServiceA>("https://example.com");
		Console.WriteLine(api.GetResource("abc"));
	}
}

(Tested at https://dotnetfiddle.net/ with refit package installed)

Reproduction repository

No response

Expected behavior

No error about doesn't look like a Refit interface. Provided example should only stumble when trying to do the actual API call because the api doesn't exist

Screenshots 🖼️

No response

IDE

Visual Studio 2022

Operating system

No response

Version

No response

Device

No response

Refit Version

7.0.0

Additional information ℹ️

Probably happens on other (older) versions too. Reproduced it with 7.0.0 in my minimal sample

Activity

  1. TimothyMakkison commented on Sep 4, 2024

    @TimothyMakkison
    Collaborator

    Are there any use cases for this? I wonder if this is intentional to prevent Refit from generating several identical classes.

  2. pagdot commented on Sep 4, 2024

    @pagdot
    Author

    My use case was multiple apis where only the healthcheck was interesting combined with dependency injection, where I needed different interfaces for different apis.

    As a workaround I added a dummy endpoint to IDerivedServiceA

  3. TimothyMakkison commented on Nov 9, 2024

    @TimothyMakkison
    Collaborator

    Hey, not sure when it was fixed, but this appears to work in Refit 8.0.0

  4. ChrisPulman commented on Nov 9, 2024

    @ChrisPulman
    Member

    @pagdot Are you able to confirm that this is now resolved.

  5. pagdot commented on Nov 11, 2024

    @pagdot
    Author

    Minimal sample now compiles and runs as expected :) Thanks for checking it :)

  6. github-actions commented on Nov 27, 2024

    @github-actions

    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.

  7. locked as resolved and limited conversation to collaborators on Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions