Is it possible to update public IReadOnlyList?
There is
public IReadOnlyList<ISelectionNode> Selections { get; }
from public api
I know it is not a good idea but I want to extend it. Is it possible?4 Replies
With reflections, maybe
Get the list normally, turn it into a regular list, append to it
Then turn it into a readonly list again
and use reflections to change the value of this property to that new list
hm
I tried this:
but got an exception "Property set method not found."
in the last line
Stack Overflow
Changing read only properties with reflection
Is it possible? With reflection or any other way?
You need to save the data in the backing field directly
selectionProperty.GetBackingField().SetValue(selectionSet, newSelections)