Unable to view Call Hierarchy on Primary Constructors in C# #77327
Labels
Area-IDE
help wanted
The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone
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:
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:
The text was updated successfully, but these errors were encountered: