Intellisense not working in code snippets - VS Code

人走茶凉 提交于 2020-07-18 05:45:47

问题


I have installed the C# extension in VS Code. The problem I am having is, after using a code snippet prop, Intellisense no longer suggests variable types. This happens with other things like ctor as well, it will not autocomplete the class name, for example.

I have tried uninstalling/reinstalling the extension. I have Googled without luck as well.

I expect for Intellisense to suggest variable types, for example. Intellisense does not suggest anything.

Hitting Ctrl+. does suggest the correct fix among the list.

Edit: My project does not have a project.json or *.sln file. I created the project using the command line dotnet new webapi. If that is what is required, how do I add it or get Intellisense working?


回答1:


By default, intellisence / quick suggestions will not be triggered inside of a snippet. To enable them set

"editor.suggest.snippetsPreventQuickSuggestions": false

true is the default.




回答2:


Mark answered the question above. If he is able to come back I'll accept his answer.

File > Preferences > Settings

Search for editor.suggest.snippetsPreventQuickSuggestions.

Make sure the box is unchecked.

Thanks Mark!




回答3:


Visual Studio Code's more advanced editing features (IntelliSense, refactoring tools, etc.) only work in C# files if you have a project.json file or *.sln file that VSCode is aware of.

Open the folder (i.e. open the File menu and click Open Folder...) with the *.sln file or project.json and VSCode will attempt to find all project/solution files in the folder.

If there are multiple projects, you may need to select one from the projects button on the right side of the status bar (bottom of the window).

From the VSCode website:

Selecting a project.json-file is opening a DNX-project and VSCode will load that project plus the referenced projects

Selecting a *.sln-file is opening a MSBuild-project. It will load the referenced *.csproj-projects and sibling or descendant project.json-files but no other project files that are referenced from the solution file.

Selecting a folder will make VSCode scan for *.sln and project.json files and VSCode will attempt to load them all.



来源:https://stackoverflow.com/questions/55683145/intellisense-not-working-in-code-snippets-vs-code

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