棱镜片段在带有 ReSharper 的 Visual Studio 2017 中不起作用

kar*_*llo 4 c# resharper prism visual-studio

我正在使用 Visual Studio 2017 和 Prism 模板包。

在我安装 Resharper 之前,Prism 片段一直正常工作。现在我可以插入棱镜片段的唯一方法是通过

编辑 -> Intellisens -> InsertSnippet [ Ctrl + K , X]。

它们没有在 Intellisense 中弹出,当我输入代码段时,双选项卡也不起作用。我尝试禁用/启用 Prism 模板包并重新安装它,但没有任何成功。

有人可以就如何让它们重新工作而不将它们重新输入为标准的 Visual Studio 片段有任何提示吗?

PS Visual Studio 片段(prop,propg)工作正常。

MRK*_*MRK 6

Funny! Juts right now! I had the same problem! I searched and found these QA in there: How to disable ReSharper property code autocomplete/code snippet & ReSharper - How to show custom snippet in IntelliSense

In both answers, they said either do:

  • Disable Resharper code snippet to use Visual Studio code snippet
  • From Visual Studio go to ReSharper | Template Explorer | C# | New Template menu and create new code Snippet for Resharper.

which I prefer the 2nd way more. To know more about Template Explorer in Resharper, you can read about it here.

But especially for our problems! I used below steps to add Prism code snippets to Resharper: (Also, You can do the same thing for MVVM Light Toolkit code snippets or ...)

  1. Find Prism code snippets files folder location. (Or MvvMLight or ...): I think the easiest way to do that is to go to: Visual Studio | [Menu] Tools | Code Snippets Manager... | [Language]CSharp | Select Prism from tree, then Copy and paste its Location into Windows Explorer address bar. Then, You will have all code snippets files of Prism.
  2. Open any *.snippet file that you need to add it into Resharper with your text editor.
  3. Create a Resharper template for your Prism code snippet. From Visual Studio, go to [Menu]ReSharper | Tools | Template Explorer... Then from Templates Explorer window/Tab select C# language(from Scopes panel) and click on Resharper - 新模板 - 工具栏图标 icon in toolbar. It will open a Template <No Name> tab inside the Visual Studio. Something look like below image:

在此处输入图片说明

  1. Copy original code snippet from Prism file or write it yourself. From *.snippet file that you open in step 2 in your text editor, Copy lines from <Code Language="csharp"> section between <![CDATA[ and $end$]]> as I show it in below image, Then paste it into Visual Studio | Template <No Name> tab:

在此处输入图片说明

  1. You must give it a Shortcut name and optionally a Description then hit the Save button in Visual Studio. (you can use the same codes from *.snippet file or change it as you wish!) I change it to this to make Resharper more happier!!! lol:

在此处输入图片说明

Done!

In my case, If I type propp and press Tab key once, It will create Prism Preoperty template for me! I Hope this help someone else too !

Happy Coding!