The term "Unpacking" refers to a pre-processing stage that occurs before your code is analyzed and constructed. When Regionerate unpacks your code, it strips up all members from regions which are managed by it ("Regionerated regions"). After the code is shaped according to the Code Layout, these members are packed back into their regions.
While Regionerate automatically handles Regionerated regions, it allows you to specify which additional regions should be unpacked.
For example, you might have some regions that were generated by the IDE or a 3rd party tool for default interface implementations, such as:
1: public class Foo : IList<string>
2: {3: #region IList<string> Members
4: 5: ... 6: 7: #endregion
8: 9: #region ICollection<string> Members
10: 11: ... 12: 13: #endregion
14: }You can use the Unpack element under Configuration inside your Code Layout document to tell Regionerate to unpack any interface that matches a regular expression. For example:
<Configuration>
...
<Unpack>
<Regions ThatMatch="I.*\sMembers" />
</Unpack>
</Configuration>
1: public class Foo : IList<string>
2: { 3: 4: #region Properties (3)
5: 6: ... 7: 8: #endregion Properties
9: 10: #region Methods (10)
11: 12: ... 13: 14: #endregion Methods
15: 16: }Another possible use for unpacking is when migrating between symbols. If you used the Prefix symbol (the only option in versions prior to v0.6.6.5) long enough you have a code base filled with regions that look like:
#region [rgn] Fields (3)If you change the symbol (lets say, from a Prefix to a Hidden Dragon), Regionerate will unpack and pack only regions the have the Hidden Dragon embedded in them, meaning that all "[rgn]" regions will stay untouched.
To migrate to the new symbol, you should tell Regionerate to unpack "[rgn]" regions:
1: <Configuration>
2: <Symbol>
3: <HiddenDragon />
4: </Symbol>
5: <Unpack>
6: <Regions ThatMatch="\[rgn\]" />
7: </Unpack>
8: </Configuration>
This way, the first time a code file is Regionerated with the new settings, Regionerate first unpacks all the old "[rgn]" regions and then it merges all the members into new Hidden Dragon symbolized regions.
Labels: Code Layout, Documentation