[225] Bad extract method
BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello, given this (somewhat convoluted code):
void
WriteAccountTransactions(XmlWriter writer, Account account)
{
decimal
previousBalance = account.GetTransactionsTotal(StartDate.AddDays(-1));
Xml.WriteXml(
writer,
account,
delegate {
// Selection starts here
decimal aggregate = previousBalance;
using(Xml.WriteXml(writer, Schema.Transactions)) {
Xml.WriteXml(
writer,
Schema.PreviousBalance,
previousBalance
);
foreach(Transaction transaction in GetTransactions(account)) {
aggregate += transaction.Value;
Xml.WriteXml(
writer,
transaction,
delegate {
Xml.WriteXml(writer, Schema.Aggregate, aggregate);
}
);
}
}
// Selection ends here
}
);
}
When doing an extract method, R# doesn't add the needed parameters to
the extracted method, it puts them as local variables int method body:
void WriteTransactions()
{
Account account;
decimal previousBalance;
XmlWriter writer;
decimal aggregate = previousBalance;
using(Xml.WriteXml(writer, Schema.Transactions)) {
Xml.WriteXml(
writer,
Schema.PreviousBalance,
previousBalance
);
foreach(Transaction transaction in GetTransactions(account)) {
aggregate += transaction.Value;
Xml.WriteXml(
writer,
transaction,
delegate {
Xml.WriteXml(writer, Schema.Aggregate, aggregate);
}
);
}
}
}
Regards,
Pablo
-
BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
iD8DBQFEGckgvooSiBfQCSoRAoDnAJsGekGj/wvcg2zff4TnRPKCnq6ACffAEE
q+aDPH91wNaDAcA6uQDEV8Y=
=OuH4
-
END PGP SIGNATURE-----
Please sign in to leave a comment.
BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Oleg Stepanov (JetBrains) wrote:
I've tested it in 226, but still it's not fixed. =(
Regards,
Pablo
-
BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
iD8DBQFEHBuCvooSiBfQCSoRAsqfAKD4CFw80AlnxrxSStFZuaNbRwFHkQCg4i3k
2+vpeKGQI2dhyz0u1nyZzY0=
=QXq0
-
END PGP SIGNATURE-----
BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Oleg Stepanov (JetBrains) wrote:
I've tested it in 226, but still it's not fixed. =(
Regards,
Pablo
-
BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
iD8DBQFEHBuCvooSiBfQCSoRAsqfAKD4CFw80AlnxrxSStFZuaNbRwFHkQCg4i3k
2+vpeKGQI2dhyz0u1nyZzY0=
=QXq0
-
END PGP SIGNATURE-----