1

Given a large C++/C# codebase, what's the best way to pull out just the public interface from all the code? The intent is to have a more automated way to alert when something public facing has changed. So public classes, method, properties, fields.

The goal would be to just create a file listing the public interface so that, in the future, the process could be repeated and the two files diff'd to see what changed in the public interface.

This way, if someone removes a public method, or changes a property or method signature, that would show up when doing the diff of the before and after results of such a tool.

The implementation is not desired, just the public facing interface. Has anyone had any luck doing this?

One thing I tried was Doxygen, setting it to export to XML, but it included private fields, for example. Is it just a matter of tweaking Doxygen settings correctly or is there a better tool out there to do this?

SergeyA
  • 61,605
  • 5
  • 78
  • 137
Nerdtron
  • 1,486
  • 19
  • 32
  • 1
    You use Doxygen in C#? – Thomas Weller Sep 08 '21 at 17:42
  • 1
    It's really easy for C# using Reflection. If the question were not off-topic, you should at least spilt it into 2 parts, because the approaches for C# and C++ are very different, IMHO – Thomas Weller Sep 08 '21 at 17:42
  • 1
    Have you tried configuring Doxygen to not print private parts? – Thomas Matthews Sep 08 '21 at 17:55
  • @ThomasWeller No, I don't use Doxygen for C#, I used it in the past for Java and C++, but here was thinking maybe it would be a good way to pull out the public interfaces. – Nerdtron Sep 09 '21 at 03:29
  • @ThomasWeller reflection is a good suggestion, I could go that route, but wanted to check and see if there were other approaches. It's a single question here because Doxygen supports both C# and C++ so was thinking it may be a way to get both. – Nerdtron Sep 09 '21 at 03:31
  • @ThomasMatthews yes, the private option was off when testing but it still included private elements. – Nerdtron Sep 09 '21 at 03:31
  • 1
    We successfully used [this tool](https://github.com/PMudra/ApiCheck) for such tasks – Klaus Gütter Sep 09 '21 at 05:31
  • 1
    When doxygen output XML format it outputs all entities and the user has to filter them out (this is done on purpose to give the end user more flexibility) – albert Sep 09 '21 at 07:44
  • @KlausGütter thanks, will check that out. – Nerdtron Sep 09 '21 at 12:53
  • @albert I guess that explains what I saw then. sounds like it may not be ideal for what I'm trying to do. – Nerdtron Sep 09 '21 at 12:54

0 Answers0