Search code examples
servicestack

How do I get ServiceStack's x csharp to generate dto's for only a specific type


I'm using the ServiceStack x tool with the csharp option to generate a C# dtos.cs file. On first create it works great. I've used its generated content to move DTO's to dto-specific files, and applied modifications to them.

Now I want to update it after adding a new class to my ServiceModel project. So I edit the settings in the existing file, by uncommenting the IncludeTypes option, like so:

...
//ExportValueTypes: False
IncludeTypes: TenantConfig
//ExcludeTypes: 
...

Then when I run x csharp, the file is updated, but it now contains ONLY the type class for TenantConfig. It does not include all the DTOs (CreateTenantConfig, UpdateTenantConfig, etc).

How can I get the x csharp tool to generate the missing DTOs when including a specific type?

As an aside, I took the other approach of using the ExcludeTypes instead of IncludeTypes, and listed all the first-time-generated types to be excluded. But this time it generated all the DTOs, even for the excluded types (and my new TenantConfig type), but the only difference is that it did not generate their actual type classes in the .Types namespace. Which seems odd. I would think that DTOs for ExcludedTypes should NOT be generated? Perhaps I am missing some documentation (though I have searched) regarding the use of this function?


Solution

  • You can find the various options for including types in the C# Add ServiceStack Reference docs, e.g. to include a Request DTO and all it's referenced types you can use:

    IncludeTypes: TenantConfig.*