Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wilson0x4d/01e59170306e3854e36826e5945a6ef5 to your computer and use it in GitHub Desktop.
Save wilson0x4d/01e59170306e3854e36826e5945a6ef5 to your computer and use it in GitHub Desktop.
/// <summary>
/// This is about indentation/formatting practices in the wild,
/// don't overanalyze the content.
/// <para>See Also: http://bit.ly/CSharpFormattingPoll </para>
/// </summary>
class Foo
{
/// <summary>
/// Basis; seasoned C# programmers get cringy when
/// they see code that trails off to the Nth column
/// of the source file, as see here.
/// </summary>
public void Bar_Basis()
{
System.Threading.Tasks.Task.WaitAll(_dictionary.Values.Select(value => DoWorkAsync(value)).ToArray()); // for all clients, queue a tasks and wait on all queued tasks
}
/// <summary>
/// This is a fairly common practice where a single-parameter
/// method shows its parameter on the same line as the method,
/// however, fluent-style method calls appear indented on subsequent
/// lines.
/// </summary>
public void Bar_001()
{
// for all clients, queue a task and wait on all queued tasks
System.Threading.Tasks.Task.WaitAll(_dictionary
.Values
.Select(value => DoWorkAsync(value))
.ToArray());
}
/// <summary>
/// Less common, but I've seen it more lately, is the practice
/// where parameters fall upon a new line, and fluent-style
/// method calls appear "further indented" on subsequent lines.
/// </summary>
public void Bar_002()
{
// for all clients, queue a task and wait on all queued tasks
System.Threading.Tasks.Task.WaitAll(
_dictionary
.Values
.Select(value => DoWorkAsync(value))
.ToArray());
}
/// <summary>
/// I've also seen this practice, where parameters
/// and their fluent-style method calls are all left-aligned.
/// </summary>
public void Bar_003()
{
// for all clients, queue a task and wait on all queued tasks
System.Threading.Tasks.Task.WaitAll(
_dictionary
.Values
.Select(value => DoWorkAsync(value))
.ToArray());
}
private IDictionary<System.Guid, System.Threading.Tasks.Task> _dictionary;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment