VS Go to definition failing / source code not available - visual-studio

I've just started experimenting with Visual Studio in order to explore F# but I'm never able to navigate to third-party dependencies code through the "Go to definition" option.
I'm getting this error message:
"Cannot navigate to definition. Source code is not available."
My main language is Java and I'm used to IntelliJ IDEA source retrieval mechanism (usually done through the Maven repositories). I consider this an indispensable functionality when developing code. Isn't there anything similar for .NET?
EDIT
After reading the comments and answer, I went looking for some packages on SymbolSource and I found them (e.g. SymbolSource page for JSON.Net).
I've tried the PM commands shown and the page but they kept producing errors:
Install-Package : An error occurred while processing this request.
So I've downloaded NuGet.exe and by running the command in verbose mode I could obtain the URL it was requesting (e.g. SymbolSource FeedService URL for JSON.Net).
As you can see it is showing an error:
Gettting packages from the NuGet feed is temporarily disabled. But you don't need it for debugging!
Is this to be expected?
P.S.: I've also tried with the pre-authenticated links. Same problem.
P.S.2: Seems that I can step into source code of third party dependencies during debug, but I still can't access it through "Go to definition" (neither in Debug nor in Edit mode).

In Visual Studio, you might be able to Go to Definition to third-party source code if:
You are in Debugging mode
'Enable source server support' options are turned on (you seem to do that already)
The third-party assemblies have their pdb files in source servers
Go to Definition in Editing mode doesn't have that capability in either C# or F#. In F#, 'Navigate to Metadata' hasn't been implemented yet.
We haven't been able to add 'Navigate to Source' to Visual F# Power Tools because they have many tricky issues e.g. (1) The feature is unusable if source server support isn't enabled, which is unfortunate (2) It relies on external data source that might be slow or unavailable (3) There is a good chance that pdb contents are outdated or incorrect, etc.
That said, 'Navigate to Metadata' seems to be less tricky to handle. We have required information from FSharp.Compiler.Service, it requires some effort to filter what we need and present it to users. This feature may be available in a future version of Visual F# Power Tools.

Related

UnityPlayer_UAP_ARM64_release_il2cpp.pdb not loaded

I've installed several packages in a Unity (2020) app I'm building. Namely: World Locking Tools, MRTK, PUN2. World Locking Tools provides some examples that are built with assemblies defining scripting symbols that any derived files I want to build would need access to. I'd like to create my own version of certain files from one of these examples. To do this and have access to the scripting symbols in one of those examples, I created an assembly reference to reference the assembly for that example code within World Locking Tools package installed in my project space. In so doing, I kept running into the common "...not found, are you missing an assembly reference" issue, which ultimately led me to creating assembly references for many of the assemblies provided by the various packages I needed to use (not just the particular example code I initially wanted to modify). Once my project finally built successfully in unity, I then tried to upload to a Hololens 2 headset in Visual Studio. This provided the error in the title of this post. Coincidentally, the app also appears to fail to start on the headset. Before I tried to alter my codebase with modified versions of files from that World Locking Tools example and with assembly references, the code would successfully build in Unity and successfully deploy to the Hololens 2 headset.
Does the behavior and missing .pdb error I describe mean that I'm missing assembly references for yet other packages even though Unity successfully builds the project?
This is my first foray into using assemblies so be please be gentle :)
For the .pdb message, that one is ignorable since will not have that symbol available. However, the app not starting is definitely likely due to a missing component or loading issue. When ran in debugger, may get a better idea on what is missing or from a debugger log in Unity.

How to get profiling data on cache misses in Unity?

I'm searching for a way to get profiling data on cache misses for my Unity project.
I already searched for visual studio tools that do have these stats. I can see Visual studio has tools for .NET applications that shows cache misses (like what's described here https://learn.microsoft.com/en-us/visualstudio/profiling/cpu-and-windows-counters?view=vs-2017), like its Performance Wizard, but they are always grayed out for my Unity project.
I tried attaching Visual Studio's performance tools to my running Unity projects, but I can't seem to find the data I'm looking for.
Unfortunately, Unity's profiler doesn't seem to show the cache misses stats I'm looking for.
I’m using mono but am open to switching to IL2CPP if that can help, I’m mainly exploring unity performance at this point.
I would like to remove guess work from my optimisations. Is there anything I missed?
Edit 1:
Here's what I tested.
I created a build of my test project with IL2CPP selected in the player options
In visual studio, I went to Debug/Performance Profiler, I selected the "Executable" target and used the option "Performance Wizard".
After clicking "Start" I used the option "Instrumentation", clicked next, used "An executable" for the application I want to profile, clicked next, selected my created build's .exe, clicked next and finish.
I then get a failure saying:
Profiling started.
Instrumenting <my path to my exe> in place
Info VSP3049: Small functions will be excluded from instrumentation.
Microsoft (R) VSInstr Post-Link Instrumentation 15.8.18219.1 x86
Unable to obtain debug information. Link with the /PROFILE linker switch.
PRF0002: Instrumentation failed with these options: /u "<my path to exe> /excludesmallfuncs. Please check the output window for additional details.
Data written to <my path>200126(5).vsp.
Profiling finished.
Profiling complete.
I tried looking into Error VSP1011: Unable to obtain debug information. Link with the /Profile linker switch but I'm not sure it's relevant.
I installed VS2013 and tried the same steps and it gave me the same errors.
I finally found a good tool for this.
Looks like Intel's VTune is pretty easy to use and gives good info. For sure it's sampling and doesn't show the exact information, but it gives me hotspots of things to investigate.

Debugging ASP .Net Core symbols and source don't match

I'm trying to track down an issue with MVC so I thought I would step into the ASP .NET Core source code. I've unchecked "Enable Just My Code" and I've checked "Enable .NET Framework source stepping" (although I guess that's not necessary). I've also checked "Enable source server support" and enabled the Microsoft symbol server.
I step into this line
app.UseMvc();
and eventually I get to this code in MvcApplicationBuilderExtensions.cs.
VerifyMvcIsRegistered(app);
var options = app.ApplicationServices.GetRequiredService<IOptions<MvcOptions>>();
if (options.Value.EnableEndpointRouting)
{
Stepping through this code the program counter starts to jump around and I receive an error that several of the local variables cannot obtain the value because it is not available or it's been optimized away. I assume this is because the source file and the symbol files don't match.
I'm running this on Visual Studio 2019. It's .net Core 2.2.203. I've deleted the symbol cache and the SourceServer cache. I'm trying to figure out what I've done wrong in my code and exactly why.
Actually, I've tried to debug .NET source code several times over the past several years and I always have the same issue. None of the online help seems to have an answer. Am I doing something wrong or is this just unreliable?
The message is accurate and explains exactly what happens. It has nothing to do with mismatched symbols.
The (non) problem as the message explains is that the IL has been optimized during compilation, those variables no longer exist. A Release build performs a lot of optimizations that usually end up eliminating parts of the code that aren't needed.
Functions can and quite often are inlined. A variable may be replaced by a register for example. A loop may be eliminated entirely. When that code runs the variables or functions are no longer there so they can't be displayed.
Debug symbols can still be generated in a Release build. They'll reflect the IL generated for a release build though. One would need assemblies compiled in a Debug configuration to get IL that matched the source without any optimizations.
That's true for the .NET Core runtime, our own code when run a Release build and all NuGet packages.
If you want to debug .NET Core source code you can download it from github (https://github.com/dotnet/corefx). It's very easy to debug, like your own project.
There is very good video, where explains how .NET Core MVC request life cycle works (https://app.pluralsight.com/library/courses/aspnet-core-mvc-request-life-cycle/table-of-contents), maybe there you can find information which you need.
P.S. you can get 3 months free in pluralsight with microsoft account.

Which editor and debugger for typescript

I am working on a nodejs project in which all code is written in typescript. It follows a microservice pattern (and each microservice is an independent project) hence lot of projects needs to be opened and debugged at the same time.
I tried webstorm and visual studio (with NTVS) but not satisified with both of them. Webstorm ignores many build errors (very important as those will fail during CI) and not as good as visual studio in intellisense and ease of use. On the other hand, Visualstudio is not as fast as I want. Also I am tied to windows and the filename length problem in node_modules is very frequent and annoying.
Others (atom, VSCode) doesn't have typescript debug support (or am I missing something?).
Can you please share your experience? Also I was wondering which editor google developers might be using to develop angular 2 :)
I have been working on a TypeScript project for 1.5 years now and am quite happy with using Visual Studio because we used .NET for back-end stuffs. For myself I consider the speed as "Ok", it is not that good - but the other stuffs e.g. intellisense is what we really like. I also personally think that as a "son" of Microsoft, TypeScript will get the best support from its "cousin" - Visual Studio.
However if you are a Eclipse person, you may be interested in this TypEcs (http://typecsdev.com/). There was also a post by Steve Fenton talking about TypeScript IDEs you may be interested (https://www.stevefenton.co.uk/Content/Blog/Date/201409/Blog/Which-TypeScript-IDE/), he listed a few of the popular ones with a few sentences of comments, including Atom and the atom-typescript extension.
A bit late to the conversation.
I recently tried VisualStudio 2015, VisualStudio Code 0.9, Atom (with Atom-Typescript package). And quite comfortable with Atom.
Atom-TypeScript uses the latest version of TypeScript so you can use all new features like async/await, string interpolation etc. The package created by community so we don't need to wait for major IDE release to use new TypeScript features.
For debugging couldn't find one. But love to use node-inspector for its light weight. The problem is you need to debug it in javascript version not in typescript version. Not so sure but maybe if you can provide map file you can debug the typescript version? like we have on Google Chrome Inspector.
VSCode can debug in Node. No browser debugging yet.
Not a recommendation, but I suggest you do not buy JetBrains' products (IntelliJ/WebStorm/ReSharper) for TypeScript editing unless you have evaluated them properly.
They reused a lot of their own logic for other languages instead of taking full benefit of the TypeScript language service, which means they behave more like a fancy JavaScript editor that can make some clever guesses as opposed to a robust IDE for a statically typed langauge. (Their type inference is different from the compiler and may fool you into believing an untyped expression (implicit any) is well-typed. Also, all the refactoring are the same as the JS ones, so they do not use or preserve any type information. No type-information-based refactoring (like safe renaming and moving) are available either.)
As for debugging, you may have more milage debugging the generated JS. Not only is it well supported, it also reveals problems that occur in compiler-inserted code. The latter would be otherwise difficult to understand if you're only looking at the TypeScript source. Also, in the generated code, you can actually set break points in single line lambda function bodies.
I too use Visual Studio. I haven't had any problem with its speed; I find everything is as immediate as I expect it too.
However, I haven't been using "TypeScript" projects. I have been using generic "Web" projects with TypeScript files. Plus, I don't use Visual Studio's own building and compilation facilities; I use my own Gulp tasks for my project (including rebuilding, watching for saves, minification, testing, etc), and Task Runner Explorer to manage/run them from inside Visual Studio. I think it's the best of both worlds: the snappiness and features of Visual Studio, and the flexibility of running my own custom tasks independent of platform.
I have to admit I don't do any deep debugging (e.g. breakpoints, stepping) from the IDE. Does VS do that with TypeScript? If I catch an error during execution (in the browser), I always have my source maps indicating where the error is, so I go back to the code, attempt to fix it, save, and reload in the browser.
I am using VSCode to actively debug an angular/node/typescript application. It does work, but you will need to do some setup/configuration. You must tell VSCode how to debug your applications. For instance I have multiple options in my launch.json configuration to debug my gulp scripts, my node server.js file, and the angular/typescript application via chrome using the "Debugger for Chrome" extension installed in VSCode. It is all possible with some configuration. Finally, depending on your exact situation you may need to have and correctly configure the map files for your project from javascript to typescript.
I also had the problem of file paths too long in the node_modules folder in visual studio when opening a project with npm. This is due to Visual Studio trying to download all your packages - incorrectly so I might add. The only way to avoid this for my project was to mark the node_modules folder as a hidden folder in windows (top level only).

Visual Studio C++ Solution in Maven2

A new project is coming up that will require interaction between Java and C++. It's been decided that the project will be built via Maven2.
Unfortunately I don't know anything about Maven and the Java guys don't know anything about C++.
They have their build chain all set up with various reports being emitted for each part related to CheckStyle, Findbugs, Corbortura(?) etc. and they want the same to be done with the C++ side.
Currently we have 4 apps that need building: 2 services, a tray app and a simple dialog based application. I've been told I need to have a pom for each and configure each to output to a target directory, have the tool chain produce the reports - the most particular being the code coverage which the client wants 100%.
I have sourced the tools - Bullseye and QA-C++ and requested eval copies - but I am dismayed to find there is very little information on C++ & Maven, and what little there is seems to be horror stories.
Does anyone on SO have a good story about it (or have link to blog post)?
Is there a simple explanation anywhere for configuring a Visual Studio solution (preferably C++) to be Mavenized?
I am expecting pain but I am getting increasingly wary of this venture - but unfortunately the project manager is Java side and seems hell-bent on Mavenizing it.
See the following stack over flow on the topic.
Using Maven for C/C++ projects
Hope it helps

Resources