Show / Hide Table of Contents

Interface ICloneable<T>

Nodes in a IDirectedAcyclicGraph<T> which, although immutable, may be cloned given a new collection of parent nodes. This allows parent replacement logic to be shared across Expression and Table nodes.

Inherited Members
IDirectedAcyclicGraph<T>.Parents
Namespace: Mangrove.MetricSetSyntaxTree
Assembly: MetricSetSyntaxTree.dll
Syntax
public interface ICloneable<T> : IDirectedAcyclicGraph<T> where T : ICloneable<T>
Type Parameters
Name Description
T
Remarks

There is some unnecessarity verbosity around the way that Expression and Table nodes implement this interface, because C# does not (yet) implement return type covariance. It would be ideal for e.g. the abstract Table class to implement this interface with T == Table, and then each subclass to override the implementation with T == e.g. Join. Sadly, C# does not allow this. To get around this limitation, we instead implement two Clone(IReadOnlyList<T>) methods: one, less strongly typed, which only takes the flat list of parents, and another, more strongly typed, which takes some extra information.

For more information on the state of return type covariance in the C# ecosystem, see:

  • https://stackoverflow.com/q/5709034
  • https://github.com/dotnet/roslyn/issues/357
  • https://github.com/dotnet/csharplang/issues/49

Methods

View Source

Clone(IReadOnlyList<T>)

Create a copy of this, using a new list of direct parents.

Declaration
T Clone(IReadOnlyList<T> parents)
Parameters
Type Name Description
IReadOnlyList<T> parents
Returns
Type Description
T

Extension Methods

ObjectExtensions.EventId(Object)
  • View Source
Back to top Generated by DocFX