Delphi 2010 Code Formatter: "(MyVar as TMyType).MyMethod" is split in two lines
How to prevent the code formatter from doing this? It seems that it moves casts with "as" always a line up. Is this a bug, or is there any setting in the formatter?
// Before formatting:
procedure TMyFrame.WidthEditChange(Sender: TObject);
begin
(Properties as TMyProperties).Width := (Sender as TJvSpinEdit).AsInteger;
end;
// After formatting:
procedure TMyFrame.WidthEditChange(Sender: TObject);
begin (Properties as TMyProperties) // <----- I want this untouched
.Width := (Sender as TJvSpinEdit).AsInteger;
end;
It gets weird:
// Before formatting:
procedure TMyFrame.WidthEditChange(Sender: TObject);
begin
(Properties as TMyProperties).Width := (Sender as TJvSpinEdit).AsInteger;
(Properties as TMyProperties).MyMethod;
end;
// After formatting:
procedure TMyFrame.WidthEditChange(Sender: TObject);
begin (Properties as TMyProperties)
.Width := (Sender as TJvSpinEdit).AsInteger; (Properties as TMyProperties)
开发者_如何学Go .MyMethod;
end;
one work-around is a comment on the end of the line:
if Assigned(aDBControl) then //
(aDBControl as TcxDBLookupComboBox)
.Properties.ListSource := aDataSource;
It's not ideal, the indent on the next line is wrong, but it's better than waiting to see if update 2 fixes it.
edit: a hard cast wrapping the safe cast works slightly better.
if Assigned(aDBControl) then
TcxDBLookupComboBox(aDBControl as TcxDBLookupComboBox)
.Properties.ListSource := aDataSource;
That's a bug and already reported to QC.
精彩评论