csharp-language-server icon indicating copy to clipboard operation
csharp-language-server copied to clipboard

AutoCompletion of Attribute-types includes `Attribute` suffix when not needed/required

Open josteink opened this issue 4 years ago • 3 comments

Consider the following code:

[Route("Demo")]
public class DemoController : Controller
{
    [HttpGet]
    [Router("DemoOperation")]
    public IActionResult DemoOperation()
    {
        // some logic
    }
}

Now try chaning the [HttpGet] attribute into a [HttpPost] attribute, by deleting Get, entering P and wait for auto-completion to kick in.

Observed that:

  • HttpPost is not suggested
  • HttpPostAttribute is suggested
  • It is harder to write [HttpPost] than without auto-completion. Oops?

Basically, unless you are willing to live with the needlessly verbose attribute-name, auto-completion now kinda works against you.

Since attribute-completion is somewhat context-sensitive, I'm not sure if there are any simple solutions here... But if there is, that would really be appreciated :smile:

josteink avatar Nov 11 '21 10:11 josteink

Yeah.. I will need to check how omnisharp does that and will steal the code :)

razzmatazz avatar Nov 11 '21 10:11 razzmatazz

does it do the same for [Flags] ? because I tried adding a [Flags] on enum and it worked..

probably your issue is with classes, right?

razzmatazz avatar Nov 20 '21 17:11 razzmatazz

Yeah. I’ve tested with basic classes and not with enum-flags yet.

josteink avatar Nov 20 '21 17:11 josteink

Old issue is old. Not sure if it's still even an issue. Abandoning.

josteink avatar Oct 11 '23 07:10 josteink