Move Foo and Foo <T> with ReSharper to match files

the code

I would like to use the ReSharper Move Types Into Matching Files function to move the code below, which is written in one .cs . File:

 public abstract class Foo { } public abstract class Foo<T> : Foo { } 

ReSharper refactoring throws this exception:

It is not possible to move the Foo class because there is another declaration that will be moved to the "Foo.cs" file.

Question

I can think of two results, of which either I'm fine:

  • Move both Foo and Too<T> to Foo.cs
  • Move Foo to Foo.cs and move Foo<T> to FooOfT.cs

So the question remains:

  • Is there any other best naming practice that does not conflict with resharper ?, or
  • Is there any way to configure ReSharper to support this name?

Note

  • Because Generics are unique to every possible combination of constraints, the Foo class is my interface class. Therefore, I will not rename Foo<T> to Bar<T> .
  • I do not want to rename Foo to FooBase , since it is already an abstract class that makes the explicit suffix "Base" redundant.
  • I cannot reorganize Foo into IFoo , since Foo is my conceptual interface (due to the necessary base implementation.
+4
source share
2 answers

As far as I know, there is no way to tell Resharper to add general file name parameters. It will just use the class name, i.e. Foo , Foo<T> and Foo<A, B, C> all have Foo.cs as the file name, but - and that the problem is - ReSharper does not seem to know that this feature exists and will show you are mistaken in this scenario. In fact, you can do nothing with this except registering an error or requesting a function .

+1
source

You can consider the following options:

  • Use AbstractFoo
  • Change Foo to an interface, if possible, and use IFoo
  • Use GenericFoo
  • Use different namespaces for Foo and Foo<T> and put them in different folders.
+1
source

Source: https://habr.com/ru/post/1500947/


All Articles