From ae2c332be76d5faa276262be13dd44f02a580119 Mon Sep 17 00:00:00 2001 From: Claire Novotny Date: Fri, 19 Mar 2021 11:58:06 -0400 Subject: [PATCH] Fix issue where explicit or override wasn't being passed correctly to the generic constraints writer --- .../InterfaceStubGenerator.cs | 2 +- Refit.Tests/InheritedGenericInterfacesApi.cs | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs b/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs index 457540d13..1ca673cdb 100644 --- a/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs +++ b/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs @@ -503,7 +503,7 @@ void WriteMethodOpening(StringBuilder source, IMethodSymbol methodSymbol, bool i source.Append(string.Join(", ", list)); } - source.Append(@$") {GenerateConstraints(methodSymbol.TypeParameters, true)} + source.Append(@$") {GenerateConstraints(methodSymbol.TypeParameters, isExplicitInterface)} {{"); } diff --git a/Refit.Tests/InheritedGenericInterfacesApi.cs b/Refit.Tests/InheritedGenericInterfacesApi.cs index cc28af564..cd9ffdd71 100644 --- a/Refit.Tests/InheritedGenericInterfacesApi.cs +++ b/Refit.Tests/InheritedGenericInterfacesApi.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; using System.Threading.Tasks; +using Newtonsoft.Json; + using Refit; // InterfaceStubGenerator looks for this using static System.Math; // This is here to verify https://github.com/reactiveui/refit/issues/283 @@ -47,5 +49,29 @@ public interface IDataCrudApi where T : class [Delete("/{key}")] Task Delete(TKey key); + + [Get("")] + Task ReadAllClasses() + where TFoo : class, new(); + } + + + public class DatasetQueryItem + where TResultRow : class, new() + { + [JsonProperty("global_id")] + public long GlobalId { get; set; } + + public long Number { get; set; } + + [JsonProperty("Cells")] + public TResultRow Value { get; set; } + } + + public interface IDataMosApi + { + [Get("/datasets/{dataSet}/rows")] + Task[]> GetDataSetItems() + where TResulRow : class, new(); } }