Skip to content

About

Test encoding of Chinese characters with Handlebars.Net

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

Handlebars-Net Encoding Test

Test encoding of Chinese characters with Handlebars-Net

Scenario 1: NoEscape = True

Set Configuration.NoEscape to True

A. Without Data Annotations in Template Data

  • Expected:
using System;
using System.Collections.Generic;

namespace FakeNamespace
{
    /// <summary>
    /// 产品
    /// </summary>
    public partial class 
    {

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

        /// <summary>
        /// 名称
        /// </summary>
        public string ProductName { get; set; }
    }
}
  • Actual:

Test passed: Actual output matches expected. No comments are escaped.

using System;
using System.Collections.Generic;

namespace FakeNamespace
{
    /// <summary>
    /// 产品
    /// </summary>
    public partial class 
    {

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

        /// <summary>
        /// 名称
        /// </summary>
        public string ProductName { get; set; }
    }
}

B. With Data Annotations in Template Data

  • Expected:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

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

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

        /// <summary>
        /// 名称
        /// </summary>
        [Required]
        [StringLength(40)]
        [Column(TypeName = "money")]
        public string ProductName { get; set; }
    }
}
  • Actual:

Test failed: Comment on ProductName property IS escaped (when it should not be).

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

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

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

        /// <summary>
        /// &#21517;&#31216;
        /// </summary>
        [Required]
        [StringLength(40)]
        [Column(TypeName = "money")]
        public string ProductName { get; set; }
    }
}

Scenario 2: NoEscape = False

Set Configuration.NoEscape to False

A. Without Data Annotations in Template Data

  • Expected:
using System;
using System.Collections.Generic;

namespace FakeNamespace
{
    /// <summary>
    /// &#20135;&#21697;
    /// </summary>
    public partial class 
    {

        /// <summary>
        /// &#32534;&#21495;
        /// </summary>
        public int ProductId { get; set; }

        /// <summary>
        /// &#21517;&#31216;
        /// </summary>
        public string ProductName { get; set; }
    }
}
  • Actual:

Test failed: Properties are NOT escaped (when they should be).

using System;
using System.Collections.Generic;

namespace FakeNamespace
{
    /// <summary>
    /// &#20135;&#21697;
    /// </summary>
    public partial class 
    {

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

        /// <summary>
        /// 名称
        /// </summary>
        public string ProductName { get; set; }
    }
}

B. With Data Annotations in Template Data

  • Expected:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace FakeNamespace
{
    /// <summary>
    /// &#20135;&#21697;
    /// </summary>
    [Table("Product")]
    [Index(nameof(CategoryId), Name = "IX_Product_CategoryId")]
    public partial class 
    {

        /// <summary>
        /// &#32534;&#21495;
        /// </summary>
        [Key]
        public int ProductId { get; set; }

        /// <summary>
        /// &#21517;&#31216;
        /// </summary>
        [Required]
        [StringLength(40)]
        [Column(TypeName = "money")]
        public string ProductName { get; set; }
    }
}
  • Actual:

Test failed: ProductId property is NOT escaped (when it should be).

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace FakeNamespace
{
    /// <summary>
    /// &#20135;&#21697;
    /// </summary>
    [Table("Product")]
    [Index(nameof(CategoryId), Name = "IX_Product_CategoryId")]
    public partial class 
    {

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

        /// <summary>
        /// &#21517;&#31216;
        /// </summary>
        [Required]
        [StringLength(40)]
        [Column(TypeName = "money")]
        public string ProductName { get; set; }
    }
}

About

Test encoding of Chinese characters with Handlebars.Net

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages