简体   繁体   中英

Visual Studio for Mac 2022 "Go to Definition" in "using" lines doesn't work

I created a simple console project with the following:

using Newtonsoft.Json;

namespace JsonExample
{
    public class Program
    {
        public static void Main()
        {
            // Create an instance of a class to serialize
            Person person = new Person
            {
                FirstName = "John",
                LastName = "Doe",
                Age = 30
            };

            // Serialize the object to a JSON string
            string json = JsonConvert.SerializeObject(person);

            // Print the JSON string
            Console.WriteLine(json);

            // Deserialize the JSON string back into an object
            Person deserializedPerson = JsonConvert.DeserializeObject<Person>(json);

            // Print the values of the deserialized object
            Console.WriteLine($"{deserializedPerson.FirstName} {deserializedPerson.LastName}, Age {deserializedPerson.Age}");
        }
    }

    public class Person
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int Age { get; set; }
    }
}

And then I placed the cursor/caret above the Json part of using Newtonsoft.Json; , did the "Go to Definition" functionality in Visual Studio so I could see more about this namespace but it returned a window saying: 'Cannot navigate to the symbol under the caret.'. On every other package installed via NuGet this happens and I don't know why. I obviously added the package to the project and it also builds without any issues.

I was expecting something like JetBrains Rider:

在此处输入图像描述

Those commands are only for direct symbol access. The only way I know of is Object Browser,then search or navigate to what you want to look at.

This is the same behavior as Visual Studio on Windows as well.

There is a similar question that might be a little helpful:

https://stackoverflow.com/a/20216717/3885008

Shift + Alt + F12 , then right click in the results and select Browse Definition

But, that is about as close as I could find to what you want to do with a using statement for a namespace.

The feature I was looking for is not available as of 2022. Please see https://developercommunity.visualstudio.com/t/Going-to-definitions-on-locally-installe/10236228 for extra information.

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