Author |
Topic  |
|
ocrosoft
New Member

3 Posts |
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?
|
Edited by - ocrosoft on Feb 17 2025 9:59:17 PM |
|
feline
Whole Tomato Software
    
United Kingdom
19187 Posts |
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.


|
zen is the art of being at one with the two'ness |
 |
|
ocrosoft
New Member

3 Posts |
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;
}
}
}
|
Edited by - ocrosoft on Feb 18 2025 11:08:17 AM |
 |
|
ocrosoft
New Member

3 Posts |
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:

|
 |
|
feline
Whole Tomato Software
    
United Kingdom
19187 Posts |
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 |
zen is the art of being at one with the two'ness |
 |
|
remcolam
Starting Member
Netherlands
1 Posts |
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
Whole Tomato Software
    
United Kingdom
19187 Posts |
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. |
zen is the art of being at one with the two'ness |
 |
|
azur
Ketchup Master
   
Germany
60 Posts |
Posted - Jun 27 2025 : 05:57:36 AM
|
Could you please speed up the process? I have to write about the constructors in a lot of places to make the IDE happy:
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "Otherwise Visual Assist will not recognize the members.")] |
 |
|
feline
Whole Tomato Software
    
United Kingdom
19187 Posts |
Posted - Jun 27 2025 : 07:23:06 AM
|
No progress to report on this yet unfortunately.
This isn't an ideal work around, but at least it is something.
Can you email me at [email protected] about this please? The new reports management run to track interest levels in the open bug reports don't pick up forum posts, so an email report will carry more weight. |
zen is the art of being at one with the two'ness |
 |
|
|
Topic  |
|