Code analysis CA0001 error for project using NSubs

2019-08-24 23:16发布

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条回答
Fickle 薄情
2楼-- · 2019-08-24 23:54

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.

查看更多
登录 后发表回答