不要做什么来阻止Delphi在.DPR中修改使用列表和{$*.RES}
发布时间:2020-12-15 09:51:25 所属栏目:大数据 来源:网络整理
导读:每隔几周,我就会碰到这一点:当在Delphi项目中对使用单元进行IDE操作时,它会破坏.dpr文件. 会发生什么,它重建使用列表,但错误的位置. 我想知道要避免哪种使用模式,所以我不会再次遇到这个错误. 我在许多Delphi版本中都出现过这种错误.我知道它至少存在于Delp
每隔几周,我就会碰到这一点:当在Delphi项目中对使用单元进行IDE操作时,它会破坏.dpr文件.
会发生什么,它重建使用列表,但错误的位置. 我想知道要避免哪种使用模式,所以我不会再次遇到这个错误. 我在许多Delphi版本中都出现过这种错误.我知道它至少存在于Delphi XE2(今天又发生在那里),XE,2007,2006和7. 受损的片段通常是这样构造的: ususes Forms,.. LastUnitInUses in 'LastUnitInUses.pas'; R *.RES} 并应删除一个我们,并添加{$: uses Forms,.. LastUnitInUses in 'LastUnitInUses.pas'; {R *.RES} 出错的示例文件: program SysUtilsFormatTests; { Delphi DUnit Test Project ------------------------- This project contains the DUnit test framework and the GUI/Console test runners. Add "CONSOLE_TESTRUNNER" to the conditional defines entry in the project options to use the console test runner. Otherwise the GUI test runner will be used by default. } {$IFDEF CONSOLE_TESTRUNNER} {$APPTYPE CONSOLE} {$ENDIF} ususes Forms,TestFramework,GUITestRunner,TextTestRunner,SysUtilsFormatUnit in 'SysUtilsFormatUnit.pas'; R *.RES} begin Application.Initialize; if IsConsole then with TextTestRunner.RunRegisteredTests do Free else GUITestRunner.RunRegisteredTests; end. 更正的.dpr文件示例: program SysUtilsFormatTests; { Delphi DUnit Test Project ------------------------- This project contains the DUnit test framework and the GUI/Console test runners. Add "CONSOLE_TESTRUNNER" to the conditional defines entry in the project options to use the console test runner. Otherwise the GUI test runner will be used by default. } {$IFDEF CONSOLE_TESTRUNNER} {$APPTYPE CONSOLE} {$ENDIF} uses Forms,SysUtilsFormatUnit in 'SysUtilsFormatUnit.pas'; {$R *.RES} begin Application.Initialize; if IsConsole then with TextTestRunner.RunRegisteredTests do Free else GUITestRunner.RunRegisteredTests; end. 解决方法
我知道唯一可行的是让IDE让你管理.dpr文件.
>不要添加评论. 如果您执行上述任何操作,请期待IDE退回. 就个人而言,我做了所有这些并在提交时反击.我使用我的VCS来防御伪造IDE的变化.这不是理想的,但它是最好的选择. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |