Windows 8.1もしくは .NET Framework 4.5がインストールされた環境でMolesを使用しようとすると
「前回記載したエラー」が発生します。今回はその対策です。
Pex and Molesは最初に自動的にmscorlibを解析してMoles(mscorlib.moles)を生成します。
しかし、Pex and Molesは、.NET Framework 4.0用に作成されているため、.NET Framework 4.5で新しく追加された
Methodに対してスタブ(stubs)やモック(moles)を作ることができません。
このため、mscorlibの解析対象から.NET Framework 4.5で新しく追加された型または名前空間名を除く必要があります。
具体的にはソリューションエクスプローらから、mscorlib.molesを開いて、Xmlを修正します。
<Moles xmlns="http://schemas.microsoft.com/moles/2010/">
<Assembly Name="mscorlib" />
<StubGeneration>
<Types>
<Remove Namespace="System.Security.Claims"/>
<Remove Namespace="System.Security.Principal"/>
<Remove Namespace="System.Security.Cryptography"/>
<Remove Namespace="System.IO"/>
<Remove Namespace="System.Threading"/>
<Remove Namespace="System.Threading.Tasks"/>
<Remove Namespace="System.Diagnostics.Contracts"/>
<Remove Namespace="System.Diagnostics.Tracing"/>
<Remove Namespace="System.Reflection" />
<Remove Namespace="System.Runtime!"/>
<Remove Namespace="System.Runtime.InteropServices"/>
<Remove Namespace="System.Runtime.DesignerServices"/>
<Remove Namespace="System.Runtime.CompilerServices"/>
<Remove Namespace="System.Runtime.ExceptionServices"/>
<Remove Namespace="System.Globalization"/>
<Remove Namespace="System.Collections.ObjectModel" TypeName="ReadOnly"/>
<Remove Namespace="System.Collections.ObjectModel" TypeName="Collection"/>
<Remove Namespace="System.Collections.Generic" />
<Remove Namespace="System.Collections.Concurrent" />
<Remove Namespace="System" TypeName="WeakReference"/>
<Remove Namespace="System" TypeName="Progress"/>
<Remove Namespace="System" TypeName="AggregateException"/>
<Remove Namespace="System.Runtime.Versioning" TypeName="CompatibilitySwitch"/>
</Types>
</StubGeneration>
<MoleGeneration>
<Types>
<Remove Namespace="System.Security.Claims"/>
<Remove Namespace="System.Security.Principal"/>
<Remove Namespace="System.Security.Cryptography"/>
<Remove Namespace="System.Threading"/>
<Remove Namespace="System.Threading.Tasks"/>
<Remove Namespace="System.Diagnostics.Contracts"/>
<Remove Namespace="System.Diagnostics.Tracing"/>
<Remove Namespace="System.Reflection" />
<Remove Namespace="System.Runtime!"/>
<Remove Namespace="System.Runtime.InteropServices"/>
<Remove Namespace="System.Runtime.DesignerServices"/>
<Remove Namespace="System.Runtime.CompilerServices"/>
<Remove Namespace="System.Runtime.ExceptionServices"/>
<Remove Namespace="System.Globalization"/>
<Remove Namespace="System.Collections.ObjectModel" TypeName="ReadOnly"/>
<Remove Namespace="System.Collections.ObjectModel" TypeName="Collection"/>
<Remove Namespace="System.Collections.Generic" />
<Remove Namespace="System.Collections.Concurrent" />
<Remove Namespace="System" TypeName="WeakReference"/>
<Remove Namespace="System" TypeName="Progress"/>
<Remove Namespace="System" TypeName="AggregateException"/>
<Remove Namespace="System.Runtime.Versioning" TypeName="CompatibilitySwitch"/>
</Types>
</MoleGeneration>
</Moles>
参考
Many errors when “Add Moles Assembly for mscorlib”
http://stackoverflow.com/questions/13340792/many-errors-when-add-moles-assembly-for-mscorlib
Troubleshooting in Visual Studio 2012 / .NET 4.5
http://research.microsoft.com/en-us/projects/moles/molesdev11.aspx
0 件のコメント:
コメントを投稿