I’m using ServiceStack 4.5.4 and I am trying to make the IHasVersion interface work for a specific request however the Version property is not automatically populated.
This is my request:
[Route("/token/guest", Verbs = "GET")]
public class GetTokenRequest : IReturn<Token>, IHasVersion
{
public DateTime ExpiryDate { get; set; }
public int Version { get; set; }
}
And I use it like this:
var client = new JsonServiceClient(url);
client.Version = 2;
var r = new GetTokenRequest();
var result = await client.SendAsync(r).ConfigureAwait(false);
The version property of the request is not populated with the version number of the client and using Fiddler I can see that the version property is sent with a value of 0.
If I use Send instead of SendAsync the version property is populated correctly so it looks like the async implementation has bug (or I am doing something wrong).
Your test is slightly different that what I had above. Can you try this one:
[Test]
public async Task Does_send_version_using_JsonServiceClient()
{
var client = new JsonServiceClient(Config.AbsoluteBaseUri);
client.Version = 1;
var response = client.Send(new RequestWithVersion { });
Assert.That(response.Version, Is.EqualTo(1));
response = await client.SendAsync(new RequestWithVersion { });
Assert.That(response.Version, Is.EqualTo(1));
}
According to the documentation, setting the version on the client should populate the version on the request but it does not even with the latest stable version 4.5.12. CustomMethod and CustomMethodAsync have the same issue.
I can confirm that Send and SendAsync works as expected in 4.15.14 however CustomMethod and CustomMethodAsync still have the issue (I briefly mentioned them in a reply above).
I would like to add that the CustomMethod and CustomMethodAsync methods adds the version to the request for POST request but not for GET request (I didn’t test PUT or DELETE).
I tried the latest v4.5.15 available on MyGet (I cleared my Nuget cache before doing so) but I still have the issue. I decompiled the Dll however I cannot see the changes from your commit. Is it possible that MyGet does not have the latest version of the code?