csharpier
csharpier copied to clipboard
ParenthesizedLambdaExpressions needs some work.
var task = Task.Factory.StartNew(async () => {
return await new WebClient().DownloadStringTaskAsync(
"http://example.com"
);
});
// should probably be
var task = Task.Factory.StartNew(async () =>
{
return await new WebClient().DownloadStringTaskAsync(
"http://example.com"
);
});
This got mostly resolved, so the only part left is to clean up the indentation.
You think something like this might look better? To make it clear that the braces aren't for the outer level statement, but rather the lambda being passed in?
var task = Task.Factory.StartNew(async () =>
{
return await new WebClient().DownloadStringTaskAsync(
"http://example.com"
);
}
);
It actually formats really close to that now
var task = Task.Factory.StartNew(
async () =>
{
return await new WebClient().DownloadStringTaskAsync(
"http://example.comddddddddddddddddddd"
);
}
);
Prettier formats it like this
var task = Task.Factory.StartNew(async () => {
return await new WebClient().DownloadStringTaskAsync(
"http://example.comddddddddddddddddddd"
);
});
But I don't think we want to have the brace on the same line as =>
We could maybe move the ) up, which would be this, but I don't think I love that.
var task = Task.Factory.StartNew(async () =>
{
return await new WebClient().DownloadStringTaskAsync(
"http://example.com"
);
});
Which leaves us with doing what you said
var task = Task.Factory.StartNew(async () =>
{
return await new WebClient().DownloadStringTaskAsync(
"http://example.com"
);
}
);
// however if there are multiple parameters
var task = Task.Factory.StartNew(
async () =>
{
return await new WebClient().DownloadStringTaskAsync(
"http://example.com"
);
},
someOtherParameter
);