How to replace AnimationUtility.GetAllCurves(AnimationClip, bool)

I’m currently cleaning up the code and I have the warning:

warning CS0618: ‘AnimationUtility.GetAllCurves(AnimationClip, bool)’ is obsolete.

Following Unity’s advice and use GetCurveBindings and GetObjectReferenceCurveBindings instead I don’t get AnimationClipCurveData as a result.

What is the correct code to replace the obsolete function without touching the other code around?

Surely I can supress the warning wit #pragma warning disable, but that’s just the second best option.

I think the proper method now is

foreach (var i in AnimationUtility.GetCurveBindings(clip))
  var curve = AnimationUtility.GetEditorCurve(clip, i);