versionFrom | versionTo | meta.Title | meta.Description |
---|---|---|---|
9.0.0 |
10.0.0 |
Debugging with SourceLink |
Information on SourceLink and how to use it to debug the Umbraco CMS source code |
Microsoft and Visual Studio have introduced a new debugging technology called 'SourceLink' that enables source code debugging of certain .NET assemblies from NuGet. In version Umbraco 8.1+, this feature has been enabled to allow developers to step into the native Umbraco CMS source code.
-
Navigate to Tools -> Options -> Debugging -> General.
-
In the General window, uncheck
Enable Just My Code
option and checkEnable Source Link support
option. -
Click OK to save the changes.
To read about SourceLink, you can take a look at the following websites:
- Create a new
.NET 5.0
Framework blank/empty website. - Install the latest Umbraco CMS 9.0+ Nuget Packages from Nuget.org
- Create an IComposer or similar code in your new site/SLN that you want to F11/Step Into. Example Code Snippet to try with SourceLink
- Prompt will appear and the original source code file is fetched directly from GitHub.
- How far can you
F11
akaStep Into
and go down the rabbit hole of the Umbraco CMS source code?
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Services;
using Umbraco.Extensions;
namespace WebApplication23
{
public class MyComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.Components().Append<MyComponent>();
}
}
public class MyComponent : IComponent
{
private IContentService _contentService;
public MyComponent(IContentService contentService)
{
_contentService = contentService;
}
public void Initialize()
{
// Add break point & F11 into me
var root = _contentService.GetRootContent();
foreach (var item in root)
{
// Add break point & F11 into me
var udi = item.GetUdi();
var foo = 5;
}
}
public void Terminate()
{
}
}
}