Closed
Description
The video below shows how stepping into ResourceGraph
source code works, but fails when stepping into Identifiable<int>.StringId.get
. For reasons unknown to me, the video tool failed to capture the context menu on right-click, where I selected "step into specific" to step into the .StringId
getter.
JsonApiDotNetCoreWebApi1.Debugging.-.Microsoft.Visual.Studio.Preview.2022-10-03.23-31-16.mp4
This is because Microsoft.SourceLink.GitHub (which enables to download sources from GitHub and step into) is missing in the list of package references in JsonApiDotNetCore.Annotations.csproj
.
For reference, the source code from the video, in case it's hard to read:
using System.Collections;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Controllers;
using JsonApiDotNetCore.Services;
using JsonApiDotNetCoreWebApi1.Models;
using Microsoft.AspNetCore.Mvc;
namespace JsonApiDotNetCoreWebApi1.Controllers
{
public class PeopleController:JsonApiController<Person,int>
{
private readonly IResourceGraph _resourceGraph;
public PeopleController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
IResourceService<Person, int> resourceService)
: base(options, resourceGraph, loggerFactory, resourceService)
{
_resourceGraph = resourceGraph;
}
public override async Task<IActionResult> GetAsync(CancellationToken cancellationToken)
{
IActionResult result = await base.GetAsync(cancellationToken);
_resourceGraph.FindResourceType(typeof(Person)); // <-- step into works
var people = (IEnumerable<Person>)((OkObjectResult)result).Value!;
foreach (Person person in people)
{
string? id = person.StringId; // <-- step into fails
}
return result;
}
}
}