简体   繁体   English

Visual Studio 2017社区— C#7 ref返回正常工作但没有智能提示

[英]Visual Studio 2017 Community — C#7 ref returns working but not intellisense

So, I've installed VS 2017, imported all my projects and was ready to try out all the new features of C# 7. Most work. 因此,我已经安装了VS 2017,导入了所有项目,并准备尝试C#7的所有新功能。大多数工作。

The problematic one for me has been the new ref returns feature. 对我来说有问题的是新的引用返回功能。 The puzzling thing is, they work! 令人困惑的是,它们起作用了! They compile and produce the expected results. 他们编译并产生预期的结果。 The problem I've been having (in a C# 7 class library project targeting .NET 4.6.2 with AnyCPU as the target) is intellisense , the autoformatter, the auto-complete and resharper all think they don't work . 我一直遇到的问题(在针对以.NET 4.6.2为目标,以AnyCPU为目标的.NET 4.6.2的C#7类库项目中)是intellisense ,自动格式化程序,自动完成和重新共享都认为它们不起作用 (Even though they compile and behave as expected). (即使它们编译并表现出预期的效果)。

public static class SomeClass
{
    public static ref int GetIntByReference()
    {
        //Compiles and does what it promises -
        //returns _someInt by reference
        return ref _someInt;
    }
    private static int _someInt = 15;
}

I get a red squiggly between static and ref with a little "unexpected token" tool-tip. 我用一些“意外令牌”工具提示在staticref之间模糊不清。 Another squiggly under the word ref on the return line with a tool-tip explaining that a semi-colon is expected. 另一个在返回行的ref字下含糊不清,并带有工具提示,解释期望使用分号。 Finally, a squiggly appears under _someInt in the return line indicating that "only assignment, call, increment, decrement, await expression, and new object expression can be used as a statement" 最后,在返回行的_someInt下出现弯曲的提示,表示“只能将赋值,调用,递增,递减,等待表达式和新对象表达式用作语句”

So ... anyone else run into this? 所以...其他人碰到这个吗? The temporary squigglies I can live with, but the autoformat and complete is so hosed, I'm not going to use this feature until there is some kind of resolution. 我可以忍受暂时的弯曲,但是自动格式化和完成是如此困难,除非有某种解决方案,否则我不会使用此功能。 If anyone else has encountered this problem and found a solution, I'd appreciate it if you'd let me know what you did. 如果还有其他人遇到此问题并找到了解决方案,请让我知道您的工作,我们将不胜感激。

I found the same thing to be true in VS 2017. I had been able to do a Resharper "Repair" using the install tool and that worked for about 2 weeks, but now with the latest VS 2017 patch released the other day, it's gotten worse. 我发现在VS 2017中同样如此。我已经能够使用安装工具进行“修复”“修复”,并且工作了大约2周,但是现在就在前一天发布的最新VS 2017补丁中,更差。 I've repaird visual studio 2017, I've repaired resharper with the latest, and XAML intellisense just doesn't work. 我已经修复了Visual Studio 2017,已经修复了最新版本的resharper,并且XAML智能感知功能不起作用。 I've tried disabling Resharper intellisense in the resharper options, and nothing works. 我试图在resharper选项中禁用Resharper intellisense,但没有任何效果。

So what I did to get this working is to simply disable Resharper from Tools and Extensions and restart Visual Studio 2017. Everything works perfectly now, except I can't use Resharper. 因此,我要做的就是简单地从工具和扩展中禁用Resharper并重新启动Visual Studio2017。现在一切正常,除了我不能使用Resharper。 This is the only thing I've found that works, for what it's worth. 这是我发现的唯一有价值的东西。 I feel your pain. 我感到你很痛苦。

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

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