Activity log for bug #901212

Date Who What changed Old value New value Message
2011-12-07 13:07:14 Fabian Schmied bug added bug
2011-12-11 19:14:25 Charlie Poole affects nunitv2 nunit-3.0
2012-01-24 17:40:54 Charlie Poole tags feature framework
2012-11-04 05:45:53 Charlie Poole nunit-3.0: status New Triaged
2012-11-04 05:45:57 Charlie Poole nunit-3.0: importance Undecided Wishlist
2013-11-03 14:40:03 Charlie Poole description For NUnit v3, a fully generic constraint system (i.e., the Constraint and ConstraintExpression classes having a generic type parameter T) would be desirable in order to be able to leverage types known at compile time when writing constraints. Constraint methods such as Equal and GreaterTo could use that type parameter in their signature, so invalid comparisons would be detected at compile time. Constraints such as Property could provide support for naming symbols using expressions (Expression<Func<T, TR>>). For collection constraints, a TElement generic parameter knowing the element type of the collection should also be added. The classic constraint builders Is and Has would instantiate the T (and TElement) with System.Object, so that "Assert.That (myValue, Is.EqualTo (10))" would cause an EqualConstraint<object> to be passed to Assert.That and "Assert.That (myValue, Has.Member (10))" would cause a CollectionContainsConstraint<object> (derived from Constraint<T> with T being IEnumerable<object> in this case) to be passed to Assert.That. Is.TypeOf<T>, Is.AssignableTo<T>, and Is.InstanceOf<T> would return their respective constraints parameterized with the given T, so that "Assert.That (myValue, Is.TypeOf<MyClass>().With.Property (v => v.P).EqualTo (42))" would work. For full type inference support, a new Assert.That syntax could be provided that binds the T to the actual type of the value passed to the Assert method: public static void That<T> (T actualValue, Func<ResolveConstraintBuilder<T>, IResolveConstraint<T>> constraintDelegate) and public static void That<TElement> (IEnumerable<TElement> actualValue, Func<ResolveCollectionConstraintBuilder<TElement>, IResolveConstraint<IEnumerable<TElement>>> constraintDelegate). This would allow code such as the following to be written in a typesafe way without needing to repeat the type: Assert.That (myVariable, v => v.EqualTo (42)); Assert.That (myCollection, c => c.EquivalentTo (new[] { 1, 2, 3 })); Assert.That (myCollection, c => c.Member (3)); [Issue now tracked at https://github.com/nunit/nunit-framework/issues/53] For NUnit v3, a fully generic constraint system (i.e., the Constraint and ConstraintExpression classes having a generic type parameter T) would be desirable in order to be able to leverage types known at compile time when writing constraints. Constraint methods such as Equal and GreaterTo could use that type parameter in their signature, so invalid comparisons would be detected at compile time. Constraints such as Property could provide support for naming symbols using expressions (Expression<Func<T, TR>>). For collection constraints, a TElement generic parameter knowing the element type of the collection should also be added. The classic constraint builders Is and Has would instantiate the T (and TElement) with System.Object, so that "Assert.That (myValue, Is.EqualTo (10))" would cause an EqualConstraint<object> to be passed to Assert.That and "Assert.That (myValue, Has.Member (10))" would cause a CollectionContainsConstraint<object> (derived from Constraint<T> with T being IEnumerable<object> in this case) to be passed to Assert.That. Is.TypeOf<T>, Is.AssignableTo<T>, and Is.InstanceOf<T> would return their respective constraints parameterized with the given T, so that "Assert.That (myValue, Is.TypeOf<MyClass>().With.Property (v => v.P).EqualTo (42))" would work. For full type inference support, a new Assert.That syntax could be provided that binds the T to the actual type of the value passed to the Assert method: public static void That<T> (T actualValue, Func<ResolveConstraintBuilder<T>, IResolveConstraint<T>> constraintDelegate) and public static void That<TElement> (IEnumerable<TElement> actualValue, Func<ResolveCollectionConstraintBuilder<TElement>, IResolveConstraint<IEnumerable<TElement>>> constraintDelegate). This would allow code such as the following to be written in a typesafe way without needing to repeat the type: Assert.That (myVariable, v => v.EqualTo (42)); Assert.That (myCollection, c => c.EquivalentTo (new[] { 1, 2, 3 })); Assert.That (myCollection, c => c.Member (3));
2013-11-03 14:40:25 Charlie Poole tags feature framework feature framework github