Visual Studio “if” snippet initially won't recognize variables

浪子不回头ぞ 提交于 2019-12-13 00:13:32

问题


I have a noob question. When I use the built in visual studio "if" snippet the expression in the parentheses won't initially recognize any of the variables in my class. I have tried google without much luck.

Here are my steps to reproduce:

  1. I type "if" - the if statement snippet appears in my intellisense.
  2. I hit enter or tab - the if statement is added. There is now a red box inside the parentheses that says "expr".
  3. I now attempt to start typing my variable - nothing is found in the intellisense window.

I have found that if I delete the red box and then move the cursor outside of the parentheses then go back inside the parentheses, the intellisense will then pick up the variable.

My question is: Is there a better way to use the if snippet with variables? Is this my my computer?


回答1:


Thanks Jonathon Chase for pointing me in the right direction. This seems to be an issue with the ReSharper if live template. I would assume some folks like it better that way. Looking through the JetBrains documentation I was able to make the template work the way I wanted.

Here's what I did to fix this issue:

  1. Navigate to ReSharper > Tools > Templates Explorer
  2. Select C# and then find the if template (not the #if template)
  3. Change $expr$ to $expression$

Now save and it should work as expected.



来源:https://stackoverflow.com/questions/53528946/visual-studio-if-snippet-initially-wont-recognize-variables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!