Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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?

share|improve this question
    
Good question. As far as I know, it has not been published. – Jonathan Wood Nov 5 '15 at 17:20
    
You've got to do some digging in the coreclr repo. For example, I believe String.nativeCompareOrdinalEx it is mapped to COMString::CompareOrdinalEx found here. Look at the external call list and try to find the function mapping. – mike z Nov 5 '15 at 17:25
    
@mikez The external call list is very helpful and is exactly what I am looking for. Any idea the mapping for String.this[int index]? – Jacob Schneider Nov 5 '15 at 17:41
    
@JacobSchneider It might be FCIntrinsic("get_Chars", COMString::GetCharAt, CORINFO_INTRINSIC_StringGetChar) but that's just a guess. – mike z Nov 5 '15 at 17:42
up vote 1 down vote accepted

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

share|improve this answer
    
Using the CoreCLR in combination with the mapping that mikez pointed out gave me the source code exactly. – Jacob Schneider Nov 5 '15 at 17:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.