File Layout - Entry.Match for Factory Method
One of the requirements that our company standards specify is that static factory methods must be grouped with the constructors. I am attempting to set up the File Layout options to accomplish this. So far, I have:
<Entry.Match>
<Or>
<Kind Is="Constructor" />
<And>
<Kind Is="Method" />
<Access Is="Public" />
<Static />
<-- What do I put here to specify that the method should return the current type? -->
</And>
</Or>
</Entry.Match>
Please sign in to leave a comment.
You've probably already thought of this, but you can match by name instead of return type, using a regular expression. Example rule: factory method names start with "Create".
Alternatively, you can use attributes to tag type members with special meaning. You could create a "ConstructorAttribute" that can be applied to factory methods. Then update your pattern to search for that attribute.
The first pattern would be convention-based while the second pattern would be configuration-based. But why not allow both?