使用插件方法覆盖核心块

I have created a module in which i am overwriting core functionality of product listing widget. I can achieve this using preference but i want to understand plugin method.. Below is my code for frontend/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\CatalogWidget\Block\Product\ProductsList">
        <plugin name="widget_product_listing_add_attribute" type="Test\CatalogWidget\Plugin\Block\Product\ProductsListAddAttributePlugin" sortOrder="1"/>
    </type>
</config>

and below is my code for plugin block.

namespace Test\CatalogWidget\Plugin\Block\Product;

class ProductsListAddAttributePlugin
{
    public function beforeCreateCollection(\Magento\CatalogWidget\Block\Product\ProductsList $subject, \Magento\Catalog\Model\ResourceModel\Product\Collection $result)
    {
        /**
        * @var \Magento\CatalogWidget\Block\Product\ProductsList $subject
        * @var \Magento\Catalog\Model\ResourceModel\Product\Collection $result
        */

        die('ProductsListAddAttributePlugin before....');

    }
}

after installing module and running di:compile.. when i reload the page i am getting below error.

Fatal error: Uncaught ArgumentCountError: Too few arguments to function Test\CatalogWidget\Plugin\Block\Product\ProductsListAddAttributePlugin::beforeCreateCollection(), 1 passed in C:\xampp\htdocs\projects\hello\vendor\magento\framework\Interception\Interceptor.php on line 121 and exactly 2 expected in C:\xampp\htdocs\projects\hello\app\code\Test\CatalogWidget\Plugin\Block\Product\ProductsListAddAttributePlugin.php:6 Stack trace: #0 C:\xampp\htdocs\projects\hello\vendor\magento\framework\Interception\Interceptor.php(121): Test\CatalogWidget\Plugin\Block\Product\ProductsListAddAttributePlugin->beforeCreateCollection(Object(Magento\CatalogWidget\Block\Product\ProductsList\Interceptor))

1 C:\xampp\htdocs\projects\hello\vendor\magento\framework\Interception\Interceptor.php(153):

Magento\CatalogWidget\Block\Product\ProductsList\Interceptor->Magento\Framework\Interception{closure}()

2 C:\xampp\htdocs\projects\hello\generated\code\Magento\CatalogWidget\Block\Product\ProductsList\Interceptor.php(26):

Mag in C:\xampp\htdocs\projects\hello\app\code\Test\CatalogWidget\Plugin\Block\Product\ProductsListAddAttributePlugin.php on line 6

Have you run setup:di:compile and clear the cache? after updating the beforeCreateCollection method?

It looks like you're correctly passing two arguments through, but it might be referring to an older DI.

Try to remove the generated code I think you working under Windows you can run the following command on your prompt terminal. Make sure first that you are under developer mode

php bin/magento deploy:mode:set developer

php rm -rf generated*
php bin/magento cache:flush
php bin/magento cache:clean
php bin/magento setup:upgrade
bin/magento setup:di:compile