IDynamicBuffer IDynamicBufferBuilder.Commit()
        {
            mType   = mTypeBuilder.CreateType();
            mData   = Activator.CreateInstance(mType);
            mBuffer = new HardwareConstantBuffer(mProvider, Marshal.SizeOf(mType));

            foreach (var fieldKey in mFieldNames)
            {
                var field = mType.GetField(fieldKey).AssertNotNull();
                mFields.Add(fieldKey, field);
            }

            UpdateBuffer();
            return(this);
        }
        protected override void DisposeOverride()
        {
            if (mIsDisposed)
            {
                return;
            }

            mFieldBuilders.Clear();
            mFieldNames.Clear();
            mFields.Clear();

            mBuffer?.Dispose();
            mContext.RemoveBuilder(mTypeName);

            mTypeBuilder = null;
            mBuffer      = null;
            mType        = null;
            mData        = null;

            mIsDisposed = true;
        }