ServiceStack CSV 序列化程序在序列化日期周围放置额外的引号

ServiceStack CSV serializer putting extra quotes around serialized date

我在我的站点中使用 ServiceStack 以允许用户下载系统数据集之一的 csv。在我的 AppHost 的配置方法中,我为 DateTime 提供了一个自定义序列化程序。看起来像这样

JsConfig<DateTime>.SerializeFn = time =>
  {
      var result = time;
      if (time.Kind == DateTimeKind.Unspecified)
      {
          result = DateTime.SpecifyKind(result, DateTimeKind.Local);
      }
          return result.ToString(CultureInfo.InvariantCulture);
  };

当使用 csv 格式时,结果中的所有日期都用额外的引号括起来;例如结果是 """06/24/2015 16:22:16""" 当我期望它是 "06/24/2015 16:22:16"

看来这一定是ServiceStack序列化的一个bug。有没有办法防止这种情况发生?以下是向 /csv/oneway/Request

发出请求时出现问题的完整示例
public class AppHost : AppHostBase
{
    /// <summary>
    /// Default constructor.
    /// Base constructor requires a name and assembly to locate web service classes. 
    /// </summary>
    public AppHost()
        : base("CSVBug", typeof(MyService).Assembly)
    {

    }

    public override void Configure(Container container)
    {
        JsConfig<DateTime>.SerializeFn = time =>
        {
            var result = time;
            if (time.Kind == DateTimeKind.Unspecified)
            {
                result = DateTime.SpecifyKind(result, DateTimeKind.Local);
            }
            return result.ToString(CultureInfo.InvariantCulture);
        };
    }
}

public class Request
{

}

public class Response
{
    public DateTime DateTime { get; set; }
}

public class MyService : Service
{
    public object Any(Request reuqest)
    {
        return new Response()
        {
            DateTime = DateTime.Now
        };
    }
}

和Global.asax.cs

public class Global : System.Web.HttpApplication
{
    protected void Application_Start(object sender, EventArgs e)
    {
        new AppHost().Init();
    }
}

现在应该可以解决这个问题 with this commit which is available from v4.0.41+ that's now available on MyGet