Code analysis CA0001 error for project using NSubstitute

半腔热情 提交于 2019-12-13 03:38:25

问题


I have a (.NET 4) test project which references (the .NET 4) NSubstitute.dll.

When I run CodeAnalysis against the project I get a number of CA0001 errors:

Running Code Analysis...

MSBUILD : error : CA0001 : The following error was encountered while reading module 'NSubstitute': Could not resolve type reference: [mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]System.Runtime.CompilerServices.ExtensionAttribute.

MSBUILD : error : CA0001 : Rule=Microsoft.Interoperability#CA1404, Target=arcplan.test.engage.admin.ecmFramework.CAppSettingsTest.#IsSettingsStoreReadyToUse_SettingsStoreIsNotReady_ReturnsFalse() : The following error was encountered while reading module 'ECMFrameworkTest': Method type parameter in position 0 is not valid.

MSBUILD : error : CA0001 : Rule=Microsoft.Security#CA2122, Target=arcplan.test.engage.admin.ecmFramework.CAppSettingsTest.#IsSettingsStoreReadyToUse_SettingsStoreIsNotReady_ReturnsFalse() : The following error was encountered while reading module 'ECMFrameworkTest': Method type parameter in position 0 is not valid.

(etc.)

Does anyone know how to solve this?


回答1:


Are you using version 1.4.1? The build of this version had a problem caused by using ilmerge with .NET 4.5 installed. This is fixed as of version 1.4.2 of NSubstitute (the latest release as of this comment).

More details are available on the commit to fix this.



来源:https://stackoverflow.com/questions/11360184/code-analysis-ca0001-error-for-project-using-nsubstitute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!