TL;DR
The answer to your question is No, it's not possible.
The article speaks about the source code location and not the object. But much of the answer is covered in the article you shared, and if you read it fully you will know why it's not possible. For the benefit of everyone i will add the excerpt here.
- Based on the available assembly metadata as of today, the runtime can infer the location of the problem and not the object.
- There are no guarantees that the PDB is always there with required information to weave the IL back to a n identifier.
- It's not just C#,but a bunch of other languages have to support this to make this work in the .NET runtime, which is less likely at this moment.
Assembly Metadata doesn't have debug information
Finding a name of an object during runtime requires debug information to be available, which is based on the configuration you used to build your code. There is no guarantee that the runtime can weave an address or register to a name. The assembly metadata contains the description of the Assembly , Data Types and members with their declarations and implementations, references to other types and members , Security permissions but doesn't contain source information.
Using PDB's would make it inconsistent as you don't have control over framework and library (nuget) code
I think it might not even be possible to do this consistently, Even if all compilers targeting CLR, emit enough information about identifiers (all language compilers) and the runtime consume it. The way the .NET project gets compiled won't be consistent given the fact that any .NET project that i can think of reference binaries from community / NuGet. In that case a part of the code report identifier names and the other part wouldn't.
Consider what happens to the generated types (for example IEnumerable) The runtime can figure out and report that IEnumerable.Current is null, but what is null is the underlying object in the container, which still doesn't give the answer. You walk the stack and figure out the underlying object and fix it, which is the case even without the information.
Consider multithreaded code, where you might know which object is null, but you might not know which context / call stack caused it to be null.
So my conclusion is,
we should try to infer context from methods than identifiers. Identifiers tell you what is null, but often you need to figure out why it is null because the programmer didn't anticipate it, he has to walk the stack back to figure out the issue. In case where the object is a local variable it's a programmer's error and might not have to be the runtime to figure it out.