NSubstitute icon indicating copy to clipboard operation
NSubstitute copied to clipboard

Increase docs on how to partially sub classes with internal virtual members

Open djeikyb opened this issue 5 years ago • 1 comments

I think it would be helpful if the partial subs page mentioned the need to add:

<ItemGroup>
    <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
        <_Parameter1>YOUR TEST ASSEMBLY</_Parameter1>
    </AssemblyAttribute>
    <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
        <_Parameter1>DynamicProxyGenAssembly2</_Parameter1>
    </AssemblyAttribute>
</ItemGroup>

Usually when I'm reaching for a partial sub, I need to invoke a public method that calls a subbed internal virtual. It took me a long time to discover this assembly configuration. While writing this feature request, I actually found an nsub page that talks about this! Unfortunately, I never saw it while I was troubleshooting. I actually gave up on nsub for that specific test and imported moq. I mean why not both, right? 😄 Seeing moq crash gave me the insights needed to get nsub going again. I'm excited to see progress on making nsub crash too!

djeikyb avatar Sep 30 '19 19:09 djeikyb

Thanks for the feedback @djeikyb! Will try to get this in for the next round of documentation updates 👍

dtchepak avatar Oct 04 '19 03:10 dtchepak