Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Where in the .NET Source Code are keywords defined

I’m browsing the .NET source code reference (https://referencesource.microsoft.com/) in an effort to find the codefiles in which keywords are defined. Specifically, I’m interested in how await in the TPL is defined/implemented, but I’d also like to browse the internal implementation of other keywords at some time.

Doing a search for the string "await" on their reference site above only returns class, property, and field names that contain the string "await" (e.g., class AwaitTaskContinuation).

I realize this seems like a basic question, but I can’t find any information elsewhere on this.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

https://referencesource.microsoft.com/ provides source code for the .NET Framework libraries (for .NET Core use https://source.dot.net/) it does not "define" keywords.

In particular case of await – it is syntactic sugar which is handled by the compiler (Roslyn) and you can try to search how it desugars it to actual code in the github repo.

Or (I would say better, at least in the beginning) use some C# decompilation tool. There is online one https://sharplab.io/ (handles decompilation to C#, IL and even JIT Asm) – example decompilation for the following code:

using System.Threading.Tasks;
public class C {
    public async Task M() => await Task.Yield();
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading