Implementing interface (or abstract class) whose members reference a type included via a global import adds empty line to the beginning of file
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
Full issue information + repro project:
https://github.com/just-ero/roslyn-issues-repros/tree/main/5.0.0/003_ImplementInterface_ReturnTypeInGlobalUsings
Version
[!NOTE]
Roslyn: 5.0.0-1.25319.11
.NET SDK: 10.0.100-preview.5.25277.114Visual Studio Code: 1.102.0
C# Extension: 2.84.19
C# Dev Kit Extension: 1.30.44
Steps to Reproduce
- Add the following code in separate files:
namespace N; class C;interface II { C M(); }
Note:class Repro : II;Cmust be in a different namespace thanII, andReproandRepromust not know ofCbefore implemetation. - Add
Nto the global usings anywhere. - Apply the
Implement interfacequick fix toRepro.
Expected Behavior
No new line is added to the beginning of the file.
Actual Behavior
It is.
Speculation: this is possibly due to Roslyn making an attempt to add missing namespaces, but stopping after finding the global import.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked repro project at 5.0.0/003_ImplementInterface_ReturnTypeInGlobalUsings and reproduce the issue by applying the Implement interface quick fix to Repro after adding N as a global using. Trace the Roslyn implementation of that quick fix and its namespace-import handling. Done means the generated implementation does not add an empty line at the beginning of the file, while the repro behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100