Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
Halibut doesn't currently support generic services (i.e.
IMyService<T>
). This is due to how the service name is serialized in the request message, it just usesType.Name
, which doesn't include any generic type argument information, just the number of generic type args (i.e.IMyService`1
).This means that the service can't be correctly resolved as
IMyService<int>
andIMyService<string>
are identified in the request message as the same service.Results
This PR changes the
TypeRegistry
and theHalibutProxy
to use a new extension method,GetGenericQualifiedName()
as the service name, rather than the.Name
property.This new extension method adds the generic type args to the name in the format
IMyService`2[Arg1,Arg2]
. If a generic type arg is also generic, it will build the same structure like thisIMyService`2[MyGenericType`1[string],string]
.Also, I have updated the
TypeRegistry
to find all derived types if a service method parameter is abstract. That is, if the method signature isvoid MyMethod(BaseType base)
and there are two derived types ofBaseType
, then those types are also registered.I have also added new unit tests covering the new generic services. I don't have enough knowledge of Halibut testing to understand what I need to do regarding the latest/previous version test cases, but this should be backwards compatible for existing services.
How to review this PR
Quality ✔️
Pre-requisites