The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,862 other subscribers

Archive for the ‘Conferences’ Category

Fixing the WSDLImp command-line Delphi WSDL importer to parse WSDL files including XSD files using xsd:group at the top level

Posted by jpluimers on 2018/05/24

I finally found out the cause of the Delphi WSDL Importer generating wrong .pas files when the WSDL file includes an XSD file that uses an xsd:group (see below) at the top-level.

The resulting access violation was caused by forgetting a nil check for a Context (at the top-level it is nil because there is no encompassing type yet; xsd:group can be at the top-level).

There might also be other WSDL/XSD constructs leading to the same code path: a good set of WSDL/XSD combination would be needed for proper integration testing on this. Hopefully, Embarcadero has such a set.

Patches

All patches are at https://gist.github.com/jpluimers/2824c03ae816229a53ffa4830b2d6208. If you need a binary build that includes the patches, drop a comment below.

Before fixing, I had to get it building which required modifying the search path and output path (both see Delphi WSDL importer compiler defines). This is the first patch below (which results includes a huge .dproj change as that’s what the IDE does to a project when you change just a few simple things).

The second patch below is the fix.

The fix is to replace if (TypeDef.IsAnonymous) then by if (TypeDef.IsAnonymous) and Assigned(Context) then in side the function TWSDLTypeImporter.AddComplexType of WSDLImpWriter.pas.

After careful checking of the group handling (around etElementGroup, cmGroupRef,  xtiElemGroupIXMLElementGroup, IXMLElementGroups), no other fixes are needed as the rest of the xsd:group handling functions correctly at least for the WSDL/XSD combinations I had to import.

During fixing, I found some compiler defines would produce much more output. That output tremendously helped finding out if xsd:group handling was indeed correct.

In the third patch, I have added another modification that introduces a new -logall command-line parameter that enables all these in one go.

I have handed over the patches through internal channels in order to circumvent a long and tedious QC/QualityPortal process. Hopefully they will make it in the next major Delphi version.

Related

Patches generated by following the steps in [WayBack] Generate a git patch for a specific commit – Stack Overflow:

git format-patch -1 <<commit-SHA>>

Command-line parameters

The WSDLImp has many command-line parameters, some of which are not accessible from the IDE expert. More information on these at:

xsd:group

An xsd:group contains a group of definitions. It is similar to a list of fields in a record/class/interface in Delphi that you can use in multiple record/class/interface definitions. The group only has a name at the XSD level, but not at the Delphi generated code level: there the group is expanded in each place it is used.

More information: [WayBack] xsd – How to use the xml schema group element – Stack Overflow

–jeroen

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 12 Comments »

Delphi WSDL importer compiler defines

Posted by jpluimers on 2018/05/22

As a follow-up on Delphi WSDL default importer settings, you can use these compiler defines to increase output.

Output that the built-in Wizard will never show you (that is also the reason you will not see any errors like access violations in the IDE).

TL;DR

Always use the command-line WSDL importer WSDLImp as it has the same default options as the IDE.

The command-line WSDL importer called WSDLImp does show error messages, but in case of an error still continues writing the wrong .pas file.

Syntax:

"C:\Program Files (x86)\Embarcadero\Studio\19.0\bin\WSDLImp.exe" -DD:\Playground\iECK_ImportWSDL "D:\Playground\iECK DT2.0 services v2.1.1\wsdl\ECK-DT2-CatalogService-v2.1.1.wsdl"

When debugging the code, I found out there are many conditional defines you can enable so it shows more output. Output that greatly helps to pin-point issues while importing more complex WSDL, especially when the WSDL has include or import elements.

These are the defines:

  • TRACK_MEMORY this requires the FastMM4 unit in the path
  • SHOW_XML_INFO
  • LOG_TYPES_DUMP
  • LOG_TYPES_LOOKUP
  • LOG_TYPES_READING
  • LOG_TYPES_SORTING
  • LOG_TYPES_UNWIND
  • LOG_TYPES_WRITING

The really odd thing is that there is a hidden command-line option -debug which does not automatically enable these, but does use SHOW_XML_INFO which seems enabled by default and writes an output file with extension .xml in addition to .pas, where the XML has an overview of the parsed data types.

I am going to fiddle around to see if I can enable all of the LOG_ entries from the command-line in a simple way.

When you debug the WSDLImp tool, ensure these two directories are on the unit search path:

  • $(BDS)\source\soap
  • $(BDS)\source\xml

The first is needed so the compiler can find CompVer.inc, the second so you can step through the XML handling code.

Also make sure you change the output path from $(BDS)\bin (which only works under UAC and overwrites the stock output) with something like .\$(Platform)\$(Config) (which  puts it along the .DCU files).

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 1 Comment »

Delphi: a pattern for a generic factory, this one for components, but can be uses for anything having a base class like a TThread descendant.

Posted by jpluimers on 2018/05/16

Generics and constraints in Delphi is still a bit of pain.

A while ago, I needed a factory for threads. It was more convoluted than I meant it to be, so I had a short chat with Stefan Glienke.

He came up with an example similar to the one below. I tore it apart so you can on each line see what the compiler dislikes.

This fails, but was kind of how I wanted it to be:

type
   TFactory = record
     class function Manufacture<T: TBaseClass, constructor>(parameter definitions): T;
   end;

class function Manufacture<T: TBaseClass, constructor>(parameter definitions): T;
begin
  Result := T.Create(parameter values);
end;

Which means I need to update Delphi Constraints in Generics – RAD Studio XE documentation wiki

The factory:

type
  TComponentFactory = class
    class function CreateComponent<T: TComponent>(AOwner: TComponent): T; static;
  end;

class function TComponentFactory.CreateComponent<T>(AOwner: TComponent): T;
var
  ComponentClass: TComponentClass;
  Component: TComponent;
begin
  ComponentClass := T;
  Component := ComponentClass.Create(AOwner); // you can't do `T.Create(AOwner)`
  Result := T(Component); // you can't do `Result := ComponentClass.Create(AOwner);`
end;

The usage:

var
  Component: TButton;
  Owner: TComponent;
begin
  Owner := Application.MainForm;
  Component := TComponentFactory<TButton>.CreateComponent(Owner);
  Component.Parent := Owner;
end;

Full source example is at: After a discussion with Stefan Glienke: a pattern for a factory, this one for components, but can be uses for anything having a base class like a TThread descendant.

In the mean time, Spring4D has added the [Archive.is] Spring4D: TActivator record with many CreateInstance methods that allow you to create instances of classes for which you just have type information.

–jeroen

This fails:

type
   TFactory = record
     class function Manufacture<T: TBaseClass, constructor>(parameter definitions): T;
   end;

class function Manufacture<T: TBaseClass, constructor>(parameter definitions): T;
begin
  Result := T.Create(parameter values);
end;

view raw

readme.md

hosted with ❤ by GitHub


type
TComponentFactory = class
class function CreateComponent<T: TComponent>(AOwner: TComponent): T; static;
end;
class function TComponentFactory.CreateComponent<T>(AOwner: TComponent): T;
var
ComponentClass: TComponentClass;
Component: TComponent;
begin
ComponentClass := T;
Component := ComponentClass.Create(AOwner); // you can't do `T.Create(AOwner)`
Result := T(Component); // you can't do `Result := ComponentClass.Create(AOwner);`
end;


var
Component: TButton;
Owner: TComponent;
begin
Owner := Application.MainForm;
Component := TComponentFactory<TButton>.CreateComponent(Owner);
Component.Parent := Owner;
end;

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

Delphi WSDL default importer settings

Posted by jpluimers on 2018/05/15

Note to self (as the WSDL importer has trouble with WSDL files that include XSD files having xsd:group definitions), the default settings of the importer in the UI:

-Oa -Od -Oe -Of -Oh -Oi -Oj -Oo -Op -Ot -Ou -Ov -Ox

This matches the output from the WSDLImp.exe default settings as well (larger screenshots below):

I suspect the reason is that the command-line importer does, but the wizard does not, show an exception during processing:

*Error*: D:\Playground\iECK DT2.0 services v2.1.1\xsd\ECK-DT2-CatalogServiceSchema-v2.1.1.xsd
> Access violation at address 0059DBA4 in module 'WSDLImp.exe'. Read of address 00000000
Done : D:\Playground\iECK DT2.0 services v2.1.1\wsdl\ECK-DT2-CatalogService-v2.1.1.wsdl>0
Writing: D:\Playground\iECK_ImportWSDL\ECK_DT2_CatalogService_v2.pas

Hopefully more on that later.

Both the IDE expert and console based WSDLimp will write the output .pas file and the output file of both tools has the same content.

–jeroen

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

Procedural Programming: It’s Back? It Never Went Away – Kevlin Henney [ACCU 2018] – YouTube

Posted by jpluimers on 2018/05/09

If you haven’t been in the software development arena for the last 50 years, then watch this and learn all “modern” stuff has been around for ages:

Most if it comes from the era of Algol, make, AWK and the famous Structured Programming book (which is not about procedures, but about control flow).

So watch Procedural Programming: It’s Back? It Never Went Away – Kevlin Henney [ACCU 2018] – YouTube

Slide deck: Sideshare: Procedural Programming: It’s Back? It Never Went Away – Kevlin Henney [ACCU 2018]

Then read [WayBack] ISBN 9780122005503 – Structured Programming (A.P.I.C. studies in data processing, no. 8)

Via: [WayBack] Kevlin Henney – Google+

–jeroen

Read the rest of this entry »

Posted in Agile, Conference Topics, Conferences, Development, Event, Paradigms, Software Development | Leave a Comment »

Delphi .dproj file changed or not changed? Normalize it! | The Art of Delphi Programming

Posted by jpluimers on 2018/05/02

Cool tool that integrates into the Delphi IDE: [WayBackDproj changed or not changed? Normalize it! | The Art of Delphi Programming

Via: [WayBack] Introducing DprojNormalizer: http://www.uweraabe.de/Blog/2017/01/18/dproj-changed-or-not-changed/ – Uwe Raabe – Google+

Note there is also RadCLI that requires Python and does it via the command-line:[WayBackjoshkel/RadCli: Command-line utilities for RAD Studio / Delphi / C++Builder

DprojNormalizer supports Delphi XE7 and up.

Updates at [WayBack] Downloads | The Art of Delphi Programming: DprojNormalizer

Note that it requires an elevation to Administrator for installing. If you run Delphi as a normal user, then afterwards you need to register the package yourself, for instance with a batch file like this:

reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\18.0\Known Packages" /v "C:\Program Files (x86)\DprojNormalizer\DprojNormalizer240.bpl" /t REG_SZ /d "Dproj Normalizer" /f
reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\19.0\Known Packages" /v "C:\Program Files (x86)\DprojNormalizer\DprojNormalizer250.bpl" /t REG_SZ /d "Dproj Normalizer" /f

Adjust your BDS and DllSuffix in the BPL file names using the table at Delphi version info table: C# Builder, Delphi 8 through 10.2 Tokyo and Appbuilder.

If you want to temporarily disable it:

reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\18.0\Disabled Packages" /v "C:\Program Files (x86)\DprojNormalizer\DprojNormalizer240.bpl" /t REG_SZ /d "Dproj Normalizer" /f
reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\19.0\Disabled Packages" /v "C:\Program Files (x86)\DprojNormalizer\DprojNormalizer250.bpl" /t REG_SZ /d "Dproj Normalizer" /f

If you want to re-enable it: remove the values under Disabled Packages.

–jeroen

 

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 1 Comment »

Do not use non-ASCII characters as identifiers – not all your tools support them well enough

Posted by jpluimers on 2018/04/05

For a very long time I’ve discouraged people from using non-ASCII characters in identifiers. It still holds.

In the past, transliterations messed things up. Even with increased support for Unicode, tools still screw non-ASCII characters up.

Delphi is not alone in this (the most important one is the DFM view as text support), see this report: [RSP-16767] Viewing a form as text fails with non ascii control or event names – Embarcadero Technologies (you need an account for this, but the report is visible for anyone):

Viewing a form as text fails with non ascii control or event names Comment

Steps:

  1. create a new VCL forms application
  2. drop a label onto the form
  3. change the name of that label to lblÜberfall (note the U-umlaut)
  4. switch to view as text
  • exp: DFM content shown as text
  • act: first line is shown incorrectly (see screenhsot)

–jeroen

Source: [RSP-16767] Viewing a form as text fails with non ascii control or event names – Embarcadero Technologies

via: [WayBack] Code of the day – – Thomas Mueller (dummzeuch) – Google+:

function TNameGenerator.StrasseToStrasse(const _Strasse: string): string;
begin
Result := _Strasse;
end;

Strasse := StrasseToStrasse(_Strasse);

Read the rest of this entry »

Posted in ASCII, Conference Topics, Conferences, Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Encoding, Event, Mojibake, Software Development | Leave a Comment »

GetPublished – Author Information

Posted by jpluimers on 2018/02/01

One day I must re-publish these papers:

Author Information

ID: 1454
First name: Jeroen W.
Last name: Pluimers
User name:
Biography: Jeroen Pluimers has had a long history in software development ranging from high-level knowledge-based systems to low-level communcation. After discovering his love for teaching, he started one of the first Delphi consulting firms in Europe, and has been speaking at national and international conferences ever since. He presents on Delphi, C#, the Microsoft .NET Platform, and Linux. Jeroen is a Certified Delphi Developer and Borland Certified Instructor. Jeroen’s strength is in getting totally different technologies to work together. He likes to integrate different languages, platforms, frameworks, and databases. As a bug hunter and idea generator, Jeroen has contributed to many products such as Developer Express? Component Development Kit and Borland Delphi. In his free time, Jeroen plays percussion in a world-famous marching band. He also enjoys reading fine books and sampling foreign cuisines.
Image not available

[WayBack] GetPublished – Author Information

From the referencing pages:

Administrating and Configuring Linux for Kylix

Intermediate paper for Delphi programmers starting to use Linux. It explains how to use and integrate Linux and Kylix with Windows and Delphi.�

The Delphi Developer’s Guide to C#

As a Delphi developer, you will find C# easier to learn than you might have thought. Get a head start with this revealing presentation.�

Choosing COM, CORBA or SOAP: What Do they Share and What Sets them Apart

This session describes COM, CORBA and SOAP, indicating what they share, what sets them apart, and how you can choose among them.�

CASE STUDY: ReCruit — Matching and Administration for Recruitment

This session provides a demonstration of ReCruit, including a discussion of its development and deployment process. ReCruit was built using Delphi and InterBase.�

–jeroen

Posted in BorCon, C#, Conferences, Delphi, Development, Event, SOAP/WebServices, Software Development | Leave a Comment »

As Delphi generics are not supported for free functions, wrap them in a record container.

Posted by jpluimers on 2018/01/31

Of the things not possible with generics in Delphi, I already wrote about Impossible: Property using Generics in Delphi.

Now it’s time to write about simulating a free function with generics as this is impossible:

function CreateManaged<T>(const value: T): IManaged<T>;

Usually I create a static record method for these, as records do not have VMT overhead, less RTTI overhead and I’ve been used to see records as helpers for other types long before helpers initially were introduced in Delphi 8 to extend classes..

Spring4D has an excellent example of such a record workaround in the Managed.New<T> commit:

type
  Managed = record
  public
    class function New<T>(const value: T): IManaged<T>; static;
  end;

...

class function Managed.New<T>(const value: T): IManaged<T>;
begin
  Result := TManaged<T>.Create(value);
end;

It basically is a factory for classes implementing the IManaged interface.

In the mean time, Managed has been renamed to Shared but the above code shows my point.

–jeroen

Reference: [WayBackClass Helpers documented in Delphi 2007, introduced in Delphi 8

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 5 Comments »

Record helpers can do wonders for code clarity.

Posted by jpluimers on 2018/01/04

A few people recently discovered the beauty of record helpers:

Record helpers can help any value type (which includes enumerated types) so you can add functions to enumerations.

Class helpers can help class types.

There are no interface helpers and likely won’t be there for a long while.

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Power User, Software Development | 2 Comments »