New Filter Exceptions expert in GExperts

 Delphi, GExperts  Comments Off on New Filter Exceptions expert in GExperts
Jul 132020
 

I my last GExperts related blog post I wrote about the new “Close Exception Notification” expert which I just had added to GExperts. It was a hack that hooked the Exception Notification dialog.

This spawned a discussion in the international Delphi Praxis forum and resulted in a rewrite of the expert. It’s now called “Filter Exception” expert and instead of hooking the dialog it directly hooks into the code that shows this dialog. Thus it prevents the dialog from being shown for filtered exceptions.

I have to thank Mahdi Safsafi of Delphi Detours Library fame for the detective work that lead to to this hooking code.

In that same discussion Der schöne Günther suggested to add a project scope to the filtering. I have implemented that too.

So now the expert can filter on:

  • Project name, which is a regular expression.
  • Exception class
  • Exception message, which again is a regular expression

I have added all those exceptions that the Delphi IDE raises on every startup to my filter. It filters on the Project = “GExperts.*”, the exception classes and the messages it shows.

That means it will no longer annoy me with them while I am debugging GExperts but will still show them for other projects.

The filter details look like this:

It’s also possible to add a filter for the current debug session only, which means that it will be deleted automatically once the debug session ends.

Unfortunately hooking of the code is only available for Delphi 2005 and later. Older versions still have got to hook the Exception Notification dialog.

If you want to test this new functionality, you’ll have to compile your own dll. Try it, it’s not rocket science!

If you want to discuss this article, you can do so in the corresponding post in the international Delphi Praxis forum.

 Posted by on 2020-07-13 at 16:59

GExperts supports even more laziness

 Delphi, GExperts  Comments Off on GExperts supports even more laziness
Jul 042020
 

I got into programming because I am lazy, I’d rather have the computer do the boring work than doing it myself. So it’s no wonder that I always liked Delphi and GExperts because both support my laziness.

Today I added yet another feature to save me a key stroke or mouse click: The “Close Exception Notification” expert.

You probably have encountered those libraries that always raise the same exception class on errors, or even worse, raise the generic Exception class instead of bothering to declare their own. And if I should guess, you have probably been guilty of doing that yourself (as I definitely have).

Why is that a problem, you ask?

Because you can’t easily ignore these exceptions during debugging. You always get this “Debugger Exception Notification” dialog, have to read it and decide whether you want to break and look at the code or ignore the exception:

There is this nice option to “Ignore this exception type”, but unfortunately ignoring the exception class “Exception” is rarely an option.

The same problem occurs with other rather generic exceptions like EFOpenError which you can’t really simply ignore but need to check for the file name.

So, what we need is a more finely grained filter based on the message.

Enter the new “Close Exception Notification” expert. It adds a “GExperts” button (I need a better caption) to the dialog above which lets you add filters for Exceptions based on class name and message. And since it was more convenient for me (more laziness), the message filter is a regular expression.

This button will call a configuration dialog which allows you to configure how to handle the current exception.

This dialog is mostly pre-filled if opened through the button on the “Debugger Exception Notification” dialog.
You first enter (there will be some kind of recently used list in the future) the exception class name and then a regular expression for the message. In the simplest case this can be the whole message (but beware of characters which have a special meaning in regular expressions, like ‘.’, ‘*’, ‘?’ or ‘\’). There is an additional input field which you can use to test whether the regex matches the message. When you are satisfied with your newly created rule, select the action to take automatically and press OK. The dialog will close and the action will be executed for the first time, e.g. the Ignore button will automatically be pressed.

The “Close Exception Notification” expert does not have a menu entry. But there is a configuration dialog which gives you a list of currently configured filters.

Unfortunately since this expert cannot directly modify the IDE code and I am not aware of any Open Tools API access to the exception notification, it has to hack the dialog. This results in the dialog being displayed for a short time before the expert “presses” the button for you. This is certainly not ideal but still better than not having it.

There is no GExperts release with this new functionality yet, so in order to get it, you will have to compile your own DLL.

If you want to discuss this article, you can do so in the corresponding post in the international Delphi Praxis forum.

 Posted by on 2020-07-04 at 14:54

GExperts 1.3.16 experimental twm 2020-05-27 released

 Delphi, GExperts  Comments Off on GExperts 1.3.16 experimental twm 2020-05-27 released
May 272020
 

There they are, the promised GExperts 1.3.16 installers for older Delphi versions.

This time I didn’t blog much about the work I did on GExperts. I spent a lot of time actually working on it instead. There are lots of bug fixes and a few new features in the new version.

I hope this time the installers won’t be wrongly detected as malware by virus scanners. Sorry about that.

The new version is available for download on the GExperts download page.

 Posted by on 2020-05-27 at 21:14

GExperts 1.3.16 for Delphi 10.4

 Delphi, GExperts  Comments Off on GExperts 1.3.16 for Delphi 10.4
May 272020
 

Today I downloaded and installed the latest and greatest Delphi 10.4. The first thing to do, was of course compile GExperts for it.

Thanks to Achim Kalwa I already had a working project and he also made all other changes necessary to make it compile. So basically I loaded the project and pressed Compile.

A few tests have shown no problems, but I am sure there will be some. On the other hand I don’t want to be the one to find them all. That’s what users are for, aren’t they? 😉

OK, so if you are brave, you can download an installer for GExperts 1.3.16 for Delphi 10.4. Please file any bug reports and feature requests as tickets on SourceForge.

For those still using older Delphi versions, there will also be a GExperts 1.3.16 release shortly. Watch this space.

 Posted by on 2020-05-27 at 20:35

More features for the IFDEF expert in GExperts

 Delphi, GExperts  Comments Off on More features for the IFDEF expert in GExperts
Apr 262020
 

The IFDEF editor expert was added to GExperts in 2016 and improved again in the same year, to support symbols defined in include files.

Unfortunately sometimes an include file itself sometimes includes other files (e.g. jclNN.inc in the JEDI Code Library includes jedi.inc) which will usually add additional symbols which are then available for conditional compilation. But the IFDEF expert only listed symbols from the original include file.

This has irked me for a long time, so today I changed this: Every include file that is included via an include file (and recursively via these include files) is now listed in the IFDEF expert:

In this example dzlib.inc itself includes dzlibjedi.inc which is simply a copy of jedi.inc. (I don’t want to include jedi.inc directly in order to not have a stale file laying around which might break compilation of other libraries.) The expert lists this file as if it had been included in the unit source code in addition to dzlib.inc.

And, since I seem to have forgotten to blog about it: The expert also searches for available include files in the search path and allows you to add them:

Just select the file from the menu and select the symbol you want to use. The required include directive will automatically be added to the interface section of the current unit.

If you want to discuss this blog post, go to the corresponding post in the international Delphi Praxis forum.

 Posted by on 2020-04-26 at 13:20

DUnit Folder Iterator Extension

 Delphi, GExperts  Comments Off on DUnit Folder Iterator Extension
Dec 282019
 

In 2012 Uwe Raabe blogged about an extension to the DUnit framework he had written. He mentioned it today in the German Delphi Praxis forum.

Guess what? It’s brilliant. It does exactly what I always wanted to write (and never came around doing) for the Unit Tests of the GExperts Code Formatter.

Those tests basically consist of a set of input files in one directory and for each of the tested configurations another set of files with the expected output. It always irked me that I actually had to write some code every time I added a new test instead of simply adding another bunch of files.

Today I changed those tests to use Uwe’s unit (with a few modifications to make it compatible to Delphi 2007). And I found that there were quite a few files which didn’t even get tested at all, because I forgot to add the code.

I’m happy to report that even with these additional tests, the number of failed tests did not increase.

 Posted by on 2019-12-28 at 19:18

The annoying problem of the growing GExperts menu

 Delphi, GExperts  Comments Off on The annoying problem of the growing GExperts menu
Dec 252019
 

As I add new functionality to GExperts the menu it displays grows larger and larger. On small monitors (there are still computers with e.g. 1024×600 pixels screen size in use, usually not with the latest Delphi version though) this means that the menu has to be broken into chunks, each with a “more” entry at the end to display the next chunk.
While this has been implemented for years (decades actually) it didn’t work very well. For Delphi 6 the code was completely broken (I might have been the culprit myself) it still had some bugs with all later versions.

No more. Today I fixed those bugs and tested it with screens as small as 640×480 pixels.

Also, when moving the GExperts menu into the Tools menu, there was a problem that the maximum number of entries for a chunk was not calculated correctly which would mean that the “more” entry could end up outside the visible area. This has also been fixed.

Unfortunately this does not solve the underlying problem: The menu keeps growing. There are now a maximum of 45 + 3 Entries in that menu. The way that menu is created on demand, depending on which experts are enabled or not, does not lend itself to a sensible menu structure.

I have added a “Category” property to each expert, which so far is neither filled nor used anywhere. I plan to create only one entry per Category in the GExperts menu with sub menus for each category. Maybe I will even make those categories configurable. But that’s for another day.

 Posted by on 2019-12-25 at 18:34

Working on the GExperts Code Formatter again

 Delphi, GExperts  Comments Off on Working on the GExperts Code Formatter again
Nov 302019
 

The code formatter can now handle inline variable declarations. That was actually just a simple change (fixes bugs #157 and #158 (and the duplicate #165))

Now I’m trying to get it to format function declarations like this:

function RegisterClipboardFormatW(lpszFormat: PWideChar): UINT; stdcall;
  external user32 Name 'RegisterClipboardFormatW';

or something as simple as this;

procedure bla;
  overload;
  forward;

Currently it doesn’t indent the additional lines. It works fine for method declarations though.

This turns out to be much more complicated than I thought. In my attempts to fix this, I have multiple times broken other test cases. Good thing there’s unit tests and source code management.

By pure chance I found a nasty side effect in the code.

 Posted by on 2019-11-30 at 20:23

GExperts 1.3.15 installers were/are detected as malware

 Delphi, GExperts  Comments Off on GExperts 1.3.15 installers were/are detected as malware
Nov 282019
 

The installers for GExperts 1.3.15 were/are detected as malware by several virus scanners on Virus Total. I have since submitted them all as false positives to Kaspersky and some to Microsoft and after their latest signature updates their scanners are now fine. I tried the same with other virus scanner vendors, but their procedure was so complicated that I decided that it is not worth the effort. So if you are using BitDefender or McAfee, you might be out of luck. Try to submit your installer to them yourself if you like, just so you see how much time that takes. Now multiply that by 19 installers and > 10 virus scanners … I guess you will understand then why I don’t bother.

 Posted by on 2019-11-28 at 17:45

GExperts 1.3.15 experimental twm 2019-11-23 released

 Delphi, GExperts  Comments Off on GExperts 1.3.15 experimental twm 2019-11-23 released
Nov 232019
 

I just released GExperts 1.3.15 for all supported Delphi versions.

There have again been various bug fixes and the following notable changes:

  • There is now a start menu entry for a new stand alone version of the GExperts Code Formatter. Note that it not only has a GUI for selecting a single file to format and show the settings dialog, but can also be called with a list of files to be formatted. So, you could for example drag a group of files onto the executable to format them all. I plan to expand that command line interface in the future to allow formatting all files in a project or in a directory and its subdirectories.
  • Talking about the code formatter: Many more bugs have been fixed. A while ago I was actually thinking I got them all, but unfortunately that turned out to be a delusion. 😉
  • The GoTo Line Number dialog enhancer has been removed and replaced with a Go To expert with the same functionality but its own dialog, which has a setting to replace the Search -> Go to Line Number menu entry. If you have any suggestions on further improving that expert, please file a feature request.
  • Bugfix for the PE Information expert: It should now display all exported class names.
  • Many changes to the Uses Clause Manager expert (most of them contributed by Peter Panettone)
    • Bugfixes for the Identifier tab. It wrongly found some identifiers that just weren’t exported from that unit
    • It now highlights any units it will add.
    • It can now parse map files generated by the Win64 compiler, not just those from the Win32 compiler
    • It now shows an error message if it cannot use the map file and resorts to the dpr file.
    • The filter on the Identfier tab now has two modes:
      • Match anywhere
      • Match at start
    • There is now a status bar that shows the full file name of the currently selected unit. A popup menu allows to
      • Copy that file name to the clipboard
      • Copy that file to the clipboard (like pressing Ctrl+C on the file name in the Windows File Explorer)
      • Open the file’s location in the Windows File Explorer
    • The library path for Delphi XE and later was wrong, so the VCL/RTL tab was always empty.
  • There was a bug with the Clipboard History expert: It still hooked the clipboard even if it was disabled. In addition it could kill the IDE when it added new entries to the (possibly invisible) list view. Under some strange conditions setting the text of a memo apparently can fail with an EInvalidOperation exception. This exception was not caught and since it happened deep inside a chain of event handlers, it caused an Access Violation somewhere which then silently killed the IDE. That one was quite difficult to track down.
  • Improvement to the Backup Project expert: A new dialog shows any files it cannot find and it only shows each file once, not every time it does not find it. This was particularly annoying with include files.
  • And last, but not least: The GExperts version for Delphi 10.3 is now compiled with the latest and greatest Delphi 10.3 update 3 release. Let’s hope this fixed some bugs and hasn’t introduced any new ones. (Unfortunately RSP-25645 “Creating sub components with IOTAFormEditor.CreateComponent raises access violation” still hasn’t been fixed, so replacing e.g. TTable with TSqlTable still does not work.)

The new version is available for download on the GExperts download page.

 Posted by on 2019-11-23 at 19:09