Search code examples
c#apiokuma

determine minimum compatible API version


Given that the THINC API is written to be backwards compatible, and lower versions enable a greater number of potential machines to run a given application, everyone should strive to use the minimum version necessary.

Does anyone know if there is an easy way determine what the minimum version necessary for a given application would be?

For example, I've got an application that only uses 3 API functions:
GetHourMeterCount, GetActiveProgramName, and GetMachiningReport

How do I know what API version I can use?


Solution

  • I can think of several possibilities:


    For your situation, the easiest solution I can think of is just to check the .chm documentation for your earliest THINC API version to see if it supports GetHourMeterCount, GetActiveProgramName, and GetMachiningReport. If not, continue checking later versions until you find one that does.


    If you had a more complicated solution that used more THINC API functionality, a quick check would be:

    1. Make sure the project builds cleanly.
    2. Go into the project references and remove the reference to THINC API. Now you will have a compilation error everywhere that THINC API is referenced.
    3. Add a reference to your earliest version of THINC API.
    4. Rebuild. If there are still compiler errors, then your code references one or more THINC methods that do not exist in this version. Move on to the next version and rebuild.
    5. Once your project builds cleanly again, you have found the version of THINC API to reference.

    You could also code a tool that examines your code (via code analysis) or your compiled assembly (via reflection) to find all THINC API functionality, and then looks at multiple versions of THINC API to find the earliest that implements all of the functionality. That shouldn't be difficult, but still seems like overkill.


    For your purposes, it would also be convenient to have a table of all THINC API methods, vs. the versions in which those methods are supported. I don't have such a table, but someone conceivably might.

    All of these methods just check whether certain functions exist in a given version of THINC API. They won't warn you about any breaking changes or different behavior between different versions. That requires knowing the API, checking the release notes, and/or testing.