protected void MergeTypes(TypeDefinerScopeImpl other)
 {
     foreach (var kv in other._types)
     {
         if (!_types.TryGetValue(kv.Key, out var my))
         {
             my = new TypeScopeImpl(Workspace, this);
             _types.Add(kv.Key, my);
         }
         my.MergeWith(kv.Value);
     }
 }
 internal void MergeWith(TypeScopeImpl other)
 {
     Debug.Assert(other != null);
     if (TypeKey != other.TypeKey)
     {
         throw new InvalidOperationException($"Unable to merge type '{_typeDef}' with '{other._typeDef}'.");
     }
     _typeDef.MergeWith(other._typeDef);
     CodePart.MergeWith(other.CodePart);
     MergeTypes(other);
     _funcs.MergeWith(Workspace, this, other._funcs);
 }
        public ITypeScope CreateType(Action <ITypeScope> header)
        {
            if (header == null)
            {
                throw new ArgumentNullException(nameof(header));
            }
            TypeScopeImpl typeScope = new TypeScopeImpl(Workspace, this);

            header(typeScope);
            typeScope.Initialize();
            _types.Add(typeScope.TypeKey, typeScope);
            Workspace.OnTypeCreated(typeScope);
            return(typeScope);
        }
 internal void OnTypeCreated(TypeScopeImpl t) => TypeCreated?.Invoke(t);