无法填充DateTime。现在在C#dotnet core 3.1中
Visual Studio Enterprise 2019发出的警告消息:无法填充DateTime。现在在C#dotnet core 3.1中,c#,.net-core,microsoft-fakes,shim,C#,.net Core,Microsoft Fakes,Shim,Visual Studio Enterprise 2019发出的警告消息: Warning Cannot generate shim for System.DateTime: type is not supported because of internal limitations. ...\NUnitTestProject1\Fakes\System.Runtime.fakes 1 有没有办法让这个垫片正常工作,或者这是微软必须解决的内部问题 复制步骤: 展开Framew
Warning Cannot generate shim for System.DateTime: type is not supported because of internal limitations.
...\NUnitTestProject1\Fakes\System.Runtime.fakes 1
有没有办法让这个垫片正常工作,或者这是微软必须解决的内部问题
复制步骤:
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Diagnostic="true">
<Assembly Name="System.Runtime" Version="4.2.2.0"/>
<StubGeneration>
<Clear />
</StubGeneration>
<ShimGeneration>
<Clear />
<Add FullName="System.DateTime!" />
</ShimGeneration>
</Fakes>
PS:为System.Text.Json添加垫片效果很好
PS-2:通过添加System.Runtime的假程序集并使用默认的System.Runtime.fakes,填充DateTimeOffset可以很好地工作
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Diagnostic="true">
<Assembly Name="System.Runtime" Version="4.2.2.0"/>
</Fakes>
看起来这个问题已经解决,并且生成了ShimDateTime,但是当我尝试运行测试时,我得到了ShimNotSupportedException。