数週間おきに、私はこれに遭遇します。Delphi プロジェクトの uses ユニットで IDE 操作を実行すると、.dpr
ファイルが破損します。
何が起こるかというと、uses
リストを再構築しますが、位置が間違っています。
このエラーに二度と遭遇しないように、どの使用パターンを避けるべきか疑問に思っています。
多くの Delphi バージョンでこのエラーが発生しました。少なくとも Delphi XE2 (今日も発生しました)、XE、2007、2006、および 7 に存在することを私は知っています。
マングルされたフラグメントは通常、次のように構造化されます。
ususes
Forms,
..
LastUnitInUses in 'LastUnitInUses.pas';
R *.RES}
us
を削除し、次を追加して修正する必要があります{$
。
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,
TestFramework,
GUITestRunner,
TextTestRunner,
SysUtilsFormatUnit in 'SysUtilsFormatUnit.pas';
{$R *.RES}
begin
Application.Initialize;
if IsConsole then
with TextTestRunner.RunRegisteredTests do
Free
else
GUITestRunner.RunRegisteredTests;
end.