.net-4.5 - 如何填充 System.Environment?
问题描述
我正在尝试填充 System.Environment:
Dim args = {"a", "b", "c", "d", "e")}
System.Fakes.ShimEnvironment.GetCommandLineArgsGet =
Function() As String()
Return args
End Function
我参考了 C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\PublicAssemblies\Microsoft.QualityTools.Testing.Fakes.dll
我的项目的 Fakes 文件夹中有以下文件:
mscorlib.fakes:
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
<Assembly Name="mscorlib" Version="4.0.0.0"/>
</Fakes>
系统假货:
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
<Assembly Name="System" Version="4.0.0.0"/>
</Fakes>
但是我得到编译错误:
错误 BC30456:“ShimEnvironment”不是“System.Fakes”的成员。
如何填充 System.Environment?
解决方案
正如https://social.msdn.microsoft.com/Forums/vstudio/en-US/b49e9f5d-0e57-46b1-8ced-f3231db5e813/cannot-find-a-shim-for-systemenvironmentmachinename-etc?forum=vsunittest中的建议我必须将以下内容放入 mscorlib.fakes:
<ShimGeneration>
<Add FullName="System.Environment"/>
</ShimGeneration>
推荐阅读
- javascript - React 中的自定义 Service Worker
- openapi - 将字段设置为模式类型,即 OpenAPI 中定义的模式
- xcode - 包含来自其他目录的 cpp 代码文件时是否是 Xcode 错误?
- php - PHP Soap 客户端处理多部分/相关
- c# - 找不到实体框架插入字段时出错
- java - BCFIPS - org.bouncycastle.crypto.fips.FipsOperationError:模块校验和失败:预期这得到了
- javascript - 使用 CSS-in-JS 时,我应该为 CSS 类使用哪种大小写?
- python - 如何将参数传递给 scipy.optimize 中的非线性约束?
- javascript - 从 Firestore 获取值并使用异步将输出存储为全局
- c# - Linq to SQL/Entities:最大的 N-Per 组问题/性能提升