I would like to know how C# and .Net compiler is able to successfully compile a self-referenced class or circular referenced classes within same assembly.
Consider the following code is present within the same assembly.
class X{ X x; }
class Y{ Z z; }
class Z{ Y y; }
Of course, this code compiles successfully.
But How? I'd like to know is how the compiler is able to resolve the classes in these cases for the very first time.
For example, when the compiler encounters class Y, it does not know class Z yet. How is it able to resolve the child property z in Class Y?
Please explain what exactly happens in the background when the code is compiled.
Probably some suitable articles on how compiler resolves classes and types