TrackableEntities / EntityFrameworkCore.Scaffolding.Handlebars

Scaffold EF Core models using Handlebars templates.
MIT License
210 stars 53 forks source link

Use Chinese Comments #180

Closed tonysneed closed 2 years ago

tonysneed commented 3 years ago

Add Chinese comments to tests. Set NoEscape true in template services.

Closes #30.

tonysneed commented 3 years ago

Table comments are encoded. Some property comments are encoded, but others are not encoded -- but only when data annotations are used.

Here is output when templates are applied to Product with table and property comments in Chinese.

namespace FakeNamespace
{
    /// <summary>
    /// 产品
    /// </summary>
    [Table("Product")]
    [Index(nameof(CategoryId), Name = "IX_Product_CategoryId")]
    public partial class Product
    {

        /// <summary>
        /// 编号
        /// </summary>
        [Key]
        public int ProductId { get; set; }

        /// <summary>
        /// &#21517;&#31216;
        /// </summary>
        [Required]
        [StringLength(40)]
        public string ProductName { get; set; }
        [Column(TypeName = "money")]
        public decimal? UnitPrice { get; set; }
        public bool Discontinued { get; set; }
        public byte[] RowVersion { get; set; }
        public int? CategoryId { get; set; }

        [ForeignKey(nameof(CategoryId))]
        [InverseProperty("Products")]
        public virtual Category Category { get; set; }
    }
}
tonysneed commented 3 years ago

The behavior is inconsistent. Comments on the class name are encoded even with attributes. The ProductId property has a [Key] attribute and the comment is not encoded. But the next property, 'ProductName' has some attributes and is encoded. If there is no #each property-annotations in the template, then the all the property comments are encoded.

To me this looks like a bug in Handlebars.Net. I filed this issue there.

tonysneed commented 2 years ago

Replace with #200