Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Navigation Bar doesn't support primary constructor

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
ocrosoft Posted - Feb 17 2025 : 9:56:55 PM

public class TestClassWithClassicConstructor
{
    private int x;
    private int y;
    public TestClassWithClassicConstructor(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
    public int Add()
    {
        return x + y;
    }
}

The above code can normally display the Add method in the dropdown.
After converting the constructor to a primary constructor:

public class TestClassWithPrimaryConstructor(int x, int y)
{
    public int Add()
    {
        return x + y;
    }
}




It seems that VA recognizes the primary constructor as a method instead of recognizing it as a class?

6   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Apr 14 2025 : 08:47:06 AM
Unfortunately no progress to report on this yet, but it is something we are keeping an eye on. It is good to know this is effecting you, since how many people are effected is one of the criteria we use when working out how to prioritise things.
remcolam Posted - Apr 14 2025 : 07:31:29 AM
Is there a way to be informed about progress on this feature request? Because I am running into the same issue, for most of my code files the VA Navigation bar no longer works, because of the primary constructor usage
feline Posted - Feb 19 2025 : 12:22:17 PM
OK, I understand what is going on now. A primary constructor is a new feature in C# 12, which VA doesn't understand yet. I have put in a feature request to support this:

case=165542
ocrosoft Posted - Feb 18 2025 : 9:38:02 PM
quote:
Originally posted by ocrosoft


public class TestClassWithClassicConstructor
{
    private int x;
    private int y;
    public TestClassWithClassicConstructor(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
    public int Add()
    {
        return x + y;
    }
}

The above code can normally display the Add method in the dropdown.
After converting the constructor to a primary constructor:

public class TestClassWithPrimaryConstructor(int x, int y)
{
    public int Add()
    {
        return x + y;
    }
}




It seems that VA recognizes the primary constructor as a method instead of recognizing it as a class?





Visual studio 2022 preview + VA 2024.12.27 + .NET9

Screenshot with VA outline:


ocrosoft Posted - Feb 18 2025 : 11:01:39 AM
This is the full code of my screenshot, please note the class TestClassWithPrimaryConstructor.

namespace ConsoleApp1
{
    public class TestClassWithClassicConstructor
    {
        private int x;
        private int y;
        public TestClassWithClassicConstructor(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        public int Add()
        {
            return x + y;
        }
    }

    public class TestClassWithPrimaryConstructor(int x, int y)
    {
        public int Add()
        {
            return x + y;
        }
    }
}
feline Posted - Feb 18 2025 : 08:07:09 AM
I don't understand why you could get this Alt-M list with this code. That isn't what I get. I have attached a screen shot of what I am seeing.

Which IDE and version of VA are you using?

What does VA Outline show? I have also attached what I am seeing there.

Your screen shot suggests there is other code at work that is confusing our parser somehow.







© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000