简体   繁体   English

Visual Studio 2022 中的代码生成“快速操作”在 C# 中不再有效

[英]Code generation "Quick Actions" in Visual Studio 2022 no longer working in C#

Typically when I implement an interface or write code for which usings are missing it is possible to press Ctrl+.通常,当我实现一个接口或编写缺少 usings 的代码时,可以按 Ctrl+。 (or right click and press 'Quick Actions and Refactorings...') to get a menu of suggestions on what can be done. (或右键单击并按“快速操作和重构...”)以获得关于可以做什么的建议菜单。

Among these suggestions are options to 'implement the interface' which generates stubs for the required methods/properties or 'add usings' etc.这些建议中有“实现接口”的选项,它为所需的方法/属性或“添加使用”等生成存根。

These are no longer available to me.我不再可以使用这些。 Various other actions are but afaik the common theme of those not being available any longer are the ones that in one way or another generates code.其他各种动作只是 afaik 不再可用的那些动作的共同主题,它们以某种方式生成代码。

None of my colleages have the same problem.我的同事都没有同样的问题。 I do however have the problem on ALL computers on which my account is logged into Visual Studio.但是,在我的帐户登录到 Visual Studio 的所有计算机上,我确实遇到了问题。 So it clearly has something to do with my settings that are synced.所以它显然与我同步的设置有关。

  • I have tried resetting the settings.我试过重置设置。

  • I have tried reinstalling VS.我试过重新安装VS。

  • I have tried to change various settings according to various slightly related tips on different forums which addresses similar issues.我试图根据解决类似问题的不同论坛上的各种稍微相关的提示来更改各种设置。

  • I have checked the roslyn log files for any information on something going wrong.我已经检查了 roslyn 日志文件,了解有关出现问题的任何信息。

But so far nothing helps.但到目前为止没有任何帮助。

I've searched various forums and it seems like ppl have experienced the same or similar issues throughout the years but I am unable to find any thread where anyone has actually found the cause of it nor a solution.我搜索了各种论坛,似乎多年来人们都遇到过相同或相似的问题,但我找不到任何人真正找到问题原因或解决方案的帖子。

I can't say for sure but I think this started when upgrading from 17.3 to 17.4.我不能肯定地说,但我认为这是从 17.3 升级到 17.4 时开始的。

Worth mentioning might be that it actually still works in Visual Basic.值得一提的是,它实际上仍然适用于 Visual Basic。

There seems to be no difference if it is .NET FW, Core or 6+. .NET FW、Core 或 6+ 似乎没有区别。

Has anyone experienced something similar and have any suggestions on what can be done to fix it?有没有人经历过类似的事情并且对如何解决它有什么建议?

Thanks!谢谢!

Based on my testing, VS 2022 community 17.4.4 still be able to use the 'implement the interface' feature:根据我的测试,VS 2022 社区 17.4.4 仍然能够使用“实现接口”功能:

在此处输入图像描述

在此处输入图像描述

From your description, looks like if you don't sign in, everything will be ok.从你的描述来看,如果你不登录,似乎一切都会好起来的。

So here are two solutions:所以这里有两个解决方案:

1, Reset the settings of the C#: 1、重置C#的设置:

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

2, Turn off synchronized settings on a particular computer 2、 关闭特定计算机上的同步设置

Otherwise reinstall the VS will be meaningless否则重装VS就没有意义了

在此处输入图像描述

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM