· Aug 19, 2020

Class properties from class name


I'd like to compare classes in two namespaces, whether the corresponding .cls code exist in both namespaces or not, and if it does exist in both namespaces, whether the CLS code is identical. If there is such a routine out there the better, I'd like to see it. If not, I know how to get a list of classes in each namespace and I can check currClss.TimeChanged. What I cannot find is the following:

  1. Programmatic access to cls routine  code lines given the class name
  2. cls routine code size in bites as a crude approximation of cls files in two namespaces being different
  3. Can I compare classes or routines on two different servers?

I has no problem extracting size and code lines info for regular routines via  %Routine including .INT routines compiled from classes but I'd rather compare original classes as opposed to their compiled representation.  %Routine apparently does not process .cls files. The oddDEF solution is ugly, too low-level, and partially binary. I also know I can always export all classes and then diff them in WinMerge or something but I am looking for a differently formatted output.

Thanks in advance,

Discussion (8)1
Log in or sign up to continue

First of all, classes code stored completely differently with plain routines. So, the best way to compare two namespaces is to export all the code in UDL format, which in fact the same as in Studio, usually it was just XML.

From my side I would recommend using VSCode for this task, there you can export any kind of source from InterSystems products with any version since 2016.2. How this process would look there. 

  • open any empty folder in VSCode
  • Configure it to desired server and namespace
  • export source code from InterSystems Explorer view
  • do, git init, and commit all exported files
  • delete all sources
  • switch to another namespace, in the same explorer view, by just opening another namespace.
  • export all sources again.

git will show the differences.

As I'm a developer of VSCode extension for InterSystems, you can contact me directly, or through public issues

I think this is a task better suited for Version Control System, such as git.

  1. Export all relevant code from the first namespace
  2. Commit
  3. Export all relevant code from the second namespace 
  4. Diff

And for CD/CI systems such as Jenkins, GitHub or GitLab.

That said you can use this SQL to compare class hashes (if hashes are identical than classes are identical)

FROM %Dictionary.CompiledClass

After that you can use this SQL to compare hashes of the individual methods (if classes do not match):

FROM %Dictionary.CompiledMethod

It looks like  code below would give me what I am looking for. Just need to figure out (or take an advice!) how to exclude, say, system classes outright. 

f  {
x=rs.Next() q:'x
P.S. Found the answer to my last question: