Reputation: 8815
Warning message from 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
Any way to make this Shim working or is this an internal issue that Microsoft has to fix ?
Steps to reproduce:
Expand Frameworks -> Microsoft.NETCore.App -> Right Click on System.Runtime -> Generate Fake Assembly
System.DateTime is contained in System.Runtime.dll for .NETCore 3.1 https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset?view=netcore-3.1
Edit Fakes\System.Runtime.fakes file with
content:
<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: Adding shim for System.Text.Json works fine.
PS-2: Shimming DateTimeOffset works fine by adding Fake assembly of System.Runtime and using default System.Runtime.fakes
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Diagnostic="true">
<Assembly Name="System.Runtime" Version="4.2.2.0"/>
</Fakes>
Upvotes: 3
Views: 1372