Enumerated constants property does not stream

delphi, delphi-xe

Solution

Unfortunately this is a limitation of the streaming system. The documentation says (emphasis mine):

Some properties, although publishable, are not fully supported by the streaming system. These include properties of record types, array properties of all publishable types, and properties of enumerated types that include anonymous values. If you publish a property of this kind, the Object Inspector will not display it correctly, nor will the property's value be preserved when objects are streamed to disk.

You can't workaround that easily and would need to provide your own custom streaming.

Problem

Given the following type declaration: ``` TMyEnum = (onehundred,twohundred,threehundred); TMyEnum2 = (Aonehundred = 100 , Atwohundred = 200 , Athreehundred = 300); TMyComponent = class(TComponent) private FMyEnum: TMyEnum; FMyEnum2: TMyEnum2; published property MyEnum: TMyEnum read FMyEnum write FMyEnum; property MyEnum2: TMyEnum2 read FMyEnum2 write FMyEnum2; end; ``` using TStream.WriteComponent does not stream MyEnum2. Does anybody know why that is, and if this can be fixed ?

Original source