• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Introducing the Delphi Upgrade Advisor Wizard

Sascha Оффлайн

Sascha

Заместитель Администратора
Команда форума
Администратор
Регистрация
9 Май 2015
Сообщения
1,477
Баллы
155
The new Delphi Upgrade Advisor wizard in RAD Studio 13 enables developers to identify meaningful changes to project configuration and code, significantly improving compilation time and the overall code tooling experience. The wizard is available as a separate GetIt package. Once installed, it will add a menu item to the IDE.

Besides providing some specific suggestions, the Delphi Upgrade Advisor wizard comes with reFind scripts you can use to clean up the project’s uses statements.


Table of Contents

How To Install


The Delphi Projects Upgrade Advisor package is available in the GetIt package manager for customers with an active update subscription:

rad13advisor 01


Once installed you can find a new menu item under Tools, as shown here:

rad13advisor 02


The Wizard


The wizard works on the active project. For this reason, before you activate it, you should open an existing project you want to test. In general terms you should open an old project, not one created with RAD Studio 13 or 12, as those will probably not include the old coding styles worth fixing.

This is the UI of the wizard:

rad13advisor 03


As you can see, the wizard offers 4 different operations you can enable or disable. Three of them work directly on the project and the IDE configuration. The fourth requires generating a separate file first. Let’s cover each of these options.

Check for Invalid Path


Having invalid paths in the search or library path can slow down compilation, as the operating system calls to check for or try to open an invalid location are expensive. This is a fairly minor issue, but with many invalid paths and hundreds of units to look for, it can affect performance. This is an example of the output:

Start of the task: Check for Invalid Library Paths [OSX64] Directory not found "$(BDSUSERDIR)Imports$(Platform)" [OSX64] Directory not found "$(BDSCOMMONDIR)Dcp$(Platform)" [OSX64] Directory not found "$(BDSCOMMONDIR)Bpl$(Platform)" [Android64] Directory not found "$(BDSCOMMONDIR)Dcp$(PLATFORM)" [Win64] Directory not found "$(BDSUSERDIR)Imports$(Platform)" [Win64] Directory not found "$(BDSCOMMONDIR)Dcp$(Platform)" [OSXARM64] Directory not found "$(BDSUSERDIR)Imports$(Platform)" [OSXARM64] Directory not found "$(BDSCOMMONDIR)Dcp$(Platform)" [OSXARM64] Directory not found "$(BDSCOMMONDIR)Bpl$(Platform)" [iOSDevice64] Directory not found "$(BDSCOMMONDIR)Dcp$(PLATFORM)" [iOSSimARM64] Directory not found "$(BDSCOMMONDIR)Dcp$(PLATFORM)" [Win64x] Directory not found "$(BDSUSERDIR)Imports$(Platform)" [Win64x] Directory not found "$(BDSCOMMONDIR)Dcp$(Platform)" [Linux64] Directory not found "$(BDSCOMMONDIR)Dcp$(Platform)" [Linux64] Directory not found "$(BDSCOMMONDIR)Bpl$(Platform)" The task is completed Start of the task: Check for Invalid Project Search Paths Current Project: ViewDateDemo.dproj [Win32-Debug] Directory not found "C:/foo/bar" The task is completed
Start of the task: Check for Invalid Library Paths
[OSX64] Directory not found "$(BDSUSERDIR)Imports$(Platform)"
[OSX64] Directory not found "$(BDSCOMMONDIR)Dcp$(Platform)"
[OSX64] Directory not found "$(BDSCOMMONDIR)Bpl$(Platform)"
[Android64] Directory not found "$(BDSCOMMONDIR)Dcp$(PLATFORM)"
[Win64] Directory not found "$(BDSUSERDIR)Imports$(Platform)"
[Win64] Directory not found "$(BDSCOMMONDIR)Dcp$(Platform)"
[OSXARM64] Directory not found "$(BDSUSERDIR)Imports$(Platform)"
[OSXARM64] Directory not found "$(BDSCOMMONDIR)Dcp$(Platform)"
[OSXARM64] Directory not found "$(BDSCOMMONDIR)Bpl$(Platform)"
[iOSDevice64] Directory not found "$(BDSCOMMONDIR)Dcp$(PLATFORM)"
[iOSSimARM64] Directory not found "$(BDSCOMMONDIR)Dcp$(PLATFORM)"
[Win64x] Directory not found "$(BDSUSERDIR)Imports$(Platform)"
[Win64x] Directory not found "$(BDSCOMMONDIR)Dcp$(Platform)"
[Linux64] Directory not found "$(BDSCOMMONDIR)Dcp$(Platform)"
[Linux64] Directory not found "$(BDSCOMMONDIR)Bpl$(Platform)"
The task is completed
Start of the task: Check for Invalid Project Search Paths
Current Project: ViewDateDemo.dproj
[Win32-Debug] Directory not found "C:/foo/bar"
The task is completed

As you can see, it found an invalid path in the project search path. We recommend removing any illegal folder from your configurations.

Unit Aliases



Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

were introduced in Delphi 2 for compatibility with Delphi 1 and they remained a predefined configuration for new projects for many years afterwards. If you have been maintaining old projects and moving them to newer versions, you might have this leftover configuration, which the compiler needs to check very frequently when you use units.

Over the years, other unit aliases have been added to overcome changes in the unit’s structure. Again, this is a sample output for an old project:

Start of the task: Check For Unit Aliases Current Project: ViewDateDemo.dproj [Win32-Debug] Aliases were found "Actions=ActnList;ImageList=Controls" The task is completed
Start of the task: Check For Unit Aliases
Current Project: ViewDateDemo.dproj
[Win32-Debug] Aliases were found "Actions=ActnList;ImageList=Controls"
The task is completed

We recommend replacing unit names with the correct ones and removing the unit aliases configurations in the project options. To replace units, you can use the specific reFind script included with the GetIt package of the wizard and covered later.

Unqualified Unit Names


The third test is for unqualified unit names, like “uses Forms” rather than “uses VCL.Forms. Having to try all prefixes for all units adds a lot to the compiler. Therefore we recommend cleaning up. Notice that the tool doesn’t search the actual code for unqualified unit names. It checks the project configuration, recommending removing that entry:

This is a sample output:

Start of the task: Check For Unqualified Unit Names Current Project: ViewDateDemo.dproj [All-Base] Unit scope names were found "Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi" [Win32-Base] Unit scope names were found "System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde" The task is completed
Start of the task: Check For Unqualified Unit Names
Current Project: ViewDateDemo.dproj
[All-Base] Unit scope names were found "Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi"
[Win32-Base] Unit scope names were found "System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde"
The task is completed

Now once you remove that entry, you’re likely going to get errors like:

F2063 Could not compile used unit 'Forms' at line 6 (6:31)
F2063 Could not compile used unit 'Forms' at line 6 (6:31)

Again, to correct the unit names in the uses statements, you can use the specific reFind script included with the GetIt package of the wizard and covered later.

Circular Unit References


The fourth option is checking for circular unit references. In this case the process has two steps. First you have to enable the generation of the GraphViz file in the compiler options (see

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

), compile the project and next you have to select the file in the wizard.

This is a sample output, excluding system libraries (you can also exclude VCL libraries from the GraphViz file with the additional –graphviz-exclude parameter)

Start of the task: Check for Circular Unit References DateF has a circular uses statement: └─DatesUnit (interface) └─DateF (implementation) DatesUnit has a circular uses statement: └─DateF (implementation) └─DatesUnit (interface) The task is completed
Start of the task: Check for Circular Unit References
DateF has a circular uses statement:
└─DatesUnit (interface)
└─DateF (implementation)
DatesUnit has a circular uses statement:
└─DateF (implementation)
└─DatesUnit (interface)
The task is completed

By examining the GraphViz file, the wizard can spot cycles and display them, something very complex to do for a very large graph.

Now some uses unit cycles are unavoidable, but you should review the cycles in your applications and consider which can be avoiding by improving the code organization and architecture. In general terms, this is a good exercise to help you remove dependencies across modules.

The Wizard, Again


This is the actual wizard in action:

rad13advisor 04


The Uses Statement Refind Script


There is an additional file that ships in the GetIt package and that you can find in the package folder (a folder you can open with a new command in the GetIt package manager dialog box). It’s called RenameUnits.txt and it’s a script you can pass to the

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

to convert units for both aliases and unqualified units. The script (which you can of course adapt to your specific project needs) has hundreds of lines like:

#replaceunit ABAccessibility->Vcl.ABAccessibility #replaceunit ADOConEd->Data.Win.ADOConEd #replaceunit ADOConst->Data.Win.ADOConst #replaceunit ADODB->Data.Win.ADODB #replaceunit ADOInt->Winapi.ADOInt #replaceunit ADSTypes->Web.Win.ADSTypes #replaceunit AVFoundation->Macapi.AVFoundation
#replaceunit ABAccessibility->Vcl.ABAccessibility
#replaceunit ADOConEd->Data.Win.ADOConEd
#replaceunit ADOConst->Data.Win.ADOConst
#replaceunit ADODB->Data.Win.ADODB
#replaceunit ADOInt->Winapi.ADOInt
#replaceunit ADSTypes->Web.Win.ADSTypes
#replaceunit AVFoundation->Macapi.AVFoundation

We recommend running reFind with this script on your entire project, after making a copy of the original source. Once this is done, you should be able to remove the project’s settings flagged by the wizard and have an application that compiles a little faster.

Conclusion


The Delphi Projects Upgrade Advisor can help you cleanup existing old (and large) Delphi applications, so that their more modern code can be processed faster by the compiler (and the DelphiLSP engine). over the years we have witnessed some customers with large applications benefit from similar transformations, and we have now released the tools to help you do the same much faster.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.





Источник:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу