简体   繁体   English

如何避免对两个包含internalsvisibleto的项目中包含的nuget源代码包进行不明确的引用

[英]How to avoid ambiguous references on nuget source code packages includeded in two projects with internalsvisibleto

Let's say you have two projects: 假设您有两个项目:

  • Main.csproj Main.csproj
  • Main.Test.csproj Main.Test.csproj

And Main has an attribute 而且Main有一个属性

[assembly:InternalsVisibleTo("Main.Test")]

Now we want to reference a NuGet package that ships its content as source code such as MoreLinq ( https://code.google.com/p/morelinq/ ) in both projects. 现在,我们要引用一个NuGet软件包,该软件包在两个项目中均将其内容作为源代码(如MoreLinq( https://code.google.com/p/morelinq/ ))提供。

The problem is that there are now two copies of the source visible to the Main.Test project and therefore the compiler spews an Ambiguous reference error. 问题在于Main.Test项目现在有两个可见的源副本,因此编译器会产生一个模糊引用错误。

Is there any way to avoid this without modifying the source code that the package drops into each project? 有什么方法可以避免这种情况,而无需修改软件包放入每个项目的源代码?

PS Please don't use arguments such as 'don't use InternalsVisibleTo because...'. PS:请勿使用诸如“请勿使用InternalsVisibleTo因为...”之类的参数。 I can read those points elsewhere. 我可以在其他地方阅读这些观点。

来自morelinq的扩展方法将是公开的,因此,如果在main.csproj中包含扩展方法,则在main.test.csproj中将不需要它们,但仍可在main.test.csproj中访问它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM