<PackageReference Include="Google.Protobuf" Version="3.34.0" />

Google.Protobuf.FieldMaskTree

sealed class FieldMaskTree

A tree representation of a FieldMask. Each leaf node in this tree represent a field path in the FieldMask.

For example, FieldMask "foo.bar,foo.baz,bar.baz" as a tree will be:

[root] -+- foo -+- bar | | | +- baz | +- bar --- baz

By representing FieldMasks with this tree structure we can easily convert a FieldMask to a canonical form, merge two FieldMasks, calculate the intersection to two FieldMasks and traverse all fields specified by the FieldMask in a message tree.

public FieldMaskTree()

Creates an empty FieldMaskTree.

public FieldMaskTree(FieldMask mask)

Creates a FieldMaskTree for a given FieldMask.

public FieldMaskTree AddFieldPath(string path)

Adds a field path to the tree. In a FieldMask, every field path matches the specified field as well as all its sub-fields. For example, a field path "foo.bar" matches field "foo.bar" and also "foo.bar.baz", etc. When adding a field path to the tree, redundant sub-paths will be removed. That is, after adding "foo.bar" to the tree, "foo.bar.baz" will be removed if it exists, which will turn the tree node for "foo.bar" to a leaf node. Likewise, if the field path to add is a sub-path of an existing leaf node, nothing will be changed in the tree.

public void IntersectFieldPath(string path, FieldMaskTree output)

Adds the intersection of this tree with the given path to output.

public void Merge(IMessage source, IMessage destination, MergeOptions options)

Merges all fields specified by this FieldMaskTree from source to destination.

Merges all field paths in a FieldMask into this tree.

Converts this tree to a FieldMask.