I'm trying to debug the Antiforgery code in the ASP.NET Core framework.
I have built the code successfully using the instructions in https://github.com/dotnet/aspnetcore/blob/master/docs/BuildFromSource.md using the Debug configuration.
I have added the source code project to my test project and referenced it.
I've checked that the Configuration is set to Debug.
I've made sure that "Suppress JIT Optimizations" has been checked.
"Optimize Code" in Project Properties -> Build, is unchecked for both projects.
"Debug Info" dropdown has been set to "Full" in the Advanced Options (Under Build tab) for both projects.
However when I hit the breakpoint in DefaultAntiforgeryTokenSerializer.Serialize(), it gives me this error when viewing the method's local vars in the Watch window:
Cannot obtain value of local or argument as it is not available at this instruction pointer, possibly because it has been optimized away
How can I force the code to not be optimized?
I'm using Visual Studio Enterprise 2019 v16.8.3.

Microsoft.AspNetCore.Antiforgery.iniand then put it into the output folder ofMicrosoft.AspNetCore.Antiforgeryproject which existsMicrosoft.AspNetCore.Antiforgery.dll. Then, add these in that file:[.NET Framework Debugging Control] GenerateTrackingInfo=1 AllowOptimize=0. Also, create a file calledAntiforgeryTest.inifor your test project and then do the same steps. The referenced document is here.