Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StyleCop SA1402 and Generics

I think SA1402 is a great rule but I have problem with generics. I've got a class that uses the Func delegate, so the names roughly parallel that signature. That is, I have classes named Operation<TType>, Operation<T, TType>, Operation<T1, T2, TType> and so on. According to SA1402, I need to put all these small classes in separate files and come up with some strange decoration for the file name. Additionally, if I need to change one of these items I'll typically need to make changes to the rest. This seems less supportable than a single module.

Does it make sense for SA1402 to allow generics of the same basic class (as well as partials) to reside in one file? In this case all permutations of the class Operation would reside in 'Operation.cs'.

like image 307
Quarkly Avatar asked Aug 31 '13 14:08

Quarkly


1 Answers

They are several nameing convension. It seems the most popular is

Operation[TType].cs

Operation[T,TType].cs

Operation[T1, T2, TType].cs

But you can also use something more classic, like

Operation`1.cs

Operation`2.cs

Operation`3.cs

(see Convention for Filenames of Generic Classes)

like image 156
Benoit Blanchon Avatar answered Oct 03 '22 21:10

Benoit Blanchon