Records as classes
jayhayman-hdd opened this issue · comments
We've recently been experimenting with converting our DTO classes to records in C#. I see that since version 1.3.0, the $Classes
function should be able to pick up record
instead of class
in the C# DTO file. Is this still the case as we're currently not getting any exported TS files for an DTO marked as record
. Classes in the same source project still export but the ones defined as record
are skipped.
Are we missing something obvious in the TypeWriter template to enable this?
We're currently using v2.25.0.
Example C# class:
namespace Cylch.Atp.Dashboard.Services.Features.RightsManagement.Dtos
{
public record GetUserSummaryDto
(
string Email,
string Name,
int WebDashTotalRights,
int AppCaptureTotalRights,
int WorkflowsAssignedTotal
);
}
Example TypeWriter template file:
${
// Enable extension methods by adding using Typewriter.Extensions.*
using Typewriter.Extensions.Types;
// Uncomment the constructor to change template settings.
Template(Settings settings)
{
settings.IncludeProject("Cylch.Atp.Dashboard.Services");
settings.OutputExtension = ".tsx";
}
// Custom extension methods can be used in the template by adding a $ prefix e.g. $LoudName
string LoudName(Property property)
{
return property.Name.ToUpperInvariant();
}
}
namespace RightsManagement.Dtos {
$Classes(c => c.Namespace == "Cylch.Atp.Dashboard.Services.Features.RightsManagement.Dtos")[
export class $Name {
$Properties[
// $LoudName
$name: $Type = $Type[$Default];]
}]
}
hi - it is implemented - you need to use $Records instead of $Classes