Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unable to view Call Hierarchy on Primary Constructors in C# #77327

Open
vsfeedback opened this issue Feb 24, 2025 · 0 comments · May be fixed by #77328
Open

Unable to view Call Hierarchy on Primary Constructors in C# #77327

vsfeedback opened this issue Feb 24, 2025 · 0 comments · May be fixed by #77328
Labels
Area-IDE help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work]
Before the introduction of primary constructors I was able to view the call hierarchy for a constructor by right clicking on the constructor and then selecting "View Call Hierarchy" with the introduction of the primary constructors this is no longer possible.

When I right click on the class name which is now my only way to access the constructor I get the message "Cursor must be on a member name".

Steps to reproduce:

  1. Create a class in C#
  2. Ensure the class uses the primary constructor
  3. Right click on the class name
  4. In the context menu select "View Call Hierarchy"

Original Comments

Feedback Bot on 2/20/2025, 09:23 PM:

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.

Una Yang [MSFT] on 2/20/2025, 11:15 PM:

Thanks for your feedback.
In your code, class Class1 defines a class named Class1. The name Class1 identifies this class. The curly braces {} following the class name contain the class definition and its members (such as methods, properties, etc.).
Regarding why you cannot view the call hierarchy, it is because the call hierarchy feature is typically used to view the call relationships of methods or constructors. If your class does not define any methods or constructors, the call hierarchy option will not be available when you right-click on the class name.
To view the call hierarchy, you need to define a method or constructor in the class. For example:

using System;

namespace ConsoleApp3
{
class Class1
{
public void MyMethod()
{
Console.WriteLine(“Hello World!”);
}
}
}

In this example, you can right-click on the MyMethod method and select “View Call Hierarchy” to see the call hierarchy.

If you have any other questions or need further assistance, please let me know!

Sandy Armstrong [MSFT] on 2/21/2025, 08:02 AM:

Thanks for the report, easy enough to repro with something like:

    // Invoke "View Call Hierarchy" on "Class1"
    public class Class1(string test)
    {
    }
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 24, 2025
@CyrusNajmabadi CyrusNajmabadi added 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 Feb 24, 2025
@github-project-automation github-project-automation bot moved this to InQueue in Small Fixes Feb 24, 2025
@CyrusNajmabadi CyrusNajmabadi added this to the Backlog milestone Feb 24, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Area-IDE help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
Status: InQueue
Development

Successfully merging a pull request may close this issue.

2 participants