Brep.CreateBooleanUnion can't deal with non-manifold polysurface

I want to union two objects: non-manifold polysurface and solid
image
the result is that only solid is left
image

If explode non-manifold polysurface to surfaces and join surfaces to new polysurface which is not non-manifold, and then union these two objects, the result will be correct or expected.

It is not necessary to union objects with code, it can be replaced by using builtin command “BooleanUnion”

            GetObject go = new GetObject();
            GetResult gr = go.GetMultiple(2, 2);
            Brep brep1 = go.Objects()[0].Brep();
            Brep brep2 = go.Objects()[1].Brep();

            List<Brep> breps = new List<Brep>();
            breps.Add(brep1);
            breps.Add(brep2);
            Brep[] unionedBreps = Brep.CreateBooleanUnion(breps, 0.0001);
            foreach(Brep unionedBrep in unionedBreps)
            {
                doc.Objects.Add(unionedBrep);
            }

            doc.Objects.Delete(go.Objects()[0].Object());
            doc.Objects.Delete(go.Objects()[1].Object());

Does this work if you use the Rhino commands to make a boolean union? If not, it will never work in code.

Expected result can be gotten via ui, the operations are below:

  1. explode non-manifold polysurface to surfaces
  2. join surfaces to new polysurface which is not non-manifold
  3. and then union these two objects, the result will be correct or expected.

There is a similar bug reported several years ago which is already fixed.

Do anybody have a look at this and give some help?
Thanks!