Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AV1506: Add guidance for generic types #87

Closed
bkoelman opened this issue Sep 14, 2017 · 3 comments
Closed

AV1506: Add guidance for generic types #87

bkoelman opened this issue Sep 14, 2017 · 3 comments

Comments

@bkoelman
Copy link
Contributor

Applies to: "Name a source file to the type it contains (AV1506)"

Consider the next file:

public class TableLoader
{
    // ...
}

public class TableLoader<TKey, TConverter> : TableLoader
{
    // ...
}

Options:

  1. Allow both types to live in the same file, because their names are the same (they only differ in arity)
  2. Split into TableLoader.cs and TableLoader`2.cs (because arity = 2)
  3. Split into TableLoader.cs and TableLoaderTKeyTConverter.cs
  4. Split into TableLoader.cs and TableLoader.generic.cs (nested)

I think it is worth providing guidance on this situation, to align naming accross the entire team. My preference would be 2. Though I often see option 1 in codebases too.

@dennisdoomen
Copy link
Owner

I usually keep them together, so my preference is option 1.

@bkoelman
Copy link
Contributor Author

The same for nested types, right?

An alternative would be to put them in partial classes and in separate files, but I'm not a big fan of that.

@dennisdoomen
Copy link
Owner

Neither am I.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants