Skip to content

Do you really have to create the root upfront? #388

Open
@SebastianStehle

Description

@SebastianStehle

Hi,

I got a bug report for our .NET wrapper. The code example is as followed:


        var localDoc = new Doc();
        var localText = localDoc.Text("name");

        using (var tx = localDoc.WriteTransaction())
        {
            localText.Insert(tx, 0, "Y-CRDT");
            tx.Commit();
        }

        var remoteDoc = new Doc();

        byte[] remoteState;
        // Get the remote document state vector.
        using (var tx = remoteDoc.ReadTransaction())
        {
            remoteState = tx.StateVectorV1();
            tx.Commit();
        }

        byte[] stateDiff;
        using (var tx = localDoc.ReadTransaction())
        {
            stateDiff = tx.StateVectorV1();
            tx.Commit();
        }

        using (var tx = localDoc.WriteTransaction())
        {
            tx.ApplyV1(stateDiff);
            tx.Commit();
        }

        using (var tx = remoteDoc.ReadTransaction())
        {
            Text? textProperty = tx.GetText("name");
            // as a new user, I expected this to return the Text since the sync should have created
            // it.

            // Instead, the docs state it should be null: "Returns the Text at the Doc root level, identified by name, 
            // or null if no entry was defined under name before." However, it throws instead.
            Assert.NotNull(textProperty);
        }

The user asked if it is by design that the does not see the root, if he uses the code above. I was also not sure about this and whether he or I made something wrong. Could also be a bug ofc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions