Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon How can I use Source Linking to debug MvvmCross issues


How can I use Source Linking to debug MvvmCross issues


Using Source Linking to Debug MvvmCross Issues

Source Linking is a powerful tool that allows developers to step through the source code of libraries like MvvmCross during debugging. This feature is particularly useful when troubleshooting issues within MvvmCross, as it enables you to navigate directly into the library's source code from your application. Here's a step-by-step guide on how to use Source Linking for debugging MvvmCross issues:

Enabling Source Linking in Visual Studio

1. Open Visual Studio: Start by opening your project in Visual Studio.
2. Enable Source Link Support: Go to `Tools > Options > Debugging > General` and ensure that the `Enable source server support` checkbox is selected. This option allows Visual Studio to download source files from source servers like GitHub when debugging[1][11].
3. Enable Source Link in Project Settings: If you are building your own library and want to enable Source Linking, you need to configure your project settings. This involves setting properties like `true` and including a Source Link package in your project file[4].

Debugging with Source Linking

1. Trigger Debugging Action: To use Source Linking, you need to trigger a debugging action. This can be done by setting breakpoints or enabling all exceptions in the `Exception Settings` window of Visual Studio. This ensures that when an exception occurs within MvvmCross, Visual Studio will break at that point, allowing you to step into the MvvmCross source code[1].

2. Step into MvvmCross Source Code: Once an exception is raised or a breakpoint is hit, Visual Studio will prompt you to download the source code for MvvmCross if it's not already available. You can choose to download and continue debugging. This will take you directly into the MvvmCross source code, where you can inspect variables, set additional breakpoints, and continue debugging as if the MvvmCross code were part of your project[1][4].

3. Reproduce Issues with the Playground Sample: If you encounter an issue that you cannot reproduce in your main project, try using the MvvmCross Playground sample. This sample project is included with the MvvmCross source code and can help isolate issues specific to MvvmCross[1].

4. Contribute to MvvmCross: If you identify a problem within MvvmCross, you can contribute by raising an issue on GitHub or even submitting a pull request with a fix. Using Source Linking helps you provide detailed information about the issue, which is invaluable for the community[1].

Troubleshooting

- Cache Issues: Sometimes, the Source Link cache might cause problems. You can find and clear the cache in `~/Library/Caches/VisualStudio/8.0/Symbols` on macOS or similar locations on Windows[10].
- Symbol Problems: Ensure that symbol files (PDBs) are correctly distributed and available. If you encounter issues with symbols, refer to the GitLink README for troubleshooting tips[11].

By following these steps, you can effectively use Source Linking to debug MvvmCross issues and contribute to the community by providing detailed reports or fixes.

Citations:
[1] https://nicksnettravels.builttoroam.com/post-2018-07-31-debugging-and-contributing-to-mvvmcross-aspx/
[2] https://www.mvvmcross.com/documentation/fundamentals/viewmodel-lifecycle
[3] https://forum.qt.io/topic/135657/qt-windows-application-deployment-issue-runs-great-in-debug-but-not-fully-functional-as-deployed-stand-alone-app
[4] https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-improve-diagnostics-debugging-with-sourcelink?view=vs-2022
[5] https://www.mvvmcross.com/documentation/fundamentals/navigation
[6] https://www.mvvmcross.com/documentation/advanced/customizing-using-App-and-Setup
[7] https://stackoverflow.com/questions/21029462/debugging-mvvmcross-application-in-xamarin-studio-with-mvvmcross-sources
[8] https://www.mvvmcross.com/logging
[9] https://www.mvvmcross.com/documentation/fundamentals/linking
[10] https://blog.verslu.is/development/clearing-source-link-cache/
[11] https://www.mvvmcross.com/documentation/contributing/debugging-with-symbols