Skip to content

Commit

Permalink
Merge pull request #1130 from reactiveui/new-constraint-fix
Browse files Browse the repository at this point in the history
Fix issue where explicit or override wasn't being passed correctly to the generic constraints writer
  • Loading branch information
clairernovotny committed Mar 19, 2021
2 parents 33935a9 + ae2c332 commit 05a1e1e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion InterfaceStubGenerator.Core/InterfaceStubGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
{{");
}

Expand Down
26 changes: 26 additions & 0 deletions Refit.Tests/InheritedGenericInterfacesApi.cs
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -47,5 +49,29 @@ public interface IDataCrudApi<T, TKey> where T : class

[Delete("/{key}")]
Task Delete(TKey key);

[Get("")]
Task ReadAllClasses<TFoo>()
where TFoo : class, new();
}


public class DatasetQueryItem<TResultRow>
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<DatasetQueryItem<TResulRow>[]> GetDataSetItems<TResulRow>()
where TResulRow : class, new();
}
}

0 comments on commit 05a1e1e

Please sign in to comment.