You should be able to get the trigger to work with object %Save:

Trigger OnUpdate [ Event = UPDATE/DELETE, Time = BEFORE ,Foreach = row/object

Could you pretend to be the compiler and run the generator method? Might be a problem if the method does anything other than generate code.

Class temp.proc
{

ClassMethod showcode(classname, methodname)
{
    n %class,%code,%method,%compiledclass,%compiledmethod,%parameter
    
    s %compiledclass=##class(%Dictionary.CompiledClass).%OpenId(classname)
    s %compiledmethod=##class(%Dictionary.CompiledMethod).%OpenId(classname_"||"_methodname)
    s generatorclassname=%compiledmethod.Origin
    s %class=##class(%Dictionary.ClassDefinition).%OpenId(classname)
    s %method=##class(%Dictionary.MethodDefinition).%OpenId(generatorclassname_"||"_methodname)
        
    s key="" f  { s param=%compiledclass.Parameters.GetNext(.key) q:key=""  s %parameter(param.Name)=param.Default }
    
    s %code=##class(%Stream.MethodGenerator).%New()

    s exec=" d "_methodname_"^"_generatorclassname_".G1(%class,%code,%method,%compiledclass,%compiledmethod,.%parameter)"
    x exec
    
    d %code.Rewind()
    w %code.Read()
}

 

I am not sure if all the variables here are set correctly, or if the generator code always ends up in a G1 or even if this is a good idea, was just thinking.

This is not code I have used before.