dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.1k stars 4.04k forks source link

Change constructor error message: Instead of writing "… that takes 0 arguments" omit this part if no constructor is available #75968

Open SetTrend opened 1 week ago

SetTrend commented 1 week ago

I'm writing a library for WPF.

In the cause of writing I noticed the following:


Current Situation

The following error message imposes that the number of constructor arguments was insufficient, or it wouldn't match:

Image

Furthermore, the parameter tooltip is giving no information about the constructor itself but about the surrounding method:

Image

After doing some investigation in the WPF source I found that the TextPointer class does not provide any public constructor at all but only internal constructors.

So, the current error message and Intellisense tooltip both seem quite misleading and confusing.


Desired Situation

I suggest to …

  1. alter the error message to not put focus on the number of arguments but instead to read "{ClassName} does not provide any constructor that's available for this protection level",
  2. don't have Intellisense suggest/provide the corresponding class name after new if no potential constructor is available.