dotnet / dotnet/roslyn

Move Type refactoring removes generic type declarations when exist non-generic with same name in same named file

Open
#84,258 1 comment 0 reactions 0 assignees View on GitHub
Area-IDE
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/Move-Type-refactoring-removes-generic-ty/11108643)._

---
[severity:It bothers me. A fix would be nice]
I don't know what exactly raised that problem - Roslyn, Intellisense or just Editor.
What happened:
1) I have created some interface A as file A.cs, all fine
2) I have created some interface B<TSelf> and B<TSelf, T> : B<TSelf>, also in A.cs, all fine
3) I have created some struct C : B<C> and C<T> : B<C, T>, also in A.cs, all fine
4) I moved to separate file B.cs interface B, all fine (RMB, Quick actions and refactoring, Move type to B.cs)
5) I moved to separate file ??? interface B<TSelf, T>, no errors, but B<TSelf, T> just disappear and wasn't in B.cs or A.cs
6) One-by-one as in 5, but for C.

Ctrl+Z in A.cs returned me generics, so there's no just deleting, but that problem stops my coding for a few seconds.

```csharp
namespace Test;

public interface A<T1, T2, T3>
where T1 : B<T1>
where T2 : B<T2>
where T3 : B<T3>
{/*...*/}

public interface B<TSelf>
where TSelf : B<TSelf>
{/*...*/}
public interface B<TSelf, T> : B<TSelf>
where TSelf : B<TSelf, T>
{/*...*/}

public struct C : B<C>
{/*...*/}
public struct C<T> : B<C, T>
{/*...*/}
```

---
### Original Comments

#### Feedback Bot on 6/17/2026, 07:14 PM:

Based on similar issues resolved with Microsoft in the last 6 months, the following can help resolve this issue faster.


If not already included, please provide:


Detected: OS: 10.0.26200.0, VS: Insiders [11904.113], Product: community-2026, Project type: C#


Please share:



  • Whether this reproduces in a brand-new simple C# solution, or only in the current solution/file.

  • The exact steps that trigger the issue after using Move type to file, especially for the generic interface/struct declarations.

  • Whether the moved type is actually removed from the source file only, or whether it appears in the destination file and then disappears.

  • Whether the issue happens every time or only sometimes, and whether it still happens after restarting Visual Studio.

  • If possible, a short screen recording showing the refactoring steps and the result.

#### Feedback Bot on 6/18/2026, 10:23 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Contributor guide

Open the contributing guide

Research direction

Reproduce the problem in a simple C# solution by placing the generic and non-generic B and C declarations in one file, then using the Move type to file refactoring. Start by tracing the refactoring behavior for declarations with the same name but different arity; done means the generic declarations remain in the source or destination file after the move.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.