GeneXus 模式:如何调试 dkt 文件?

GeneXus Patterns: How to debug dkt files?

我想通过 GeneXus 17 U8 使用模式类别(已弃用)。使用 https://github.com/genexuslabs/category-pattern.

中的示例代码

我设法在 GeneXus 17 中编译、安装和 运行 模式。

我尝试在 Empresas 事务中应用该模式,它创建了实例,但出现错误:

==========模式生成(CategoryEmpresas)开始==========错误:应用模式实例时发生错误'CategoryEmpresas':'Artech.Common.Diagnostics.GxException' **错误:输入文件有 1 个语法错误 AttributeCategoryId.dkt(2,0):错误 DKT1:语法错误:不可恢复的语法错误 **

失败:模式生成 (CategoryEmpresas)

我没有修改 AttributeCategoryId.dkt 文件(事实上,我没有修改存储库中的任何文件),我找不到可能是什么语法错误。

当我将 dkt 文件与其他工作正常的文件进行比较时,我无法确定错误所在。

Windows 事件查看器出现以下错误:

时间戳:18/4/2022 10:46:14 消息:HandlingInstanceID:c51c0798-ff33-416b-8822-8af2c40b9e33 发生并捕获了 'Artech.Common.Diagnostics.GxException' 类型的异常。

04/18/2022 10:46:14 类型:Artech.Common.Diagnostics.GxException、Artech.Common、版本=11.0.0.0、文化=中性、PublicKeyToken=6f5bf81c27b6b8aa 消息:输入文件有 1 个语法错误AttributeCategoryId.dkt(2,0):错误 DKT1:语法错误:不可恢复的语法错误

来源:Artech.Architecture.Common 帮助 link:异常数据产品:GeneXus 17 版本:17.0.158023 U8 Exception.Severity:错误目标站点:Boolean iEca3OpCse(Artech.Architecture.Common.Defaults .IApplyDefaultTarget,Artech.Architecture.Common.Defaults.IDfaultProvider,System.String,布尔值)HResult:-2146232832 堆栈跟踪:在 Artech.Architecture.Common.Defaults.DefaultManager.iEca3OpCse(IApplyDefaultTarget,IDfaultProvider,字符串,布尔值)在Artech.Architecture.Common.Defaults.DefaultManager.ApplyDefault(IApplyDefaultTarget 目标,布尔值 canDecline) 在 Artech.Architecture.Common.Objects.KBObject.Artech.Architecture.Common.Defaults.IApplyDefaultTarget.CalculateDefault() 在 Artech.Architecture.Common.Defaults .EntityDefault.SetIsDefault(Boolean value, Boolean fireCalculate) at Artech.Architecture.Common.Defaults.EntityDefault.set_IsDefault(Boolean value) at Artech.Architecture.Common.Objects.KBObject.set_IsDefault(Boolean value ) 在 Artech.Packages.Patterns.Engine.PatternInstanceGenerator.GenerateObject(IPatternBuildProcess buildProcess、PatternModel patternModel、PatternObject patternObject、PatternInstance 实例、PatternInstanceElement 元素、ApplySettings 设置)在 Artech.Packages.Patterns.Engine.PatternInstanceGenerator.GenerateObjects(IPatternBuildProcess buildProcess、PatternModel patternModel、Patter nInstance 实例、PatternObject patternObject、ApplySettings 设置)在 Artech.Packages.Patterns.PatternEngine.GenerateInstanceObjects(IPatternBuildProcess buildProcess、PatternModel patternModel、PatternInstance 实例、InstanceObjects instanceObjects、ApplySettings 设置、ApplyResults 结果)在 Artech.Packages.Patterns.PatternEngine.InternalApplyPattern(PatternInstance 实例、ApplySettings 设置)在 Artech.Packages.Patterns.PatternEngine.ApplyPattern(PatternInstance 实例,ApplySettings 设置)

附加信息:

时间戳:18/4/2022 13:46:14 全名:Microsoft.Practices.EnterpriseLibrary.ExceptionHandling,版本=3.1.0.0,文化=中性,PublicKeyToken=79a65ef946496ecc AppDomainName:GeneXus.exe

类别:默认类别优先级:0 EventId:100

AttributeCategoryId.dkt内容:

<%@ Template Language="C#" TargetLanguage="GX" Description="Grid Selected Objects SDT" %>
<%@ Include Name="Constants.cs" %>
<%@ Assembly Name="Artech.Patterns.Category" %>
<%@ Import Namespace="Artech.Patterns.Category" %>
<%@ Property Name="Object" Type="Artech.Architecture.Common.Objects.KBObject" %>
<%@ Property Name="Part" Type="Artech.Architecture.Common.Objects.KBObjectPart" %>
<%@ Property Name="Instance" Type="Artech.Packages.Patterns.Objects.PatternInstance" %>
<%@ Property Name="Element" Type="Artech.Packages.Patterns.Objects.PatternInstanceElement" %>
<%
    CategoryInstance catInstance = new CategoryInstance(Instance);
%>
<Object Type="Attribute" Id="CategoryId" name="<%= catInstance.AttributesName.CategoryId %>" description="<%= catInstance.AttributesName.CategoryId %>">
      <Properties><Property><Name>Name</Name><Value><%= catInstance.AttributesName.CategoryId %></Value></Property><Property><Name>Length</Name><Value>4</Value></Property><Property><Name>Decimals</Name><Value>0</Value></Property><Property><Name>AUTONUMBER</Name><Value>True</Value></Property><Property><Name>AUTONUMBER_START</Name><Value>1</Value></Property><Property><Name>IsDefault</Name><Value>False</Value></Property></Properties>
 </Object>

我需要调试 dkt 和应用模式过程来纠正这个错误。

查看此问题后,我们发现语法错误的原因是因为 dkt 换行符是 UNIX-style (\n),而模板解析器期望 Windows-style 行休息 (\r\ n).

将项目发布到 GitHub,然后将其下载为 zip,这是一个不幸的变化。如果从 Windows Git 客户端克隆存储库,则应恢复换行符。