Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Framework External Method Source Code

Tags:

c#

.net

Is there any way to see the source code for methods that are implemented externally in the .NET framework?

I know about Reference Source which is a great resource, however a lot of the core classes in the .NET framework are implemented externally (I assume in C++?).

For example I am very interested in the internal workings of of the class String but almost half of the methods are declared with the extern keyword including this[int index] which appears to actually hold the characters in the string.

Where can I find the source code for String.this[int index] or String.nativeCompareOrdinalEx(String strA, int indexA, String strB, int indexB, int count) and other externally implemented methods?

Also, is there a particular reason why so much of the core framework classes are implemented externally? Is it so that they could utilize existing code or for performance reasons or something else?

like image 731
Jacob Schneider Avatar asked Nov 05 '15 17:11

Jacob Schneider


People also ask

How do I view source code in Visual Studio?

You can open code into Visual Studio in the following ways: On the Visual Studio menu bar, choose File > Open > Folder, and then browse to the code location. On the context (right-click) menu of a folder containing code, choose the Open in Visual Studio command.

How do I create a .NET Framework?

You can use command-line compilers or Visual Studio to create a single-file assembly that targets the . NET Framework. By default, the compiler creates an assembly file with an .exe extension. Visual Studio for C# and Visual Basic can be used only to create single-file assemblies.


1 Answers

For the new, community, version you can dig in the github, that's where I found the implementation of decimal subtraction (or were I was pointed to by SO in fact)

CoreCLR / src

You have roslyn code there too:

Roslyn at Github

like image 163
mikus Avatar answered Oct 05 '22 09:10

mikus