Region difference discrepancy between rhinocommon and gh

Perhaps a bug that’s addressed in WIP but love to have it working in Rhino 6
The grasshopper native component region difference works.
I call the rhinocommon equivalent in a c# component, but it fails. (4.2 KB)

I also ran into this issue today. Can someone advise me how to get the same result using C# as the Grasshopper “Region Difference” component? In this image below, I can get the ideal result (green colored regions) using the Grasshopper Region Difference component from two sets of curves (blue and red color). However, CreateBooleanDifference from RhinoCommon outputs all the boolean result regions including unnecessary regions.

  private void RunScript(List<Curve> outlines, List<Curve> curves, ref object R)

    double tolerance = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
    List<Curve> resultCurves = new List<Curve>();

    for (int i = 0; i < outlines.Count; i++)
      Curve[] trimmedCurves = Curve.CreateBooleanDifference(outlines[i], curves, tolerance);

    R = resultCurves;

I’m attaching the example file. Thank (13.5 KB)