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

Necessary imports should be added when inlineHints are applied #61438

Closed
JoeRobich opened this issue May 20, 2022 · 1 comment
Closed

Necessary imports should be added when inlineHints are applied #61438

JoeRobich opened this issue May 20, 2022 · 1 comment
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@JoeRobich
Copy link
Member

JoeRobich commented May 20, 2022

Double clicking inline hints which replace var with a type name do not add using directives when necessary.

Steps to Reproduce:

  1. Create a new console app
  2. Add a new class named OtherClass.cs with the following:
using System.Collections.Immutable;

namespace ConsoleApp;

internal class OtherClass
{
    public static ImmutableDictionary<string, string> GetNameMap()
        => ImmutableDictionary<string, string>.Empty;
}
  1. Replace the code in Program.cs with the following:
var nameMap = ConsoleApp.OtherClass.GetNameMap();
  1. With inline type hints for var enabled you should see the following:

image

5. Double click the inline type hint to apply the text to the document.

Expected Behavior:
var is replaced with ImmutableDictionary<string, string> and a using System.Collections.Immutable; using directive is added.
image

Actual Behavior:
var is replaced with ImmutableDictionary<string, string>? which is error squiggled.
image

Additional Thoughts:
The VS Code implementation of this behavior supports associating multiple TextEdits with each inlay hint. Currently Roslyn supports a single TextEdit.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 20, 2022
@vatsalyaagrawal vatsalyaagrawal added Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 2, 2022
@vatsalyaagrawal vatsalyaagrawal modified the milestones: Backlog, 17.3 Jun 2, 2022
@arunchndr arunchndr modified the milestones: 17.3, 17.4 Oct 3, 2022
@arunchndr arunchndr modified the milestones: 17.4, 17.6 P3 Jan 17, 2023
@github-project-automation github-project-automation bot moved this to InQueue in Small Fixes Oct 22, 2024
@CyrusNajmabadi
Copy link
Member

Closing out due to lack of feedback.

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2024
@github-project-automation github-project-automation bot moved this from InQueue to Completed in Small Fixes Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
Status: Completed
Development

No branches or pull requests

4 participants