Consider the following code:
type
TColors = (Red, Blue, Green, Yellow, Orange); // base type
TMyColors = Green..Orange; // subrange type
TAllowedColors = set of TMyColors; // set based on the subrange above
TMyComponent = class(TComponent)
private
FAllowedColors: TAllowedColors;
published
property AllowedColors: TAllowedColors read FAllowedColors write FAllowedColors;
end;
Once installed into a design time package, Object Inspector correctly shows the property AllowedColors:
Please notice that Green and Yellow are both set. Now, after saving the form and inspecting the DFM file, that's what I get:
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
...
object MyComponent1: TMyComponent
AllowedColors = [Red, Blue]
Left = 80
Top = 56
end
end
Notice that the IDE is saving AllowedColors incorrectly as [Red, Blue] instead of [Green, Yellow]. Somehow it is using the ordinality of the subrange type when streaming but then it uses the base type, instead of the subrange type (although Green should be equal to 2 - not 0 - in either case).
Is this the expected behavior or a known issue? Is there any workaround other than taking care of the streaming to/from the DFM file myself?
PS: Tested in Delphi 10.2.3 and 10.3.3
