pose
pose copied to clipboard
Extension Method Replacement
How do you use pose to replace extension methods?
I've tried replacing with Extension.MyExtension<T>(this myClass, T value) and also myClass.MyExtension(T value) and both fail to use the replacement code and use the original.
Is this possible? I realise I am probably doing something wrong or is it because it's a generic?
Pose cannot currently shim extension methods
Is this feature being considered? This was my main use case for pulling in this library - disappointed to see its not currently supported. I haven't been able to find a .NET Standard friendly way of shimming an extension method at this point.
Hi @k-schneider, currently revisiting the feature list for Pose and will add this to the backlog
Count me as another vote for shimming of extension methods. I need this ability so I can test ASP.NET code that uses Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions such as the GetRequiredService<T>() method. Really frustrating that Microsoft chose to implement the functionality in such an untestable way!
@Dreamwalker666 on second thought I think this might be supported just not very obvious. Can you paste a snippet of your code?
Well I feel embarrased I didn't have the original code I was using. So I whipped up a quick test project that was similar in layout to what I was previously testing and it works :S
So I think something else may have been causing a problem or I missed something before.
I have attached the project I made is this how you were excpecting it to work?
@Dreamwalker666 I can confirm that v2.0 does support shimming extension method. Please refer to Miista/Pose#27
cc: @k-schneider @SamerAdra @tonerdo @azaytsev-csr @efotin