Bug? Code-completion uses superfluous fully-qualified type-name for generic type parameter arguments
If I use Linqpad 6's code-completion to complete a variable declaration of a generic-type it won't simplify the type's generic parameter's type-names.
For example:
- Open a new Linqpad 6 query. I'm using Linqpad 6.14.10 x64 with .NET 5 right now.
- Be in "C# Statement(s)" or "C# program" mode.
- Right-click > Namespace Imports, ensure
System,System.Collections.Generic, andSystem.IOis in the list. - Type in
Dictionary<String,FileInfo> dict = new - Right after typing
newthe completion list appears withDictionary<string, System.IO.FileInfo>preselected. - Pressing [Tab] will cause "
Dictionary<string, System.IO.FileInfo>()" to be inserted.- I expected
Dictionary<String,FileInfo>()to be inserted instead. There are 3 differences from actual behaviour from what I expected:
stringwas inserted instead ofString(though Linqpad does not currently have a setting to specify C# keywords or actual type-names, but I wish it would at least preserve my left-hand declaration type verbatim).- It added a space after the comma (again, there's no option to control this, but my preference is to not have spaces between generic type parameters in most cases).
- And the main bug/issue: it inserted
System.IO.FileInfoeven thoughSystem.IOis in the list of imported namespaces.
- I expected
Screenshot proof:

Comments
-
I agree with the
FileInfoinstead ofSystem.IO.FileInfo, but I think other 2 point is Ok, since it's also a existing behavior in Visual Studio:

-
Perhaps it would be best to remove that code completion, given that its actually now redundant:
Dictionary<String,FileInfo> dict = new(); // From C# 9
-
Hey @JoeAlbahari , although the C# 9
new()is workable for this example, but I found another bug when deal with internal types, let's say this code:// Note: namespace `ExternalNs` is imported void Main() { DoWork( } void DoWork(External.Colors color) { } namespace ExternalNs { public class External { public enum Colors { Red, Black, White } } }Cursor at right of
DoWork(, hitCtrl+Spacetrigger intellisense, the namespaceExternalNswill shown:
Please also aware that for those non-internal-types, this bug will not shown.
-
@sdflysha said:
I agree with theFileInfoinstead ofSystem.IO.FileInfo, but I think other 2 point is Ok, since it's also a existing behavior in Visual Studio:Indeed, it is - but VS is wrong in this case because my
.editorconfigsettings are set-up to always use actual type-names instead of C# keywords (e.g.StringandInt32instead ofstringandint), and VS gets it right most of the time but not all the time, and tab-completing an auto-suggested generic-type constructor is one of the few edge cases still not respecting my.editorconfig.So I'm "okay" with Linqpad using C# keywords - but only because Linqpad doesn't have an option for it - as soon as LinqPad does start respecting
.editorconfigor at least having an option for it then it should use type-names and not keywords when tab-completing generic type parameters for suggested constructors.
