Member leftovers are instances of a specific member type which were not already placed by a previous PutX statement. Member leftovers are placed by a PutX statement with no restricting Where statements.
For instance, A <PutFields/> statement will place all fields that weren't already placed by previous <PutFields> statements.
A <PutMethods><Where><IsConstructor Equals="true"/></Where></PutMethods> will place all constructors which weren't placed by previous <PutMethods> statements. (see example at the bottom)
Take this Code Layout Snippet as an example:
<PutFields><!-- First -->
<Where><Static Equals="true"/></Where>
</PutFields>
<PutFields/><!-- Second -->
Run it on this piece of code -
public class WorkItem
{
private string _a;
private static string _b;
private readonly string _c;
}
and you will get -
public class WorkItem
{
private static string _b;
private string _a;
private readonly string _c;
}
The first <PutFields> statement in the Code Layout snippet will place "_b" and the second <PutFields/> statement will place all the leftovers ("_a", and "_c").
How is this useful, you ask? Well, placing leftovers can help you put some order in your regions without having to specify each specific case. For example, you might want to create a region for constructors, having all the public constructors appear first followed by the rest of the constructors.
Without leftovers, the Code Layout should have looked something like:
<CreateRegion Title="Constructors">
<PutMethods>
<Where><IsConstructor Equals="true"/><Access Equals="Public"/></Where>
</PutMethods>
<PutMethods>
<Where><IsConstructor Equals="true"/><Access Equals="Protected"/></Where>
</PutMethods>
<PutMethods>
<Where><IsConstructor Equals="true"/><Access Equals="Private"/></Where>
</PutMethods>
<PutMethods>
<Where><IsConstructor Equals="true"/><Access Equals="Internal"/></Where>
</PutMethods>
<PutMethods>
<Where><IsConstructor Equals="true"/><Access Equals="ProtectedInternal"/></Where>
</PutMethods>
</CreateRegion>
Using leftovers, the Code Layout can be reduced to:
<CreateRegion Title="Constructors">
<PutMethods>
<Where><IsConstructor Equals="true"/><Access Equals="Public"/></Where>
</PutMethods>
<PutMethods>
<Where><IsConstructor Equals="true"/></Where><!-- Leftovers -->
</PutMethods>
</CreateRegion>
Labels: Code Layout, Code Layout Tricks, Documentation