I am designing a set of generic interfaces in order to clarify the construction of some reports.
To achieve this I am using generics and I have to carry over three generic parameters between different fluent classes. Sometimes I have to pass four of them but it is all done by the framework and the idea behind is that, with enough attention, it is possible to have a whole interface without having to type any generics at all.
An example is
t1.Schedule.ForSession(Session).
WithName("TestName").
Map.
Args.FromResultsOfTask(t2).UsingDefaultMappings().
And.
WaitOnCompletionOfTask(t4);
Running FXCop produces an endless set of complaintsof this type:
Error, Certainty 85, for AvoidExcessiveParametersOnGenericTypes
I am using generics to create “type safe” (perhaps type aware is more correct) interfaces where mappings can be defined as in
...
Map.Args.From(myObject).
Mapping(x=>x.MyProperty).To(y=>y.ArgsProperty).
...
What strategies can I adopt to reduce the use of generics and still achieve compile-safe custom mappings?
Has anyone successfully utilised generics (and can point me to a good set of examples) to implement a fluent interface?
It sounds to me like you should just suppress that FXCop warning for your code. If there are naturally three generic type parameters, then such is life. Document it carefully and it should be fine, IMO.
Tools like FXCop are there to be helpful, not to become the ultimate arbiters of your code.