How to embed C++ class to MLIR operation?

Hello all,
I have C++ class containing member data and methods and it is needed to embed it into some MLIR operation in a custom dialect.
It is not possible to simply insert it as a data member in an op ExtraClassDeclaration section because MLIR operation prevents such a practice.
Is there an elegant and legal way to embed this class in a MLIR operation?

Yes, we call this “property”, see here for an example: llvm-project/mlir/test/lib/Dialect/Test/TestOps.td at 14e6f63ee64711bbd74a0fda745f62f62556d70d · llvm/llvm-project · GitHub

Hello Mehdi,
Thank you for the advice with properties.
I tried to carefully study and implement the example you have suggested and let me ask a little more. Yes, I see class TestOpWithWrappedPropertiesGenericAdaptorBase and struct Properties inside it where functions MyPropStruct getProp() and void setProp(const MyPropStruct &propValue) allow to get and save the instance of MyPropStruct that is a data member of struct Properties.
And yes, I can get the instance of struct Properties via TestOpWithWrappedProperties::getProperties().
But I couldn’t find how to store the modified instance of MyPropStruct (or struct Properties with modified MyPropStruct inside) back to operation TestOpWithWrappedProperties.
Is there a way to storeProperties(MyPropStruct &) into TestOpWithWrappedProperties?

getProperties() returns a reference, so you can modify it in-place or just use the assignment operator to replace its content.

I get the reference to properties instance via TestOpWithWrappedProperties::getProperties() and modify it. Then I call TestOpWithWrappedProperties::getProperties() once more and the instance of MyPropStruct that was got in the second attempt is unmodified.
What I do wrong?

I can’t tell without seeing the code. But there is nothing special in MLIR here: it returns a plain C++ reference to the object.

The reference to the object MyPropStruct that is inside the instance of TestOpWithWrappedProperties, right?

In terms of TestOpWithWrappedProperties, it should be something like:

MyPropStruct newProp = ...
op.getProperties().getProp() = newProp;

Hello Mehdi,
Thank you for your advice, in the end I found and fixed the error in my code, so your decision began to work correctly. But, finally, more elegant and simple decision of my task was found with use of SymbolTable infrastructure.