Duplicated DTOs while auto-generating with "x typescript" tool

There is a small issue, which can be easily “work-arounded”, nevertheless I think it’s an issue.

This happened on v5.14 of ServiceStack, but I don’t think this was resolved in newer versions.

So there are two requests with the same name, but in different namespaces:

namespace n1 {
  [Tag("tag1")]
  public class MyRequest {
  }
}

namespace n2 {
  [Tag("tag2")]
  public class MyRequest {
  }
}

Following the instructions in https://docs.servicestack.net/typescript-add-servicestack-reference, I filtered the dto generation only for the requests with tag tag1:

var nativeTypes = appHost.GetPlugin<NativeTypesFeature>();
nativeTypes.MetadataTypesConfig.IncludeTypes = new List<string> { "{tag1}" };

Thus, this results anyway in generating the n2.MyRequest with tag2 in the dtos.ts file using the x typescript tool:

export class MyRequest
{
}

export class MyRequest
{
}

Currently, I just renamed the second request to MyRequest_v2, but I think the service responsible for publishing the metadata for the x typescript tool should be aware of the namespaces.

Small explanation on the model
The reason I implemented it like that is, those 2 requests have exactly the same functionality, but they are under different authentication scheme. So for different customers, depending on the licensing model, there might be only 1 service (or none at all) available.

Usage of duplicate Types in different C#/.NET Namespaces is only supported in .NET Service Clients e.g. using Service Model DTOs .dll’s.

But a primary Add ServiceStack Reference limitation is that all DTO Type Names must be unique.

Basically they shouldn’t be relied upon if you need to support non-.NET Typed languages.

I understand. Just didn’t scroll to the same bottom of the docs :slight_smile: If it is so by design, I guess it’s fine… There are many ways to tackle my scenario. I just thought it might be a bug, that’s why I reported.

Thanks!

2 Likes