C
C#7mo ago
Nick

Static Classes without Implementation

What do static classes without implementation mean? Like this:
c#
public static class Host
{
public static HostApplicationBuilder CreateApplicationBuilder();
...
}
c#
public static class Host
{
public static HostApplicationBuilder CreateApplicationBuilder();
...
}
Does the runtime contain implementations and resolve them dynamically at runtime? Where/How can I read the code for these functions then?
15 Replies
Jimmacle
Jimmacle7mo ago
if it's BCL stuff you can look on https://source.dot.net or the .NET github repos
Angius
Angius7mo ago
Where did you find this snippet? Seems like a method stub the IDE would show without decompiling
Jimmacle
Jimmacle7mo ago
if you go to definition on a symbol without source (and you dont have a decompiler) it would look like this yeah
Nick
NickOP7mo ago
I don't see a need for a decompiler though? That source should be enough to compile a call <method> opcode? My guess is that the runtime picks it up then, similarly to the JVM runtime?
Angius
Angius7mo ago
Unless it's code you wrote, it's been compiled to a DLL Thus, to see the full proper source code, it needs to be decompiled
Jimmacle
Jimmacle7mo ago
this is specifically how you get classes without implementation they don't really have no implementation, you just can't see it because it's compiled code
Nick
NickOP7mo ago
There is no need for the compiler to have DLLs if the runtime has them, that is my guess, but please link relevant resources if I'm wrong.
Angius
Angius7mo ago
.NET libraries are also distributed as DLLs Nothing in the .NET environment is distributed as raw code, it's not JS or Python
Jimmacle
Jimmacle7mo ago
the compiler needs the DLLs to find the symbols you're trying to use in your own code
Angius
Angius7mo ago
Frameworks are compiled down to DLLs, the standard library is, any Nuget package is as well
Jimmacle
Jimmacle7mo ago
there are no header files in C#
Nick
NickOP7mo ago
oh, I see it in the name of the directory now, it was indeed a stub produced by a decompiler okay I'm convinced, thanks But still, this is from Microsoft.Extensions.Hosting, how would I go about finding the sources?
Angius
Angius7mo ago
An IDE with a decompiler, or a quick search of the repo: https://github.com/dotnet/runtime Or https://source.dot.net
Nick
NickOP7mo ago
this is the what you'd call the BCL? all of the classes under all of these namespaces?
Angius
Angius7mo ago
BCL is base class library, it'd be a subset of the full runtime library, IIRC Not 100% sure, I'm not that interested into the nitty gritty That said, yes, the aforementioned links contain everything that comes "stock" with .NET
Want results from more Discord servers?
Add your server