I am using the Add ServiceStack Reference Visual Studio plugin and I’m trying to generate only some classes from my service model by using the IncludeTypes option. It works well for most cases however I had an issue with a request that returns a list of DTO. I know that this is not best practice however I cannot change this code without breaking the compatibility.
I found an unusual issue while trying to reproduce the behavior in a separate project:
If I use the following code:
public partial class ReturnedDto
{
public virtual int Id { get; set; }
}
[Route("/Request1/", "GET")]
public partial class GetRequest1
: IReturn<List<ReturnedDto>>, IGet
{
}
// Service
public object Any(GetRequest1 request)
{
return null;
}
Options:
IncludeTypes: GetRequest1,ReturnedDto
I get the expected behavior e.g.: GetRequest1 and ReturnedDto are present in the generated code. However if I add another request that returns the DTO, only GetRequest1 is generated.
public partial class ReturnedDto
{
public virtual int Id { get; set; }
}
[Route("/Request1/", "GET")]
public partial class GetRequest1
: IReturn<List<ReturnedDto>>, IGet
{
}
[Route("/Request2", "GET")]
public partial class GetRequest2
: IReturn<ReturnedDto>, IGet
{
}
// Service
public object Any(GetRequest1 request)
{
return null;
}
public object Any(GetRequest2 request)
{
return null;
}
Options:
IncludeTypes: GetRequest1,ReturnedDto
Can you tell me why the class ReturnedDto is not always generated? I guess this is related to the non best practice use of returning a list.
This issue is because the ReturnedDto is defined as a Response DTO for a different Service which isn’t being included in the list, where excluding that Service excludes its definition. I’ve added a workaround to support this scenario in this commit.