Search code examples
c#asp.net-corereinforced-typings

Reinforced.Typings cannot handle attributes on properties


I have an ASP.NET Core project using ASP.NET Identity. Some classes cannot be exported since their properties contain attributes from System.ComponentModel.DataAnnotations. If I ignore such properties, everything works fine.

Example class:

public class LoginViewModel
{
    [Required]
    [EmailAddress]
    public string Email { get; set; }

    [Required]
    [DataType(DataType.Password)]
    public string Password { get; set; }

    [Display(Name = "Remember me?")]
    public bool RememberMe { get; set; }
}

Since I don't want to strip out these attributes, what is the recommended course of action?

[assembly: TsGlobal(
    CamelCaseForMethods = true,
    CamelCaseForProperties = true,
    GenerateDocumentation = true,
    UseModules = true,
    DiscardNamespacesWhenUsingModules = true)]

namespace X
{
    public static class ReinforcedTypingsConfiguration
    {
        public static void Configure(ConfigurationBuilder builder)
        {
            builder
                .ExportAsInterface<LoginViewModel>()
                .AutoI(false)
                .WithProperty(x => x.RememberMe)
                ;
        }
    }
}

Other than that, it seems that UseModules does the opposite of what I want it to do. When set to true, the generated ts file doesn't contain any modules. When set to false, I get module in my ts files.

Also, when dividing types among files, I get strange folder names on mac that contain \ for every . in my namespace. Can I just flatten out the structure? And completely ignore backend namespaces?

In the above configuration (and I use file splitting) I get the annoying error message error MSB3552: Resource file "**/*.resx" cannot be found..


Solution

  • Upgrade to 1.4.2 to fix this issue.