How to uniquely identify a method

We’re trying to do an integration with 4D Remote and Git using the macro system. We’ve hit a little snag… namely that any method can be renamed. Even changing the capitalization of an object will rename the object method as far as Git is concerned.

Is there a way to get a UUID or other unique and unchanging value for methods and object methods?

One thought we had was to generate a UUID and store them in the method comments (not sure yet if this will work with object methods).

Are there any other ideas?

: Jeffrey KAIN

One thought we had was to generate a UUID and store them in the
method comments (not sure yet if this will work with object methods).
Are there any other ideas?
That’s what Vincent de Lachaux made (still makes? I did not check) in 4d pop methods. But I’m not fan about using comments for that. In the passed I made some things using the CC4D reference but knowing a created method was using the first found deleted one, it was bad.

IMHO using macros is the complicated way

  • no delete detection
  • spread on all developing clients, it will be necessary to consolidate
  • what about forms
    I’d love https://forums.4d.com/Post/FR/27606863/1/27618112#27606864triggers for “structure objects”> (at least code and forms) on server side instead. We could manage many missing things this way: who (Current user), when, etc. When I take a look at how the explorer reacts on these events on another developer machine than mine, it makes me suppose it would not be a huge job.

Agreed that using macros is a bit complicated and fragile… but that problem will be solved soon enough with ‘projects’. Looks like it’s comments or nothing…

Is it an issue because you are using macros and you have both the original method and the renamed method? Seems like that is not going to work unless you implement something to delete method paths from the repository that are no longer in 4D. I don’t use macros, just a method that updates the repository and deletes any orphaned method paths. It runs in seconds for a structure with 5000+ methods and 150 tables. Git does a nice job of figuring out that a method was renamed and keeping the history intact.

Yes - that’s correct. We also have a batch method that updates a repository and deletes the orphaned paths – this happens about every two weeks when we push new code into production (it happens on version change of our development structure). We also have a separate repository that tracks changes in real time on method save, which is where this little issue is popping up.

Arnaud mentioned CC4D which might work for project methods if you put them in the trash without emptying it. I also noticed that FORM Convert to dynamic has a kind of CC4D for object method paths:

“method”: “/CC4D/829/cbcd85fe605df655098f8c8336713709”,

You might be able to incorporate that somehow, but it seems easier just to run a method to removed orphaned paths.

: Jeffrey KAIN

We also have a separate repository that tracks changes in real time
real time, that’s where triggers would be helpful…

Another place we can read/write something is explorer method comments, instead of code comments. I realise (:oops:) forms have such comments too, but it seems there’s no command for those.

Hi,

It might not be the most efficient way but…

I did notice (with some light testing) that compiling generates a
{dbFolder}/Project/DerivedData/CompiledCode/map.json
file that maps a unique ID to a method path. This file, unfortunately, is only updated with a successful compile.
Even if a method is renamed or even moved to the trash but not emptied the ID is kept for that method. If a method is deleted and emptied from the trash, the ID does not appear to be reused even if a new method with the same name is created.

As I mentioned not efficient, but a way to confirm things is to make sure to compile regularly and use the mapping to confirm methods.

Maybe, a future update will assign the ID to the method in a more easily accessible way.