2
votes

I can use tools like "dumpbin" and "dll export" to see the public entrypoints ("exports") of standard win32 DLL's like Windows\SYSTEM32\GDI32.dll. But when I use these same tools on .Net DLLs all I see is something like

    2000 .reloc
    2000 .rsrc
   48000 .text

I have a C#/.Net DLL that provides entrypoints to control an industrial process and I want to check its public entry points against our documentation to ensure completeness of the public documentation. What tool shows public entry points for a .Net DLL?

I've tried Jetbrains DotPeek, which does a complete decompile of our DLL into C# source code, but that's overkill because it shows EVERYTHING and doesn't seem to have a summary mode where it just reports out public entry points.

2
All public classes and interfaces with public methods and properties can be seen as "public exports" of .NET assembly. Hence you can review it manually with some decompiler (as you already did) or try to write code using Reflection to list all such methods.Konrad Kokosa
Managed assemblies don't use unmanaged exports. Many ways to go about this, the sane one is to write unit tests.Hans Passant
Not sure how unit tests address the question. Our goal is to make sure that when the user has our DLL everything that's publicly visible via the DLL is documented. Obviously we can surmise what's publicly visible by studying the source code or the assembly but that's only a surmise. Knowing what the DLL exposes is the empirical test, or at least that's how we did it with the older Win32 DLL's. The assembly and source code tell us what should be publicly visible, I was hoping the DLL could provide a double-check for what actually, empirically is publicly visible.user316117
That's because .NET is component based programming. There is no need for double checking exports defs vs exports code. Every public component is available, metadata (accessible via Reflection) describes them. Client references assemblies and through metadata knows what is available.Konrad Kokosa

2 Answers

4
votes

I assume that by "entry points" you mean "public classes and methods"

How about using the visual Studio object browser?

  1. Create a test project
  2. Add a reference to the DLL you want to inspect.
  3. Double click on the reference to open the object browser
  4. Click the little "Gear" icon and uncheck "Show Private Members," "Show Protected Members," "Show Other Members" so you only see public stuff.
  5. Start browsing.
2
votes

Just as a starting point only, how to list all public types from current assembly and list all public methods from them:

Assembly assembly = Assembly.GetExecutingAssembly();
var exports = 
assembly.GetExportedTypes()
        .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.Public)
                                .Select(member => new
                                {
                                    type.FullName,
                                    Member = member.ToString()
                                }))
        .ToList();

But this omits nested classes, properties and should be probably extended in few ways to suit question needs.