What is the difference between a "hard minimum" and a "soft minimum"?

1.1k Views Asked by At

I'm one of the poor souls condemned to work on design-time support for some WPF controls. Between VS 2010 and VS 2012, an attribute appeared (more like migrated from Blend) that lets you specify a range of valid values for a property.

NumberRangesAttribute is not documented very well yet. For inclusive ranges, setting the hard minimum/maximum values works just fine. But today I was faced with an exclusive range where the value had to be greater than zero and is usually less than 1 but does not have to be. So my first attempt was to set both minimums to double.Epsilon and the maximums to double.MaxValue. That did not stop the designer from happily accepting 0, then barfing as that caused problems due to invalid value.

So began a long, long session of trying random values until I settled on a hard minimum of 1e-15 and a soft minimum of 1. If I choose a hard minimum or soft minimum any smaller, 0 is allowed and bad things happen. 1e-15 is definitely small enough for my purposes, but I don't like that I brute forced my way to it. I want to understand it instead of leaving a hack behind.

So can anyone explain to me what these parameters might do? I'd also love to know what the canBeAuto does, because it makes no sense to me either. What does "can be automatically set" mean here? The user's setting a value, not a range.

0

There are 0 best solutions below