Reputation:
When setting an OOB default Visual Studio 2013 Update 5 Project, with no tests setup, using the Target Framework of 4.6.1, adding a Fakes assembly to System and setting the following ShimGenerations:
mscorlib.fakes:
<ShimGeneration>
<Clear/>
<Add FullName="System.Collections.ReadOnlyCollectionBase"/>
<Add FullName="System.ApplicationException"/>
<Add FullName="System.IO.Path"/>
<Add FullName="System.Security.SecureString"/>
<Add FullName="Microsoft.Win32.Registry"/>
<Add FullName="Microsoft.Win32.RegistryKey"/>
<Add FullName="System.Activator"/>
<Add FullName="System.Convert"/>
<Add FullName="System.Version"/>
<Add FullName="System.StringComparer"/>
<Add FullName="System.Threading.Thread"/>
</ShimGeneration>
System.fakes:
<ShimGeneration>
<Clear/>
<Add FullName="System.Text.RegularExpressions.Regex"/>
<Add FullName="System.Diagnostics.FileVersionInfo"/>
<Add FullName="System.Diagnostics.Process"/>
<Add FullName="System.Net.CookieContainer"/>
<Add FullName="System.Net.FtpWebRequest"/>
<Add FullName="System.Net.FtpWebResponse"/>
<Add FullName="System.Net.IPAddress"/>
<Add FullName="System.Net.Dns"/>
<Add FullName="System.Net.Mail.SmtpClient"/>
<Add FullName="System.Net.Mail.MailMessage"/>
<Add FullName="System.Net.NetworkInformation.Ping"/>
<Add FullName="System.Net.NetworkInformation.PingReply"/>
<Add FullName="System.Net.NetworkInformation.PingException"/>
<Add FullName="System.Net.HttpWebRequest"/>
<Add FullName="System.Net.HttpWebResponse"/>
<Add FullName="System.Net.WebHeaderCollection"/>
<Add FullName="System.Net.ServicePoint"/>
<Add FullName="System.Net.NetworkInformation.NetworkInterface"/>
<Add FullName="System.Net.Sockets.TcpClient"/>
<Add FullName="System.Net.Sockets.UdpClient"/>
<Add FullName="System.Net.Sockets.Socket"/>
<Add FullName="System.Net.WebRequestMethods"/>
<Add FullName="System.Net.WebRequest"/>
<Add FullName="System.Uri"/>
</ShimGeneration>
The following error occurs:
'System.Net.Sockets.SocketClientAccessPolicyProtocol' is obsolete: 'This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.'
[some path\TestFakes\UnitTestProject1\obj\Debug\Fakes\s\f.csproj] some path\TestFakes\UnitTestProject1\f.csGENERATEFAKES : error : project compilation failed with exit code 1
This appears to only to occur with this configuration.
I am not sure how to work around this since I need to intercept most of the .NET framework calls.
Upvotes: 2
Views: 2004
Reputation:
After spending a couple of days on this problem, I found the following. This is a problem with the following class "System.Net.Sockets.Socket". I found that removing this shim generation, then removing all of the .fakes assemblies, then removing one of the .fakes files in the/Fakes folder and recreating it with the "Add Fakes Assembly" dialogue, recreates all of the .fakes assemblies based on the .fakes files in the /Fakes folder and allows the code to build.
Since I did not need to fake "System.Net.Sockets.Socket", this was an acceptable solution to successfully building and rerunning my unit tests. This definitely appears to be a problem specifically with this class and the Fakes framework.
I find that the Fakes framework is a good one but needs better support. Things like this are too difficult to troubleshoot and need improvement. To me the above is not an acceptable solution to the overall. I find that if MS would provide better feedback and more verbosity on such a problem as above, a solution to it would be simpler. One should not have to spend days looking at logs, researching on the web and testing when a simple message such as "This class is unsupported for Shim Generation" would suffice.
Upvotes: 2