You can use the Product Collection factory as below.

    $_collection = $this->_productCollectionFactory->create();
    $_collection->addAttributeToSelect('*');
    $_collection->addAttributeToFilter('status',\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED);
    // Your attribute code   
    $_collection->addAttributeToFilter('size',  array('notnull' => true));


Get your product.

    foreach ($_collection as $_product) {
        $_product->getName();
    }