I always tend to group all stuff that belongs to a dependency property (registration, clr property, change callback, coerce callback etc.) into one region. But this violates the stylecop member ordering rules. This is also a general problem with codesnippets that generate multiple members, since the snippets can not generate code at different places in my file. What is you philosophy on this? Do you disbale the stylecop rules or do you put everything at its "right" place?
Also I personally think that stylcop should not complain about this:
/// <summary>
/// RepeatX Dependency Property
/// </summary>
public static readonly DependencyProperty RepeatXProperty =
DependencyProperty.Register(
"RepeatX",
typeof(int),
typeof(GeometryViewbox),
new FrameworkPropertyMetadata
{
DefaultValue = 1,
AffectsRender = true,
AffectsParentMeasure = true,
PropertyChangedCallback = OnRepeatXChanged,
CoerceValueCallback = CoerceRepeatXValue
});
Stylcop should generate addtional work for us to do. In the above example sticking to stylcecop makes you less productive plus the code becomes less readable, because you are forced to put the above code in the static ctor (instead of field initialization) to be able to make FrameworkPropertyMetadata into a temp variable. One additional temp variable for each dependency property doesn't make the code more readable/maintainable plus you can't use codesnippets anymore.