简体   繁体   中英

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.

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 . (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. Another squiggly under the word ref on the return line with a tool-tip explaining that a semi-colon is expected. 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"

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. I've repaird visual studio 2017, I've repaired resharper with the latest, and XAML intellisense just doesn't work. I've tried disabling Resharper intellisense in the resharper options, and nothing works.

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. This is the only thing I've found that works, for what it's worth. I feel your pain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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