razor icon indicating copy to clipboard operation
razor copied to clipboard

Roslyn semantic snippets don't know to show `if` for `@i` etc.

Open davidwengier opened this issue 3 years ago • 5 comments

Looks like by turning on semantic snippets, Roslyn has inadvertently broken our completion and @if no longer appears. The speculation is that this is caused because typing @i generates C# similar to __o = i and Roslyn is now smart enough to know that if is not valid there.

We might just need to resurrect our own snippets for these, eg from https://github.com/dotnet/razor-tooling/pull/3956/files#diff-052d5834149367e2bcf4d95d0740ddb4b346116cfcd64e568d0b5eca38f7b8aeR299-R315 as we presumably do want semantic snippets to work fully in other C# contexts in Razor files.

/cc @ToddGrun

davidwengier avatar Sep 29 '22 21:09 davidwengier

Let's see if C# can roll the feature back for Razor only and we can make a different fix for 17.5.

DustinCampbell avatar Sep 29 '22 21:09 DustinCampbell

Note: When fixing this, we'd want to (and probably need to) revert https://github.com/dotnet/roslyn/pull/64378 in Roslyn at the same time

davidwengier avatar Sep 29 '22 22:09 davidwengier

and Roslyn is now smart enough to know that if is not valid there.

This feels incredibly brittle. Shoudln't roslyn know that anyways, ignoring semantic-snippets. e.g. that's an expression location, not a keyword one.

CyrusNajmabadi avatar Sep 30 '22 16:09 CyrusNajmabadi

It is absolutely brittle! 😄 Reverting the change for Razor files is purely tactical for 17.4. We're planning to do the right thing from the Razor side in 17.5.

DustinCampbell avatar Sep 30 '22 16:09 DustinCampbell

Putting this back in triage to discuss, as semantic snippets are on by default in 17.5

davidwengier avatar Dec 13 '22 23:12 davidwengier