views:

68

answers:

3

Hello there! I'll have to generate a lot of externs so I can interface with the .NET framework from another programming language for an open-source project I'm working on. I was wondering if there is any way to get all the MSDN class references as an XML or something? I'm thinking about parsing the actual HTML, but it seems it won't be very straight-forward, so I was wondering if there is a better way to do it.

The most detail I can get from them, the better. So for example if it works on the Compact Framework, or version differences, would be great to be able to get.

Thank you very much!

+1  A: 

Have you looked at Pinvoke.net, a site full of the interfaces to external windows DLLs (including Windows CE DLLs for use with Compact Framework).

For non Windows DLL interop, the Pinvoke Interop Assistant helps you figure out the externs for talking to non-managed DLLs.

sbass
+2  A: 

You could use reflection on the DLLs to get a list of classes, method parameters etc. I assume this is what you ultimately need.

Take a look here for more information: http://msdn.microsoft.com/en-us/library/ms173183(VS.80).aspx

You could easily write some .Net code to print out the data on the classes, or even use it to autogenerate code in another language.

I've no idea what you plan to do with this though. Surely if you want to use the .Net Framework it would make sense to do it in .Net? If you want open source have you looked at Mono (http://www.mono-project.com/Main_Page)?

Steve Haigh
Hey ! Thanks for the tip. I really can look into mscorlib like that, with the use of reflection. But the problem is that I'll have the code specific to the .dll I'm using. Maybe it is an option, to read all .dlls across different versions (including mono) and sort their differences out. But it would be much easier if there was already some kind of machine-ready doc files ;).
Waneck
+2  A: 

Example code (written directly in this answer, you have to modify it):

//Will load your assembly and all .Net core assemblies.
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
    Console.WriteLine("Going through " + assembly.Location);
    foreach(var type in assembly.GetTypes())
    {
        Console.WriteLine("Type " + type.FullName + " has the following methods:");
        for (var method in type.GetMethods())
        {
           // you can create another loop to go through all method arguments.
           Console.WriteLine(method.Name);
        }
    }
}

To go through all assemblies, simply use Directory.GetFiles() on all subdirectories in C:\Windows\Microsoft.Net\Assembly\GAC_MSIL and Assembly.Load them.

jgauffin
Hey! Thanks! This snippet is very useful!
Waneck
But I'm still in the hopes of finding a way to read the actual doc files, so I can get the differences across the many framework versions !
Waneck
Framework versions is not problem, you can find it with assembly.ImageRuntimeVersion.
jgauffin
...so all I need is the mscorlib.dll from each runtime version? (including CompactFramework, XNA, etc.)?
Waneck
Would there be a way to read all different dll runtime versions from one program only?
Waneck