As far as I know, there is no way to tell Resharper to append the generic parameters of the filename. It will just use the class name, i.e. Foo
, Foo<T>
and Foo<A, B, C>
all have Foo.cs
as the filename, but - and that's the problem - ReSharper doesn't seem to know that this possibility exists and will show you an error in this scenario. Really nothing you can do about it except logging a bug or feature request.
Move Foo and Foo<T> with ReSharper to matching files
-
27-06-2022 - |
Frage
Code
I would like to use the ReSharper Move Types Into Matching Files functionality to move the code below which is written in a single .cs
'. file:
public abstract class Foo
{
}
public abstract class Foo<T> : Foo
{
}
Executing the ReSharper refactoring causes this exception:
Can not move class Foo because there is another declaration that will be moved into file 'Foo.cs'.
Question
I can think of two outcomes of which either are ok by me:
- Move both
Foo
andToo<T>
intoFoo.cs
- Move
Foo
intoFoo.cs
and moveFoo<T>
intoFooOfT.cs
So, the question remains:
- Is there another best naming practise that does not conflict with resharper?, or
- Is there a way to configure ReSharper to support this naming?
Note
- Because Generics are unique for each possible combination of constraints, the
Foo
class is my interface class. Therefore I won't renameFoo<T>
toBar<T>
. - I do not wish to rename
Foo
toFooBase
as it is already an abstract class which makes the explicit 'Base' suffix redundant. - I cannot refactor
Foo
toIFoo
asFoo
is my conceptual interface (because of a required basic implementation.
Lösung
Andere Tipps
You may consider these options:
- Use
AbstractFoo
- Change Foo to an interface, if possible, and use
IFoo
- Use
GenericFoo
- Use different namespaces for
Foo
andFoo<T>
and put them in different folders.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow