Code Monkey home page Code Monkey logo

prig's Introduction

Prig: Open Source Alternative to Microsoft Fakes

Prig

Prig(PRototyping jIG) is a framework that generates a Test Double like Microsoft Fakes/Typemock Isolator/Telerik JustMock based on Unmanaged Profiler APIs. This framework enables that any methods are replaced with mocks. For example, a static property, a private method, a non-virtual member and so on.

STATUS

As of Mar 12, 2017, Released V2.3.2.
Coverity Scan Build Status Donate via Amazon Wish List

QUICK TOUR

Let's say you want to test the following code:

using System;

namespace QuickTour
{
    public class LifeInfo
    {
        public static bool IsNowLunchBreak()
        {
            var now = DateTime.Now;
            return 12 <= now.Hour && now.Hour < 13;
        }
    }
}

You probably can't test this code, because DateTime.Now returns the value that depends on an external environment. To make be testable, you should replace DateTime.Now to the Test Double that returns the fake information. If you use Prig, it will enable you to generate a Test Double by the following steps without any editing the product code:

Step 1: Install From Visual Studio Gallery

Run Visual Studio 2013(Community or more, 2015 is also supported) as Administrator and choose TOOLS - Extensions and Updates....
Extensions and Updates... menu

Now in the Extensions and Updates window, take the following steps:

  1. On the left side, ensure Visual Studio Gallery is selected under Online.
  2. In the search box in the upper right corner, type prig.
  3. Select the Prig package, and click Download.

Extensions and Updates dialog

NOTE: Prig requires PowerShell v3.0+. If you want to use Prig in Windows 7, please install Windows Management Framework 3.0+ beforehand. See also this issue.

Once restart Visual Studio, you can find PRIG in the menu. Choose PRIG - Register Prig (Needs Restarting).
Register Prig menu

Finally restart Visual Studio then you are now ready.

Step 2: Add Stub Settings

Add test project(e.g. QuickTourTest). Then, right click References and choose Add Prig Assembly for mscorlib:
Add Stub Settings

Step 3: Modify Stub Settings

You can find the Stub Settings File <assembly name>.<runtime version>.v<assembly version>.prig in the project(in this case, it is mscorlib.v4.0.30319.v4.0.0.0.prig). So, right click the file and choose Edit Prig Indirection Settings:
Edit Prig Indirection Settings

Then, Prig Setup Session will start:
Prig Setup Session

Welcome to Prig Setup Session!!


You can add the Stub Settings File from here. In this session, you can use `$ReferencedAssemblies` that contains all
referenced assemblies information of current project. For example, if you want to get the indirection settings for all
members of the type `Foo` that belongs to the referenced assembly `UntestableLibrary`, the following commands will achi
eve it:

PS> $ReferencedAssemblies

FullName
--------
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
MyLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
UntestableLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null


PS> padd -ra $ReferencedAssemblies[-1]
PS> $ReferencedAssemblies[-1].GetTypes() | ? { $_.Name -eq 'Foo' } | pfind | pget | clip
PS> exit   # Then, paste the content on the clipboard to the Stub Settings File(e.g. `UntestableLibrary.v4.0.30319.v1.0.
0.0.prig`).



See also the command's help `padd`, `pfind` and `pget`.



Current Project: QuickTourTest
WARNING: Change the Current Project from `Default Project: ` on the Package Manager Console if it isn't what you want.


-EditorialInclude parameter is specified. You can also use the global variable $TargetReferencedAssembly in addition to
 $ReferencedAssemblies. Currently $TargetReferencedAssembly is:

FullName
--------
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089




PS 01.QuickTour>

Now, we want to get the indirection setting for DateTime.Now. In this case, execute the following commands and copy it to the clipboard:

PS 01.QuickTour> $TargetReferencedAssembly.GetTypes() | ? { $_.Name -eq 'datetime' } | pfind -m 'get_Now' | pget | clip
PS 01.QuickTour> exit

Exit the Prig Setup Session, and paste the copied information to the Stub Settings File:
Indirection Setting File

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  
  <configSections>
    <section name="prig" type="Urasandesu.Prig.Framework.PilotStubberConfiguration.PrigSection, Urasandesu.Prig.Framework" />
  </configSections>

  <prig>

    <stubs>
      <!-- PASTE HERE -->
      <!-- 
          PDateTime.NowGet().Body = 
              () => 
              {   
                  throw new NotImplementedException();
              };
      -->
      <add name="NowGet" alias="NowGet">
        <RuntimeMethodInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection">
          <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">get_Now</Name>
          <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyName>
          <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">System.DateTime</ClassName>
          <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">System.DateTime get_Now()</Signature>
          <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">System.DateTime get_Now()</Signature2>
          <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">8</MemberType>
          <GenericArguments i:nil="true" xmlns="" />
        </RuntimeMethodInfo>
      </add>
      <!-- PASTE HERE -->
    </stubs>
    
  </prig>

</configuration>

NOTE: You can also get the same result using Prig ILSpy plug-in.

Were you able to build successfully? OK, now you're ready to test them.

Step 4: Make Tests

In the test code, it becomes testable through the use of the stub and the replacement to Test Double that returns the fake information:

using NUnit.Framework;
using QuickTour;
using System;
using System.Prig;
using Urasandesu.Prig.Framework;

namespace QuickTourTest
{
    [TestFixture]
    public class LifeInfoTest
    {
        [Test]
        public void IsNowLunchBreak_should_return_false_when_11_oclock()
        {
            // `IndirectionsContext` can minimize the influence of the API replacement.
            using (new IndirectionsContext())
            {
                // Arrange
                // `PDateTime` is the class that is generated automatically by Prig.
                // We call such class "Prig Type". You can replace the method body of 
                // `DateTime.Now` by using that.
                PDateTime.NowGet().Body = () => new DateTime(2013, 12, 13, 11, 00, 00);
                // Hereafter, `DateTime.Now` will return only `2013/12/13 11:00:00`.

                // Act
                var result = LifeInfo.IsNowLunchBreak();

                // Assert
                Assert.IsFalse(result);
            }
        }

        // In the same way, add the test case to cover other branches...
        [Test]
        public void IsNowLunchBreak_should_return_true_when_12_oclock()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                PDateTime.NowGet().Body = () => new DateTime(2013, 12, 13, 12, 00, 00);

                // Act
                var result = LifeInfo.IsNowLunchBreak();

                // Assert
                Assert.IsTrue(result);
            }
        }

        [Test]
        public void IsNowLunchBreak_should_return_false_when_13_oclock()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                PDateTime.NowGet().Body = () => new DateTime(2013, 12, 13, 13, 00, 00);

                // Act
                var result = LifeInfo.IsNowLunchBreak();

                // Assert
                Assert.IsFalse(result);
            }
        }
    }
}

Step 5: Install Test Adapter

Before running tests in Visual Studio Test Explorer, you have to install a Test Adapter. Currently, Prig supports the following Test Adapters: NUnit, MSTest, xUnit.net. As the above described sample, let we use NUnit. Now, in the Package Manager Console, change the Package source to Prig Source, the Default project to QuickTourTest and execute the following command:

PM> Install-Package NUnitTestAdapterForPrig

NOTE: Unfortunately, you can't use official NUnit Test Adapter because it doesn't support any configurations like prime NUnit which is supported, e.g. NUnit Gui Runner's Settings and NUnit-Console's Settings.

After install, build the test project and choose the menu TEST - Windows - Test Explorer. Then, you can find runnable tests in the Test Explorer.
Install Test Adapter 01

When Test Adapter was installed successfully, you can also modify the Test Settings. As the following image, change Default Processor Architecture to x64 and uncheck Keep Test Execution Engine Running:
Install Test Adapter 02

Step 6: Run Tests

In fact, to enable any profiler based mocking tool, you have to set the environment variables. Therefore, such libraries - Microsoft Fakes/Typemock Isolator/Telerik JustMock provide small runner to satisfy the requisition, also it is true at Prig. Choose the menu PRIG - Enable Test Adapter for ConsoleApplicationTest:
Run Tests 01

Then, execute TEST - Run - All Tests, you can get test results in the Test Explorer.
Run Tests 02

Final Step: Refactoring and Get Trig Back!

If tests have been created, you can refactor illimitably! For example, you probably can find the result of refactoring as follows:

using System;

namespace QuickTour
{
    public class LifeInfo
    {
        public static bool IsNowLunchBreak()
        {
            // 1. Add overload to isolate from external environment then call it from original method.
            return IsNowLunchBreak(DateTime.Now);
        }

        public static bool IsNowLunchBreak(DateTime now)
        {
            // 2. Also, I think the expression '12 <= now.Hour && now.Hour < 13' is too complex.
            //    Better this way, isn't it?
            return now.Hour == 12;
        }
        // 3. After refactoring, no longer need to use Prig, because you can test this overload.
    }
}

As just described, Prig helps the code that depends on an untestable library gets trig back. I guarantee you will enjoy your development again!!

For more information, see also Prig's wiki.

INSTALLATION FROM SOURCE CODE

PREREQUISITES

To build this project needs the following dependencies:

CMD boost_1_60_0>cd
C:\boost_1_60_0

CMD boost_1_60_0>bootstrap.bat
Building Boost.Build engine

Bootstrapping is done. To build, run:

    .\b2

To adjust configuration, edit 'project-config.jam'.
Further information:
...

CMD boost_1_60_0>.\b2 link=static threading=multi variant=debug,release runtime-link=shared,static -j 4

Building the Boost C++ Libraries.

Performing configuration checks
...

CMD boost_1_60_0>.\b2 link=static threading=multi variant=debug,release runtime-link=shared,static -j 4 --stagedir=.\stage\x64 address-model=64

Building the Boost C++ Libraries.

Performing configuration checks
...
  • Google Test 1.6
    Extract to C:\gtest-1.6.0, and upgrade C:\gtest-1.6.0\msvc\gtest.sln to Visual Studio 2013. Choose the Build menu, and open Configuration Manager.... On Configuration Manager dialog box, in the Active Solution Platform drop-down list, choose the <New...> option. After the New Solution Platform dialog box is opened, in the Type or select the new platform drop-down list, select a 64-bit platform. Then build all(Debug/Release) configurations.
  • NUnit 2.6.4.14350
    Install using with the installer(NUnit-2.6.4.msi). As more easy way, you can install it by using Chocolatey: cinst nunit -version 2.6.4 -y.
  • Microsoft Visual Studio 2013 SDK
    Install using with the installer(vssdk_full.exe).
  • Modeling SDK for Microsoft Visual Studio 2013
    Install using with the installer(VS_VmSdk.exe).
  • NAnt
    You can also install in accordance with the help, but the easiest way is using Chocolatey: cinst nant -y.
  • Microsoft .NET Framework 3.5 Service Pack 1
    Install using with the installer(dotnetfx35setup.exe).
  • Jekyll(Optional)
    This is used to only edit and test locally Prig's GitHub Pages. The installation steps are too complex. I think that you had better use Chocolatey(just executing a few commands).

BUILD

From PowerShell Script

Run Developer Command Prompt for VS2013 as Administrator, and execute the following commands:

CMD Prig> cd
C:\Users\User\Prig

CMD Prig> powershell
Windows PowerShell
Copyright (C) 2014 Microsoft Corporation. All rights reserved.


PS Prig> .\Build.ps1
...

PS Prig>

NOTE: It takes somewhere round 30 minutes.

NOTE: Probably, the reference assembly path of NuGet.VisualStudio will be changed to another path like this commit. It seems that it will be created randomly when installing Visual Studio, so temporarily change it correct path for your development.

From Visual Studio

After preparing all dependencies, you can build this project in the following steps:

  1. Run Visual Studio as Administrator, and open Prig.sln(This sln contains some ATL projects, so the build process will modify registry).
  2. According to the version of the product to use, change the solution configuration and the solution platform and build.
  3. The results are output to $(SolutionDir)$(Configuration)\$(PlatformTarget)\.

REGISTRATION

If you built Prig by PowerShell script, Prig.vsix will be output to <top level directory you cloned>\Release\x86 directory. You can install by double clicking that. After that, do installation procedure same as the beginning; choose the menu PRIG - Register Prig (Needs Restarting).

UNREGISTRATION

At first, choose the menu PRIG - Unregister Prig (Needs Restarting). After you once restart Visual Studio, uninstall the VSIX; choose TOOLS - Extensions and Updates..., search Installed for prig and click Uninstall.

prig's People

Contributors

davidruhmann avatar urasandesu avatar wegged avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prig's Issues

Using this without indirection context

Is it possible to use this framework without having an IndirectionCotext?
I know it's there to protect you from permanently detouring functions and do other dangerous things, but that's exactly what I want to to.
Can I achieve this with prig? Maybe even without using a test but a normal c# application.
If it's not possible do you have any idea where I could start searching for a way to do this?

Sorry if this is the wrong place to ask btw

Support mocking DLL imports

In this commit, I have almost done the work to support three or more out/ref parameters. However, when I started writing the sample for it, I understood that the sample is very difficult to explain thereafter. Because I think it is strongly linked to the business domain like the API that is described in Issue #31. Also, I know such API in my business, but it isn't open to the public.

In generally, I believe the almost cases that developers are inconvenienced against three or more out/ref parameter are when they made the thin wrapper for P/Invoke. However, if I explain the sample to replace such thin wrapper, people probably will have the question as below in next to no time: "Why don't you replace the P/Invoke method directly?" 😈

For your information, JustMock has this feature.

Minimize the dependency to Chocolatey

As this notice indicates, Chocolatey has a very large backlog of packages in moderation queue. So, probably we can't release like how we think it will --- Also, currently I have not heard anything the moderation status of the package that I submitted 12 days ago... 😧

Therefore, we should minimize the dependency to Chocolatey and take back the control for our releases. We are planning the following enhancements to achieve that:

  • The process resolving the dependency to NuGet.CommandLine
    => Bundle NuGet.exe up.
  • The process generating NuGet package
    => Generate it at the build time.
  • The process registering the profiler
    => Register it at startup time of VSIX. Of course, considering whether version is newer.
  • The process executing prig install TestWindow ...
    => Execute it at the timing same as profiler registration.

By implementing the above, VSIX will be available as an independent installer(This means we can publish it in Visual Studio Gallery). Almost operations that Chocolatey did to install will be unnecessary.

Shall the name attribute be unique in the Stub Setting?

In the Stub Setting, the name attribute is explained as the follows:

This attribute is identifier. It's preferable that method's overloads can be recognized. If the method has just one signature, this can make be same as 'alias'.

So, it shall be unique in the method's overloads, but it doesn't have to be unique in the Stub Setting.
Now, I modified the Stub Setting as the follows, and I got unintended results:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  ...(snip)...
  <prig>
    <stubs>
      <add name="Constructor" alias="Constructor">
        <RuntimeConstructorInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection">
          <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">.ctor</Name>
          <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">ClassLibrary1</AssemblyName>
          <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">A`1</ClassName>
          <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">Void .ctor()</Signature>
          <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">.ctor()</Signature2>
          <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">1</MemberType>
          <GenericArguments i:nil="true" xmlns="" />
        </RuntimeConstructorInfo>
      </add>
      <add name="Constructor" alias="Constructor">
        <RuntimeConstructorInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection">
          <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">.ctor</Name>
          <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">ClassLibrary1</AssemblyName>
          <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">B`1</ClassName>
          <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">Void .ctor()</Signature>
          <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">.ctor()</Signature2>
          <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">1</MemberType>
          <GenericArguments i:nil="true" xmlns="" />
        </RuntimeConstructorInfo>
      </add>
    </stubs>
  </prig>
</configuration>

This Stub Setting can only generate one stub. The expected is that two stubs are generated, because each method has just one overload.

BadImageFormatException occurred

I got BadImageFormatException in the following steps:

  1. Select the menu [FILE] - [New] - [Project], and create New Project for Console Application.
    [NOTE: .NET Framework 4.5 or later]
  2. In the Package Manager Console, run Install-Package Prig -pre.
  3. After installing successfully, run padd -as mscorlib.
  4. Modify the stub setting and use the stub in the Console Application, then F5.
  5. The program crashes because BadImageFormatException occurred.

About this issue's cause, I think that Add-PrigAssembly doesn't consider the configuration Any CPU + Prefer32Bit.

No longer need install.ps1 for NuGet.

We no longer need install.ps1 for NuGet by the following reason:

  • NuGet package became the end of the dependency chain.
    When developing, we can use newer assemblies immediately by cleaning the project and entrusting automatic restoration to NuGet.
  • VSIX became always checking installed package version.
    When installing, user can use newer assemblies naturally by executing some operations as usual.

Currently, this script isn't harmful, but it is unnecessary process.

The indirect tests sometimes fail.

In v1.0.0, the tests that use the indirection stub sometimes fail. For example, it outputs the following log:

C:\Users\Akira\Prig\Test.program1\bin\Debug(.NET 3.5)\x64>"..\..\..\..\Release\x64\prig.exe" run -process "C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console.exe" -arguments "Test.program1.dll /domain=None /run:Test.program1.MyLibrary.LifeInfoTest"
NUnit-Console version 2.6.3.13283
Copyright (C) 2002-2012 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment -
   OS Version: Microsoft Windows NT 6.2.9200.0
  CLR Version: 2.0.50727.8009 ( Net 3.5 )

ProcessModel: Default    DomainUsage: None
Execution Runtime: net-3.5
Selected test(s): Test.program1.MyLibrary.LifeInfoTest
....................F..........
Tests run: 30, Errors: 1, Failures: 0, Inconclusive: 0, Time: 2.03592993619678 seconds
  Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

Errors and Failures:
1) Test Error : Test.program1.MyLibrary.LifeInfoTest.IsTodayHoliday_should_consider_a_set_day_and_the_previous_day_as_holiday(11/21/2013 00:00:00,Thursday)
   System.InvalidOperationException : T(Urasandesu.Prig.Framework.IndirectionHolder`1[Urasandesu.Prig.Framework.IndirectionAction`2[System.Collections.Generic.List`1[System.Reflection.RuntimeFieldInfo],System.Reflection.RuntimeFieldInfo]]) has not been registered yet. Please call Register method.
   場所 Urasandesu.Prig.Framework.LooseCrossDomainAccessor`1.get_Holder()
   場所 Urasandesu.Prig.Framework.LooseCrossDomainAccessor.GetOrRegister[T]()
   場所 Urasandesu.Prig.Framework.LooseCrossDomainAccessor.TryGet[T](T& holder)
   場所 System.Collections.Generic.List`1.Add(T item)
   場所 System.RuntimeType.RuntimeTypeCache.MemberInfoCache`1.PopulateRtFields(Filter filter, Int32** ppFieldHandles, Int32 count, RuntimeTypeHandle declaringTypeHandle, List`1 list)
   場所 System.RuntimeType.RuntimeTypeCache.MemberInfoCache`1.PopulateRtFields(Filter filter, RuntimeTypeHandle declaringTypeHandle, List`1 list)
   場所 System.RuntimeType.RuntimeTypeCache.MemberInfoCache`1.PopulateFields(Filter filter)
   場所 System.RuntimeType.RuntimeTypeCache.MemberInfoCache`1.Populate(String name, MemberListType listType, CacheType cacheType)
   場所 System.RuntimeType.RuntimeTypeCache.MemberInfoCache`1.GetMemberList(MemberListType listType, String name, CacheType cacheType)
   場所 System.RuntimeType.RuntimeTypeCache.GetMemberList[T](MemberInfoCache`1& m_cache, MemberListType listType, String name, CacheType cacheType)
   場所 System.RuntimeType.RuntimeTypeCache.GetFieldList(MemberListType listType, String name)
   場所 System.RuntimeType.GetFieldCandidates(String name, BindingFlags bindingAttr, Boolean allowPrefixLookup)
   場所 System.RuntimeType.GetFields(BindingFlags bindingAttr)
   場所 System.Enum.GetValueField(Type type)
   場所 System.Enum.ToString()
   場所 System.String.Concat(Object arg0, Object arg1)
   場所 NUnit.Core.TestMethod.RunTest()
   場所 NUnit.Core.NUnitTestMethod.RunTest()
   場所 NUnit.Core.TestMethod.RunRepeatedTest()
   場所 NUnit.Core.TestMethod.RunTestInContext()



C:\Users\Akira\Prig\Test.program1\bin\Debug(.NET 3.5)\x64>

Also, it sometimes outpus the following log in another case:


C:\Users\Akira\Prig\Test.program1\bin\Debug(.NET 3.5)\x64>"..\..\..\..\Release\x64\prig.exe" run -process "C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console.exe" -arguments "Test.program1.dll /domain=None /run:Test.program1.MyLibrary.LifeInfoTest"
NUnit-Console version 2.6.3.13283
Copyright (C) 2002-2012 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment -
   OS Version: Microsoft Windows NT 6.2.9200.0
  CLR Version: 2.0.50727.8009 ( Net 3.5 )

ProcessModel: Default    DomainUsage: None
Execution Runtime: net-3.5
Selected test(s): Test.program1.MyLibrary.LifeInfoTest
.....................F.........
Tests run: 30, Errors: 1, Failures: 0, Inconclusive: 0, Time: 2.02487413261262 seconds
  Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

Errors and Failures:
1) Test Error : Test.program1.MyLibrary.LifeInfoTest.IsTodayHoliday_should_consider_a_set_day_and_the_previous_day_as_holiday(11/22/2013 00:00:00,Thursday)
   System.InvalidOperationException : T(Urasandesu.Prig.Framework.IndirectionHolder`1[Urasandesu.Prig.Framework.IndirectionFunc`3[System.String,System.DayOfWeek,System.DayOfWeek]]) has not been registered yet. Please call Register method.
   場所 Urasandesu.Prig.Framework.LooseCrossDomainAccessor`1.get_Holder()
   場所 Urasandesu.Prig.Framework.LooseCrossDomainAccessor.GetOrRegister[T]()
   場所 UntestableLibrary.Prig.PULConfigurationManager.zzGetPropertyOfTStringT`1.set_Body(IndirectionFunc`3 value) 場所 c:\Users\Akira\Prig\Test.program1\UntestableLibrary.v2.0.50727.v1.0.0.0.MSIL.Prig\UntestableLibrary\PULConfigurationManager.g.cs:行 35
   場所 Test.program1.MyLibrary.LifeInfoTest.IsTodayHoliday_should_consider_a_set_day_and_the_previous_day_as_holiday(DateTime today, DayOfWeek holiday) 場所 c:\Users\Akira\Prig\Test.program1\MyLibrary\LifeInfoTest.cs:行 102



C:\Users\Akira\Prig\Test.program1\bin\Debug(.NET 3.5)\x64>

If I enhanced the log level or executed the test in CLR v4.0.30319, this issue never be occurred :'( Probably, this is the problem of thread safety.

Path to `tools` become unreachable from the Package Manager Console after building a project.

By default, NuGet sets path to tools automatically, but it became unreachable in the following step:

Step 1

Install-Package Prig -pre against arbitrary project.

Step 2

Reboot the Visual Studio, then confirm $env:Path in the Package Manager Console. In this timing, the result is as the follows:

PS >  $env:Path -replace ";", "`r`n"
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\Git\cmd
C:\Program Files\TortoiseGit\bin
C:\Users\User\AppData\Local\Apps\NuGet
C:\Users\User\Documents\Visual Studio 2013\Projects\ConsoleApplication1\packages\Prig.0.0.0-alpha3\tools
PS >  

Step 3

Rebuild the project that was installed Prig in step 1.

Step 4

Confirm $env:Path again...

PS >  $env:Path -replace ";", "`r`n"
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\Git\cmd
C:\Program Files\TortoiseGit\bin
C:\Users\User\AppData\Local\Apps\NuGet
PS >  

The path to tools is removed for no special reason :(
This issue's real problem is that user can't invoke typing just prig in some situation. Prig should be able to invoke typing just prig any time in the Package Manager Console.

Error adding Stub Settings

I'm running Windows 7 64 bit, as local admin.

I attempted the Quick Tour in both Visual Studio Professional 2012 and Visual Studio Express 2013 for Desktop, and got the same error in the PM console when attempting to add the stub settings (after first installing prig via the PM console) via Add-PrigAssembly -Assembly "mscorlib, Version=4.0.0.0" [full dump below],

(my actual username has been replaced with {username})

I find the error C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\prig.exe to be interesting, since the .exe does exist, but is located at either

C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\x64\prig.exe (x64 sub-dir)

or

C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\x86\prig.exe (x86 sub-dir)

Array assignment to [AnyCPU|true] failed: The value "" is not of type "System.Collections.Generic.List`1[System.Reflection.ProcessorArchitecture]" and cannot be used in this generic collection.
Parameter name: value.
At C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Add-PrigAssembly.ps1:74 char:30
+             $platformTargets[ <<<< $conditionedProperty] = New-Object 'System.Collections.Generic.List[System.Reflection.ProcessorArchitecture]'
    + CategoryInfo          : InvalidOperation: (AnyCPU|true:String) [], RuntimeException
    + FullyQualifiedErrorId : ArrayAssignmentFailed

You cannot call a method on a null-valued expression.
At C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Add-PrigAssembly.ps1:78 char:55
+             $platformTargets[$conditionedProperty].Add <<<< ($1stCandidateArch)
    + CategoryInfo          : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Add-PrigAssembly.ps1:79 char:55
+             $platformTargets[$conditionedProperty].Add <<<< ('MSIL')
    + CategoryInfo          : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Array assignment to [AnyCPU|false] failed: The value "" is not of type "System.Collections.Generic.List`1[System.Reflection.ProcessorArchitecture]" and cannot be used in this generic collection.
Parameter name: value.
At C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Add-PrigAssembly.ps1:74 char:30
+             $platformTargets[ <<<< $conditionedProperty] = New-Object 'System.Collections.Generic.List[System.Reflection.ProcessorArchitecture]'
    + CategoryInfo          : InvalidOperation: (AnyCPU|false:String) [], RuntimeException
    + FullyQualifiedErrorId : ArrayAssignmentFailed

You cannot call a method on a null-valued expression.
At C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Add-PrigAssembly.ps1:78 char:55
+             $platformTargets[$conditionedProperty].Add <<<< ($1stCandidateArch)
    + CategoryInfo          : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Add-PrigAssembly.ps1:79 char:55
+             $platformTargets[$conditionedProperty].Add <<<< ('MSIL')
    + CategoryInfo          : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Array assignment to [x64] failed: The value "" is not of type "System.Collections.Generic.List`1[System.Reflection.ProcessorArchitecture]" and cannot be used in this generic collection.
Parameter name: value.
At C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Add-PrigAssembly.ps1:74 char:30
+             $platformTargets[ <<<< $conditionedProperty] = New-Object 'System.Collections.Generic.List[System.Reflection.ProcessorArchitecture]'
    + CategoryInfo          : InvalidOperation: (x64:String) [], RuntimeException
    + FullyQualifiedErrorId : ArrayAssignmentFailed

You cannot call a method on a null-valued expression.
At C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Add-PrigAssembly.ps1:78 char:55
+             $platformTargets[$conditionedProperty].Add <<<< ($1stCandidateArch)
    + CategoryInfo          : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Add-PrigAssembly.ps1:79 char:55
+             $platformTargets[$conditionedProperty].Add <<<< ('MSIL')
    + CategoryInfo          : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

The term 'C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\prig.exe' is not recognized as the name of a cmdlet, function, script file, or operable progra
m. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Invoke-Prig.ps1:92 char:18
+                 & <<<<  $prig dasm -assembly $Assembly
    + CategoryInfo          : ObjectNotFound: (C:\Users\pauluk...\tools\prig.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You cannot call a method on a null-valued expression.
At C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Add-PrigAssembly.ps1:121 char:42
+         $result.psobject.TypeNames.Insert <<<< (0, $AssemblyNameExTypeName)
    + CategoryInfo          : InvalidOperation: (Insert:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Cannot index into a null array.
At C:\Users\{username}\documents\visual studio 2013\Projects\PrigTest1\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Add-PrigAssembly.ps1:108 char:53
+     SetStubSettingNoneItem $curMsbProj $actualNames[ <<<< 0] $envProj.FullName
    + CategoryInfo          : InvalidOperation: (0:Int32) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

Support Visual Studio 2015 Update 1

In Visual Studio 2015 Update 1, it seems that test hosting process is changed to te.processhost.managed from vstest.executionengine. So, the processes at Enable Test Adapter should consider the change.

`Add-PrigAssembly -AssemblyFrom` went dead.

In the Prig v0.0.0-alpha4, the command Add-PrigAssembly -AssemblyFrom went dead.
When running the command, I got the following error message:

PM >  Add-PrigAssembly -AssemblyFrom "C:\Users\User\Documents\Visual Studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe"
"1" 個の引数を指定して "GetDirectoryName" を呼び出し中に例外が発生しました: "パスの形式が無効です。"
発生場所 C:\users\user\documents\visual studio 2013\Projects\ConsoleApplication1\packages\Prig.0.0.0-alpha4\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Add-PrigAssembly.ps1:253 文字:9
+         $tools = [System.IO.Path]::GetDirectoryName((Get-Command prig).Path)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException

ユーザー設定変数 "ErrorActionPreference" または共通パラメーターが Stop に設定されているため、実行中のコマンドが停止しました。パス 'C:\users\user\documents\visual studio 2013\Projects\ConsoleApplication1\PilotStubber.prig' が存在しないため検出できません。
PM >  

I seem that its cause is the side-effect by Issue #7.

Unable to add Prig assembly for mscorlib

I'm following the walkthrough to get my project using Prig. It's a .Net 4.5.1 unit test, and I'm using Visual Studio 2015. When I right-click on References for the test project and click Add Prig Assembly for mscorlib, I get this message:

11-16-2015 11-39-39 am

What should I do about this?

Reduce the environmental-dependence of `Add-PrigAssembly`

Currently, Add-PrigAssembly make the absolute path of the replacement target assembly. However, this behavior will break the build if the committed *.csproj is carried another environment.

It should reduce such environmental-dependence by using a reference path for example.

Namespace reference not added for parameter that is array type?

I have a method with this signature:

protected int ExecuteNonQuery(String commandText, CommandType commandType, DbParameter[] parameters)

CommandType is in the System.Data namespace, and DbParameter is in the System.Data.Common namespace.

When I attempt to generate a stub, I get this stub:

<add name="ExecuteNonQueryStringCommandTypeDbParameterArray" alias="ExecuteNonQueryStringCommandTypeDbParameterArray"> <RuntimeMethodInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection"> <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">ExecuteNonQuery</Name> <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</AssemblyName> <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">Common.Repository.AbstractSqlRepository</ClassName> <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">Int32 ExecuteNonQuery(System.String, System.Data.CommandType, System.Data.Common.DbParameter[])</Signature> <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">System.Int32 ExecuteNonQuery(System.String, System.Data.CommandType, System.Data.Common.DbParameter[])</Signature2> <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">8</MemberType> <GenericArguments i:nil="true" xmlns="" /> </RuntimeMethodInfo> </add>

The code file is generated for the stub, but I get this Type for the IndirectionFunc:

public IndirectionFunc<Common.Repository.AbstractSqlRepository, System.String, System.Data.CommandType, DbParameter[], System.Int32> Body

(Common.Repository.AbstractSqlRepository is my class.)

If you notice, all of the parameters have the full namespace listed, with the exception of the DbParameter[] type. I'm wondering if it has something to do with the fact that the command type is an array? The System.Data.Common using statement isn't there in the file, either.

Make framework assemblies private.

The Prig framework managed assemblies Urasandesu.NAnonym, Urasandesu.Prig.Framework should be private(They shouldn't be in GAC). If we don't do that, unintended assembly neutralization is occurred by the test execution engine of Visual Studio, and also an internal error of .NET runtime - e.g. Exception Code: 0xc0000005 - is occurred.

The entry point of the test execution engine is marked by LoaderOptimizationAttribute with LoaderOptimization.MultiDomainHost. This acts to load the assemblies that are in GAC to the neutral domain if available.

When assemblies are loaded to the neutral domain, their JIT results are shared and static field is validated every accessing time. This is problem for Prig, because the core utility class LooseCrossDomainAccessor is promised that any static fields is validated only once in their domain.

The only way to prohibit loading assemblies to the neutral domain is to make the assemblies private.

Add Comment-Based Help

This issue is a cause of the combination of issues. The original issue is reported at Issues 22 comment-58711535.

Comment-Based Help should be added to the following commands at least, because they are directly used by developer:

  • Add-PrigAssembly(alias: PAdd)
  • Find-IndirectionTarget(alias: PFind)
  • Get-IndirectionStubSetting(alias: PGet)
  • Invoke-Prig(alias: prig)

Why do you use PDateTime in the sample code?

your readme https://github.com/urasandesu/Prig/blob/master/README.md uses PDateTime which is not anywhere in the scope - this is your custom class i believe... - https://gist.github.com/urasandesu/8751367

having that, what is the meaning of example???:

[Test]
public void IsNowLunchBreak_should_return_false_when_11_oclock() {
// IndirectionsContext can minimize the influence of the API replacement.
using (new IndirectionsContext())
{
// Arrange
// Replace DateTime.Now body. Hereafter, DateTime.Now will return only 2013/12/13 11:00:00.
PDateTime.NowGet().Body = () => new DateTime(2013, 12, 13, 11, 00, 00);

            // Act
            var result = LifeInfo.IsNowLunchBreak();

            // Assert
            Assert.IsFalse(result);
        }
    }

Build was failed when adding Prig assembly for 3rd party library.

When I added Prig assembly for 3rd party library, I got the following build error:

CS0234: The type or namespace name 'ComponentModel' does not exist in the namespace 'System' (are you missing an assembly reference?) [C:\Users\User\Documents\Visual Studio 2013\Projects\ConsoleApplication1\ConsoleApplication1Test\UntestableLibrary.v4.0.30319.v1.0.0.0.MSIL.Prig\UntestableLibrary.Prig.g.csproj]

I seem that UntestableLibrary.Prig.g.csproj doesn't have the assembly references other than Urasandesu.NAnonym, Urasandesu.Prig.Framework and stubbing assembly. The csproj file is here:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <OutputType>Library</OutputType>
    <RootNamespace>UntestableLibrary.Prig</RootNamespace>
    <FileAlignment>512</FileAlignment>
    <SignAssembly>False</SignAssembly>
    <AssemblyOriginatorKeyFile>
    </AssemblyOriginatorKeyFile>
    <OutputPath>C:\Users\User\Documents\Visual Studio 2013\Projects\ConsoleApplication1\ConsoleApplication1Test\bin\Debug\.</OutputPath>
    <DefineConstants>_M_MSIL;_NET_4</DefineConstants>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <AssemblyName>UntestableLibrary.v4.0.30319.v1.0.0.0.MSIL.Prig</AssemblyName>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Urasandesu.NAnonym">
      <HintPath>C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Urasandesu.NAnonym\v4.0_0.2.0.0__ce9e95b04334d5fb\Urasandesu.NAnonym.dll</HintPath>
    </Reference>
    <Reference Include="Urasandesu.Prig.Framework">
      <HintPath>C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Urasandesu.Prig.Framework\v4.0_0.1.0.0__acabb3ef0ebf69ce\Urasandesu.Prig.Framework.dll</HintPath>
    </Reference>
    <Reference Include="UntestableLibrary">
      <HintPath>C:\Users\User\Documents\Visual Studio 2013\Projects\ConsoleApplication1\Library\UntestableLibrary.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="**/*.cs" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Shouldn't it rather also have references for <stubbing assembly>.GetReferencedAssemblies()?

Indirection stub settings for the instance method of an internal class generates build errors.

In Prig v0.0.0-alpha8, when making the indirection stub settings like the following class, build errors occurred:

internal class FooInternal
{
    public void DoIt()
    {
        throw new NotImplementedException();
    }
}

It seems that the signature of the method DoIt is public seemingly. However, it requires implicit this parameter. The type of this is FooInternal, so the member's signature is non-public in fact.

Prig should avoid to make the indirection stub of such member automatically.

Multiple Prig assemblies can't be added.

Add-PrigAssembly command doesn't work against multiple assemblies. For example, I ran the following commands:

  1. PM> Add-PrigAssembly -Assembly "mscorlib, Version=4.0.0.0"
  2. PM> Add-PrigAssembly -Assembly "System, Version=4.0.0.0"

In this case, the 2nd command didn't work.

Unit tests on specific class repeatedly crashes ms test runner

We have an older service we had some unit tests with ms fake that worked that we are trying to convert the test to prig but it crashes vstest.executionengine. what is the best way to debug the issue?

The issue is reproducible every time with this class (it has some static properties/fields that we are trying to mock out but for the sake of argument I set these all to null in the System Under Test and did not stub any methods but it still crashes when running any test (even just new Service()) with the prig test adapter is enabled.

Here is information from the dump.

Dump Summary

Dump File: vstest.executionengine.exe.26884.dmp : C:\Users\wege\AppData\Local\CrashDumps\vstest.executionengine.exe.26884.dmp
Last Write Time: 4/3/2015 12:26:03 AM
Process Name: vstest.executionengine.exe : C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\Common7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.exe
Process Architecture: x64
Exception Code: 0xC0000005
Exception Information: The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
Heap Information: Present

System Information

OS Version: 6.1.7601
CLR Version(s): 4.5.27.0

Modules

Module Name Module Path Module Version


vstest.executionengine.exe C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\Common7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.exe 12.0.30501.0
ntdll.dll C:\Windows\System32\ntdll.dll 6.1.7601.18247
mscoree.dll C:\Windows\System32\mscoree.dll 4.0.40305.0
kernel32.dll C:\Windows\System32\kernel32.dll 6.1.7601.18409
KERNELBASE.dll C:\Windows\System32\KERNELBASE.dll 6.1.7601.18409
sxwmon64.dll C:\Windows\System32\sxwmon64.dll 4.5.2710.0
user32.dll C:\Windows\System32\user32.dll 6.1.7601.17514
gdi32.dll C:\Windows\System32\gdi32.dll 6.1.7601.18577
lpk.dll C:\Windows\System32\lpk.dll 6.1.7601.18177
usp10.dll C:\Windows\System32\usp10.dll 1.626.7601.18454
msvcrt.dll C:\Windows\System32\msvcrt.dll 7.0.7601.17744
advapi32.dll C:\Windows\System32\advapi32.dll 6.1.7601.18247
sechost.dll C:\Windows\System32\sechost.dll 6.1.7600.16385
rpcrt4.dll C:\Windows\System32\rpcrt4.dll 6.1.7601.18532
shell32.dll C:\Windows\System32\shell32.dll 6.1.7601.18429
shlwapi.dll C:\Windows\System32\shlwapi.dll 6.1.7601.17514
ole32.dll C:\Windows\System32\ole32.dll 6.1.7601.17514
oleaut32.dll C:\Windows\System32\oleaut32.dll 6.1.7601.18640
imm32.dll C:\Windows\System32\imm32.dll 6.1.7600.16385
msctf.dll C:\Windows\System32\msctf.dll 6.1.7600.16385
DAinit.dll C:\Windows\System32\DAinit.dll 7.0.0.36
vmwsci.dll C:\Windows\System32\vmwsci.dll 5.3.2.24325
psapi.dll C:\Windows\System32\psapi.dll 6.1.7600.16385
mscoreei.dll C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscoreei.dll 4.5.27.0
clr.dll C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll 4.5.27.0
MSVCR120_CLR0400.dll C:\Windows\System32\MSVCR120_CLR0400.dll 12.0.52242.36242
Urasandesu.Prig.dll C:\ProgramData\chocolatey\lib\Prig.2.0.0-alpha03\tools\x64\Urasandesu.Prig.dll 0.1.0.0
dbghelp.dll C:\Windows\System32\dbghelp.dll 6.1.7601.17514
msvcp120.dll C:\Windows\System32\msvcp120.dll 12.0.21005.1
msvcr120.dll C:\Windows\System32\msvcr120.dll 12.0.21005.1
version.dll C:\Windows\System32\version.dll 6.1.7600.16385
fusion.dll C:\Windows\Microsoft.NET\Framework64\v4.0.30319\fusion.dll 4.5.27.0
cryptsp.dll C:\Windows\System32\cryptsp.dll 6.1.7600.16385
rsaenh.dll C:\Windows\System32\rsaenh.dll 6.1.7600.16385
CRYPTBASE.dll C:\Windows\System32\CRYPTBASE.dll 6.1.7600.16385
clrjit.dll C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clrjit.dll 4.5.27.0
nlssorting.dll C:\Windows\Microsoft.NET\Framework64\v4.0.30319\nlssorting.dll 4.5.27.0
System.Transactions.dll C:\Windows\Microsoft.Net\assembly\GAC_64\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll 4.5.27.0
pcwum.dll C:\Windows\System32\pcwum.dll 6.1.7600.16385
bcrypt.dll C:\Windows\System32\bcrypt.dll 6.1.7600.16385
secur32.dll C:\Windows\System32\secur32.dll 6.1.7601.18779
sspicli.dll C:\Windows\System32\sspicli.dll 6.1.7601.18779
credssp.dll C:\Windows\System32\credssp.dll 6.1.7601.18779
msv1_0.dll C:\Windows\System32\msv1_0.dll 6.1.7601.18779
cryptdll.dll C:\Windows\System32\cryptdll.dll 6.1.7600.16385
System.Data.dll C:\Windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll 4.5.27.0
ws2_32.dll C:\Windows\System32\ws2_32.dll 6.1.7601.17514
nsi.dll C:\Windows\System32\nsi.dll 6.1.7600.16385
crypt32.dll C:\Windows\System32\crypt32.dll 6.1.7601.18277
msasn1.dll C:\Windows\System32\msasn1.dll 6.1.7601.17514
diasymreader.dll C:\Windows\Microsoft.NET\Framework64\v4.0.30319\diasymreader.dll 12.0.52242.36242
RpcRtRemote.dll C:\Windows\System32\RpcRtRemote.dll 6.1.7601.17514
clbcatq.dll C:\Windows\System32\clbcatq.dll 2001.12.8530.16385
uxtheme.dll C:\Windows\System32\uxtheme.dll 6.1.7600.16385
urlmon.dll C:\Windows\System32\urlmon.dll 11.0.9600.17496
api-ms-win-downlevel-ole32-l1-1-0.dll C:\Windows\System32\api-ms-win-downlevel-ole32-l1-1-0.dll 6.2.9200.16492
api-ms-win-downlevel-shlwapi-l1-1-0.dll C:\Windows\System32\api-ms-win-downlevel-shlwapi-l1-1-0.dll 6.2.9200.16492
api-ms-win-downlevel-advapi32-l1-1-0.dll C:\Windows\System32\api-ms-win-downlevel-advapi32-l1-1-0.dll 6.2.9200.16492
api-ms-win-downlevel-user32-l1-1-0.dll C:\Windows\System32\api-ms-win-downlevel-user32-l1-1-0.dll 6.2.9200.16492
api-ms-win-downlevel-version-l1-1-0.dll C:\Windows\System32\api-ms-win-downlevel-version-l1-1-0.dll 6.2.9200.16492
api-ms-win-downlevel-normaliz-l1-1-0.dll C:\Windows\System32\api-ms-win-downlevel-normaliz-l1-1-0.dll 6.2.9200.16492
normaliz.dll C:\Windows\System32\normaliz.dll 6.1.7600.16385
iertutil.dll C:\Windows\System32\iertutil.dll 11.0.9600.17496
wininet.dll C:\Windows\System32\wininet.dll 11.0.9600.17496
userenv.dll C:\Windows\System32\userenv.dll 6.1.7601.17514
profapi.dll C:\Windows\System32\profapi.dll 6.1.7600.16385
api-ms-win-downlevel-advapi32-l2-1-0.dll C:\Windows\System32\api-ms-win-downlevel-advapi32-l2-1-0.dll 6.2.9200.16492

`Get-IndirectionStubSetting` generates invalid alias against explict implemented interface.

Get-IndirectionStubSetting generates invalid alias for indirection stub settings against the member that implements an interface explicitly.

When it is executed against the following class, :

public interface IFoo
{
    void Execute(int arg1);
}

public sealed class Foo : IFoo
{
    void IFoo.Execute(int arg1)
    {
        throw new NotImplementedException();
    }
}

the following indirection stub setting is generated:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="prig" type="Urasandesu.Prig.Framework.PilotStubberConfiguration.PrigSection, Urasandesu.Prig.Framework" />
  </configSections>
  <prig>
    <stubs>
      <add name="SealedMockingMigration.IFoo.ExecuteInt32" alias="SealedMockingMigration.IFoo.ExecuteInt32">
        <RuntimeMethodInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection">
          <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">SealedMockingMigration.IFoo.Execute</Name>
          <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">SealedMockingMigration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</AssemblyName>
          <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">SealedMockingMigration.Foo</ClassName>
          <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">Void SealedMockingMigration.IFoo.Execute(Int32)</Signature>
          <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">System.Void SealedMockingMigration.IFoo.Execute(System.Int32)</Signature2>
          <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">8</MemberType>
          <GenericArguments i:nil="true" xmlns="" />
        </RuntimeMethodInfo>
      </add>
    </stubs>
  </prig>
</configuration>

This can't build successfully, because it has invalid alias name SealedMockingMigration.IFoo.ExecuteInt32.

Prig can't uninstall correctly against the solution that contains multiple test projects.

Prig 0.0.0-alpha8 can't uninstall correctly against the solution that contains multiple test projects.

After installing Prig to the solution which contains multiple test projects, if uninstalling Prig from either test project, I can't test using Prig at rest projects any more.

Steps

  1. Add the test projects ClassLibraryTest1 and ClassLibraryTest2 to one solution.
  2. Run the command Install-Package Prig -Pre at ClassLibraryTest1.
  3. Run the command Install-Package Prig -Pre at ClassLibraryTest2.
  4. Run the command Uninstall-Package Prig at ClassLibraryTest1.
  5. At ClassLibraryTest2, try to add the indirection stub settings(e.g. Add-PrigAssembly -Assembly "mscorlib, Version=4.0.0.0").

Results

PM>  Add-PrigAssembly -Assembly "mscorlib, Version=4.0.0.0"
Add-PrigAssembly : 用語 'Add-PrigAssembly' は、コマンドレット、関数、スクリプト ファイル、または操作可能なプログラムの名前として認識されません。名前が正しく記述されていることを確認し、パスが含まれている場合はそのパスが正しいことを確認してから、再試行してください。
発生場所 行:1 文字:1
+ Add-PrigAssembly -Assembly "mscorlib, Version=4.0.0.0"
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Add-PrigAssembly:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PM>  

Expected Results

Allow to add the indirection stub settings without error.

Test stalled if adding the indirection settings for all members of DateTime.

In v1.0.0, I got the following error when I added the indirection settings for all members of System.DateTime:

2014/12/29 11:20:29.273988,ERROR,00000x21a0,1683,0x00001e0c,"            C:\Users\Akira\Prig\Swathe\Urasandesu.Swathe\Urasandesu/Swathe/Metadata/BaseClassPimpl/BaseInstructionMetadataPimpl.hpp(427): Throw in function unsigned long __cdecl Urasandesu::Swathe::Metadata::BaseClassPimpl::BaseInstructionMetadataPimpl<struct Urasandesu::Swathe::AutoGen::Metadata::DefaultClassPimplApiHolder::DefaultInstructionMetadataPimplApiHolder>::TakeInlineToken(const class Urasandesu::Swathe::Metadata::BaseClassPimpl::BaseInstructionMetadataPimpl<struct Urasandesu::Swathe::AutoGen::Metadata::DefaultClassPimplApiHolder::DefaultInstructionMetadataPimplApiHolder> *,const unsigned char *,const unsigned char *,class boost::variant<struct boost::blank,bool,unsigned char,double,short,int,__int64,struct Urasandesu::Swathe::Metadata::ILocal const *,struct Urasandesu::Swathe::Metadata::Signature const *,struct Urasandesu::Swathe::Metadata::IField const *,struct Urasandesu::Swathe::Metadata::IMethod const *,char,float,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,struct Urasandesu::Swathe::Metadata::IType const *,class Urasandesu::Swathe::Metadata::Label,class std::vector<int,class std::allocator<int> >,class std::vector<class Urasandesu::Swathe::Metadata::Label,class std::allocator<class Urasandesu::Swathe::Metadata::Label> >,struct boost::detail::variant::void_,struct boost::detail::variant::void_> &)
Dynamic exception type: class boost::exception_detail::clone_impl<struct Urasandesu::CppAnonym::CppAnonymNotImplementedException>
std::exception::what: mdtTarget: 0x04002BF9
[struct Urasandesu::CppAnonym::tag_stack_trace * __ptr64] = at Urasandesu::CppAnonym::CppAnonymNotImplementedException::CppAnonymNotImplementedException in C:\Users\Akira\Documents\Visual Studio 2013\Projects\VariationTest\Test03\packages\Prig.1.1.0\tools\x64\Urasandesu.Prig.dll(c:\users\akira\prig\cppanonym\urasandesu.cppanonym\urasandesu\cppanonym\cppanonymnotimplementedexception.cpp:54)
at Urasandesu::Swathe::Metadata::BaseClassPimpl::BaseInstructionMetadataPimpl<Urasandesu::Swathe::AutoGen::Metadata::DefaultClassPimplApiHolder::DefaultInstructionMetadataPimplApiHolder>::TakeInlineToken in C:\Users\Akira\Documents\Visual Studio 2013\Projects\VariationTest\Test03\packages\Prig.1.1.0\tools\x64\Urasandesu.Prig.dll(c:\users\akira\prig\swathe\urasandesu.swathe\urasandesu\swathe\metadata\baseclasspimpl\baseinstructionmetadatapimpl.hpp:427)
at Urasandesu::Swathe::Metadata::BaseClassPimpl::BaseInstructionMetadataPimpl<Urasandesu::Swathe::AutoGen::Metadata::DefaultClassPimplApiHolder::DefaultInstructionMetadataPimplApiHolder>::TakeRawData in C:\Users\Akira\Documents\Visual Studio 2013\Projects\VariationTest\Test03\packages\Prig.1.1.0\tools\x64\Urasandesu.Prig.dll(c:\users\akira\prig\swathe\urasandesu.swathe\urasandesu\swathe\metadata\baseclasspimpl\baseinstructionmetadatapimpl.hpp:242)
at Urasandesu::Swathe::Metadata::BaseClassPimpl::BaseMethodBodyMetadataPimpl<Urasandesu::Swathe::AutoGen::Metadata::DefaultClassPimplApiHolder::DefaultMethodBodyMetadataPimplApiHolder>::GetInstructions in C:\Users\Akira\Documents\Visual Studio 2013\Projects\VariationTest\Test03\packages\Prig.1.1.0\tools\x64\Urasandesu.Prig.dll(c:\users\akira\prig\swathe\urasandesu.swathe\urasandesu\swathe\metadata\baseclasspimpl\basemethodbodymetadatapimpl.hpp:153)
at Urasandesu::Swathe::Metadata::BaseClass::BaseMethodBodyMetadata<Urasandesu::Swathe::AutoGen::Metadata::DefaultClassApiHolder::DefaultMethodBodyMetadataApiHolder>::GetInstructions in C:\Users\Akira\Documents\Visual Studio 2013\Projects\VariationTest\Test03\packages\Prig.1.1.0\tools\x64\Urasandesu.Prig.dll(c:\users\akira\prig\swathe\urasandesu.swathe\urasandesu\swathe\metadata\baseclass\basemethodbodymetadata.hpp:101)
at Urasandesu::Swathe::Metadata::BaseClassPimpl::BaseMethodBodyGeneratorPimpl<Urasandesu::Swathe::AutoGen::Metadata::DefaultClassPimplApiHolder::DefaultMethodBodyGeneratorPimplApiHolder>::GetInstructions in C:\Users\Akira\Documents\Visual Studio 2013\Projects\VariationTest\Test03\packages\Prig.1.1.0\tools\x64\Urasandesu.Prig.dll(c:\users\akira\prig\swathe\urasandesu.swathe\urasandesu\swathe\metadata\baseclasspimpl\basemethodbodygeneratorpimpl.hpp:192)
at Urasandesu::Swathe::Metadata::BaseClass::BaseMethodBodyGenerator<Urasandesu::Swathe::AutoGen::Metadata::DefaultClassApiHolder::DefaultMethodBodyGeneratorApiHolder>::GetInstructions in C:\Users\Akira\Documents\Visual Studio 2013\Projects\VariationTest\Test03\packages\Prig.1.1.0\tools\x64\Urasandesu.Prig.dll(c:\users\akira\prig\swathe\urasandesu.swathe\urasandesu\swathe\metadata\baseclass\basemethodbodygenerator.hpp:102)
at CWeaverDetail::CWeaverImpl::JITCompilationStartedCore in C:\Users\Akira\Documents\Visual Studio 2013\Projects\VariationTest\Test03\packages\Prig.1.1.0\tools\x64\Urasandesu.Prig.dll(c:\users\akira\prig\urasandesu.prig\weaver.cpp:444)
at Urasandesu::Swathe::Profiling::ICorProfilerCallbackImpl<ICorProfilerCallback5>::JITCompilationStarted in C:\Users\Akira\Documents\Visual Studio 2013\Projects\VariationTest\Test03\packages\Prig.1.1.0\tools\x64\Urasandesu.Prig.dll(c:\users\akira\prig\swathe\urasandesu.swathe\urasandesu\swathe\profiling\icorprofilercallbackimpl.h:274)
at SetProfToEEInterface in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscordbc.dll
at CertCreateAuthenticodeLicense in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at PreBindAssembly in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at IEE in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at IEE in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at PreBindAssembly in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CertCreateAuthenticodeLicense in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at NGenCreateNGenWorker in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at GetMetaDataInternalInterface in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at InitializeFusion in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at PreBindAssembly in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CreateAssemblyNameObject in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at PreBindAssembly in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at PreBindAssembly in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at PreBindAssembly in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CreateAssemblyNameObject in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at <Unknown Symbol> in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorjit.dll
at <Unknown Symbol> in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorjit.dll
at <Unknown Symbol> in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorjit.dll
at <Unknown Symbol> in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorjit.dll
at <Unknown Symbol> in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorjit.dll
at <Unknown Symbol> in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorjit.dll
at CreateAssemblyNameObject in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CreateAssemblyNameObject in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CreateAssemblyNameObject in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at PreBindAssembly in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at CompareAssemblyIdentity in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at IEE in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
at <Unknown Symbol> in <Unknown Module>
at <Unknown Symbol> in <Unknown Module>

","C:\Users\Akira\Prig\Swathe\Urasandesu.Swathe\Urasandesu/Swathe/Profiling/ICorProfilerCallbackImpl.h",274,"long __cdecl CWeaverDetail::CWeaverImpl::JITCompilationStartedCore(unsigned __int64,int)=>Weaver.cpp,360","pModProf.IsPersisted()=>Weaver.cpp,377","(result = prigData.m_indirectables.find(mdt)) != prigData.m_indirectables.end()=>Weaver.cpp,419","Modifying method=>Weaver.cpp,425"

It seems that the case that the metadata token fielddef comes in as an operand of the opcode ldtoken is not implemented.

Issue with out parameters

I am having trouble generating the below stub I debugged this a bit (powershell wise) and it is because $stub.IndirectionDelegate is null any idea why that would be?

<add name="GetContractDetailsStringBooleanRefDecimalRefDecimalRef" alias="GetContractDetailsStringBooleanRefDecimalRefDecimalRef">
        <RuntimeMethodInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection">
          <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">GetContractDetails</Name>
          <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">AQR.BP.TW.FX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</AssemblyName>
          <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">AQR.BP.TW.FX.Helpers</ClassName>
          <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">Void GetContractDetails(System.String, Boolean ByRef, System.Decimal ByRef, System.Decimal ByRef)</Signature>
          <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">System.Void GetContractDetails(System.String, System.Boolean&amp;, System.Decimal&amp;, System.Decimal&amp;)</Signature2>
          <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">8</MemberType>
          <GenericArguments i:nil="true" xmlns="" />
        </RuntimeMethodInfo>
      </add>

Can't be replaced the method that exposes the type of GAC unregistered assembly.

This issue is a cause of the combination of issues. The original issue is reported at Issues 22 comment-58714123.

Prig can't create correctly the *.csproj for the indirection stub like the below steps:

STEP 1: Add a class to a Class Library

For example, after creating a project as Class Library, add the class like below:

namespace ClassLibrary1
{
    public class Foo
    {
        public int Echo(int arg0)
        {
            return arg0;
        }
    }
}

STEP 2: Expose the above class at another *.csproj

For example, create the class like below at another *.csproj:

using ClassLibrary1;
using System;

namespace ConsoleApplication45
{
    public class Bar
    {
        public Foo CreateFoo()
        {
            throw new NotImplementedException();
        }
    }
}

Then, add the indirection setting against the above method:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="prig" type="Urasandesu.Prig.Framework.PilotStubberConfiguration.PrigSection, Urasandesu.Prig.Framework" />
  </configSections>
  <prig>
    <stubs>
      <add name="CreateFoo" alias="CreateFoo">
        <RuntimeMethodInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection">
          <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">CreateFoo</Name>
          <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">ConsoleApplication45, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</AssemblyName>
          <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">ConsoleApplication45.Bar</ClassName>
          <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">ClassLibrary1.Foo CreateFoo()</Signature>
          <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">ClassLibrary1.Foo CreateFoo()</Signature2>
          <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">8</MemberType>
          <GenericArguments i:nil="true" xmlns="" />
        </RuntimeMethodInfo>
      </add>
    </stubs>
  </prig>
</configuration>

RESULT

You'll get the build error as the below:

エラー,75,型または名前空間名 'ClassLibrary1' が見つかりませんでした。using ディレクティブまたはアセンブリ参照が不足しています。 [c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45.v4.0.30319.v1.0.0.0.MSIL.Prig\ConsoleApplication45.Prig.g.csproj],c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45\PBar.cs,24,62,ConsoleApplication45
エラー,76,型または名前空間名 'ClassLibrary1' が見つかりませんでした。using ディレクティブまたはアセンブリ参照が不足しています。 [c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45.v4.0.30319.v1.0.0.0.MSIL.Prig\ConsoleApplication45.Prig.g.csproj],c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45\PBar.cs,62,124,ConsoleApplication45
エラー,77,型または名前空間名 'ClassLibrary1' が見つかりませんでした。using ディレクティブまたはアセンブリ参照が不足しています。 [c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45.v4.0.30319.v1.0.0.0.MSIL.Prig\ConsoleApplication45.Prig.g.csproj],c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45\PProxyBar.cs,37,62,ConsoleApplication45
エラー,79,型または名前空間名 'ClassLibrary1' が見つかりませんでした。using ディレクティブまたはアセンブリ参照が不足しています。 [c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45.v4.0.30319.v1.0.0.0.MSIL.Prig\ConsoleApplication45.Prig.g.csproj],c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45\PBar.cs,24,62,ConsoleApplication45
エラー,80,型または名前空間名 'ClassLibrary1' が見つかりませんでした。using ディレクティブまたはアセンブリ参照が不足しています。 [c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45.v4.0.30319.v1.0.0.0.MSIL.Prig\ConsoleApplication45.Prig.g.csproj],c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45\PBar.cs,62,124,ConsoleApplication45
エラー,81,型または名前空間名 'ClassLibrary1' が見つかりませんでした。using ディレクティブまたはアセンブリ参照が不足しています。 [c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45.v4.0.30319.v1.0.0.0.MSIL.Prig\ConsoleApplication45.Prig.g.csproj],c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45\PProxyBar.cs,37,62,ConsoleApplication45
エラー,82,"コマンド ""cmd /c "" ""%VS120COMNTOOLS%VsDevCmd.bat"" & %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -File ""c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\packages\Prig.0.0.0-alpha9\tools\Invoke-PilotStubber.ps1"" -ReferenceFrom ""@('c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\packages\Prig.0.0.0-alpha9\lib\net40\Urasandesu.NAnonym.dll','c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\packages\Prig.0.0.0-alpha9\lib\net40\Urasandesu.Prig.Framework.dll')"" -AssemblyFrom ""C:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\bin\Debug\ConsoleApplication45.exe"" -TargetFrameworkVersion v4.5.1 -KeyFile ""c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\packages\Prig.0.0.0-alpha9\tools\Urasandesu.Prig.snk"" -OutputPath ""c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\bin\Debug\."" -Settings ""c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\ConsoleApplication45\ConsoleApplication45.v4.0.30319.v1.0.0.0.prig"" """" はコード -1 で終了しました。",C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets,1131,5,ConsoleApplication45

If you follow the build log, you'll find the error that is occurred at Invoke-PilotStubber.ps1:

1>  警告: "1" 個の引数を指定して "Load" を呼び出し中に例外が発生しました: "ファイルまたはアセンブリ 'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'、またはその依存関係の 1 つが読み込めませんでした。指定されたファイルが見つかりません。"
1>  
1>  発生場所 C:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication45\packages\Prig.0.0.0-alpha9\tools\Invoke-PilotStubber.ps1:98 文字:9
1>  
1>  +         $refAsmInfos.Add([System.Reflection.Assembly]::Load($refAsmName.FullName ...
1>  +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1>  + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
1>  + FullyQualifiedErrorId : FileNotFoundException

Prig assembly shouldn't need InternalsVisibleToAttribute.

In v0.0.0-alpha10, Prig became always generating the indirection stubs. Because Prig had become available to generate the indirection setting against an internal type without limitation. But now, if I create the stub setting for an internal type, the stub exposes the internal type in the method SetTargetInstanceBody/RemoveTargetInstanceBody.

This makes cause occurring build errors if I don't apply InternalsVisibleToAttribute.

`prig -p ConsoleApplication1.exe` went dead.

In the Prig v0.0.0-alpha4, the command prig -p ConsoleApplication1.exe went dead.
When running the command, I got the following error message:

PM >  prig -p ConsoleApplication1.exe
prig.exe : Throw location unknown (consider using BOOST_THROW_EXCEPTION)
発生場所 C:\Users\User\Documents\Visual Studio 2013\Projects\ConsoleApplication1\packages\Prig.0.0.0-alpha4\tools\Urasandesu.Prig\Urasandesu\Prig\NuGet.Invoke-Prig.ps1:85 文字:17
+                 & $prig run -process $Process -arguments $Arguments
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Throw location ...HROW_EXCEPTION):String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Dynamic exception type: class boost::exception_detail::clone_impl<struct boost::exception_detail::error_info_injector<class boost::program_options::invalid_command_line_syntax> >
std::exception::what: the required argument for option '--arguments' is missing



PM >  

I seem that its cause is the side-effect by Issue #7.

Against the method that contains a nested type, indirection stub can't be created.

Against the method that has signature of the appearance of some nested types, Prig can't create the indirection stub. For example, the following setting could not work well:

Target

public class Foo
{
    public int Echo(int arg1)
    {
        return arg1;
    }

    public delegate void EchoEventHandler(bool echoed);
    public event EchoEventHandler OnEchoCallback;
}

Stub Setting

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="prig" type="Urasandesu.Prig.Framework.PilotStubberConfiguration.PrigSection, Urasandesu.Prig.Framework" />
  </configSections>
  <prig>
    <stubs>
      <add name="Echo" alias="Echo">
        <RuntimeMethodInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection">
          <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">Echo</Name>
          <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">ConsoleApplication1</AssemblyName>
          <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">Foo</ClassName>
          <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">Int32 Echo(Int32)</Signature>
          <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">System.Int32 Echo(System.Int32)</Signature2>
          <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">8</MemberType>
          <GenericArguments i:nil="true" xmlns="" />
        </RuntimeMethodInfo>
      </add>
      <add name="AddOnEchoCallback" alias="AddOnEchoCallback">
        <RuntimeMethodInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection">
          <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">add_OnEchoCallback</Name>
          <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">ConsoleApplication1</AssemblyName>
          <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">Foo</ClassName>
          <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">Void add_OnEchoCallback(EchoEventHandler)</Signature>
          <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">System.Void add_OnEchoCallback(Foo+EchoEventHandler)</Signature2>
          <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">8</MemberType>
          <GenericArguments i:nil="true" xmlns="" />
        </RuntimeMethodInfo>
      </add>
    </stubs>
  </prig>
</configuration>

It should be able to call indirectly the same as another method.

Problem Debugging unit tests

I am having an issue debugging unit tests that are using prig. It causes my visual studio to crash.

Any ideas?

Problem signature:
Problem Event Name: APPCRASH
Application Name: devenv.exe
Application Version: 12.0.31101.0
Application Timestamp: 54548724
Fault Module Name: ntdll.dll
Fault Module Version: 6.1.7601.18798
Fault Module Timestamp: 5507b3e0
Exception Code: c00000fd
Exception Offset: 0002e04e
OS Version: 6.1.7601.2.1.0.256.4
Locale ID: 1033
Additional Information 1: 1b65
Additional Information 2: 1b65fd2bc837c3f68ac38b42e645b825
Additional Information 3: f0db
Additional Information 4: f0db8f09d56e5f792e4047923c985d44

Test engine crashes while trying to execute a unit test without indirections context even when it doesn't use any stubs

Hi,
I have a project with two unit tests - one of them uses a stub for DateTime.Now, the other one uses unstubbed DateTime.Now:

[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void UseDateTimeWithoutStubs()
    {
        var dateTime = DateTime.Now;
    }


    [TestMethod]
    public void UseDateTimeWithStubs()
    {
        using (new IndirectionsContext())
        {
            PDateTime.NowGet().Body = () => new DateTime(2013, 12, 13, 11, 00, 00);
            var dateTime = DateTime.Now;
        }
    }
}

Surprisingly,while the first test doesn't use any stubs at all, it makes execution engine crash. The issue is resolved if I use IndirectionsContext in this test, but it looks a little bit strange why a test that doesn't use Prig Stubs should use IndirectionsContext.

Test is freezed when hijacking the method to add an event handler.

My test was freezed when I ported a MS Mole's sample to Prig's:

using System;
using System.Net;

namespace UntestableLibrary
{
    public class ULWebClient
    {
        public static void ShowGoogle()
        {
            var client = new WebClient();
            client.DownloadStringCompleted += (sender, e) =>
            {
                Console.WriteLine(e.Result);
            };
            client.DownloadStringAsync(new Uri("http://google.co.jp/"));
        }
    }
}
using UntestableLibrary;
using Moq;
using NUnit.Framework;
using System;
using System.Net;
using System.Net.Prig;
using System.Prig;
using Urasandesu.NAnonym;
using Urasandesu.NAnonym.Mixins.System;
using Urasandesu.Prig.Framework;

namespace UntestableLibraryTest
{
    [TestFixture]
    public class ULWebClientTest
    {
        [Test]
        public void ShowGoogle_should_write_response_from_google_to_standard_output()
        {
            using (new IndirectionsContext())
            {
                // Arrange 
                var handler = default(DownloadStringCompletedEventHandler);
                handler = (sender, e) => { };
                PWebClient.AddDownloadStringCompleted.Body = (@this, value) => handler += value;
                PWebClient.RemoveDownloadStringCompleted.Body = (@this, value) => handler -= value;
                PWebClient.DownloadStringAsyncUri.Body = (@this, address) =>
                {
                    var e = new PDownloadStringCompletedEventArgsProxy() { ResultGet = () => "google!modoki" };
                    handler(@this, e);
                };
                var mockWriteLine = new Mock<IndirectionAction<string>>();
                mockWriteLine.Setup(_ => _(It.IsAny<string>()));
                PConsole.WriteLine_string.Body = mockWriteLine.Object;


                // Act 
                ULWebClient.ShowGoogle();


                // Assert 
                mockWriteLine.Verify(_ => _(It.Is<string>(s => s == "google!modoki")), Times.Once());
            }
        }
    }

    class PDownloadStringCompletedEventArgsProxy
    {
        static readonly Type Type = typeof(DownloadStringCompletedEventArgs);

        class ConstructorDelegate
        {
            public static readonly Work New = Type.GetConstructorDelegate(new Type[] { typeof(string), typeof(Exception), typeof(bool), typeof(object) });
        }

        DownloadStringCompletedEventArgs m_target;

        public PDownloadStringCompletedEventArgsProxy()
        {
            m_target = (DownloadStringCompletedEventArgs)ConstructorDelegate.New(new object[] { null, null, false, null });
        }

        IndirectionFunc<string> m_resultGet;
        public IndirectionFunc<string> ResultGet
        {
            set
            {
                PDownloadStringCompletedEventArgs.ResultGet.Body = @this =>
                {
                    if (object.ReferenceEquals(@this, m_target))
                        return m_resultGet();
                    else
                        return IndirectionsContext.ExecuteOriginal(() => @this.Result);
                };
                m_resultGet = value;
            }
        }

        public static implicit operator DownloadStringCompletedEventArgs(PDownloadStringCompletedEventArgsProxy @this)
        {
            return @this.m_target;
        }
    }
}

I seem that it can't resolve a generic MemberRef method like Interlocked.CompareExchange<T>(T, T, T).

Default parameterized method can't call indirectly.

In 0.0.0-alpha10, the following method that has a default parameter and the stub setting can't be built:

namespace ConsoleApplication55
{
    public class Foo
    {
        public int Echo(int arg0 = 42)
        {
            return arg0;
        }
    }
}
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="prig" type="Urasandesu.Prig.Framework.PilotStubberConfiguration.PrigSection, Urasandesu.Prig.Framework" />
  </configSections>
  <prig>
    <stubs>
      <add name="EchoInt32" alias="EchoInt32">
        <RuntimeMethodInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection">
          <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">Echo</Name>
          <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">ConsoleApplication55, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</AssemblyName>
          <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">ConsoleApplication55.Foo</ClassName>
          <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">Int32 Echo(Int32)</Signature>
          <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">System.Int32 Echo(System.Int32)</Signature2>
          <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">8</MemberType>
          <GenericArguments i:nil="true" xmlns="" />
        </RuntimeMethodInfo>
      </add>
    </stubs>
  </prig>
</configuration>

The generated stub is as follows(It seems that Urasandesu.Prig.Framework.PilotStubberConfiguration.IndirectionStub.IndirectionDelegate is always null):

    ...(snip)...

    public class PFoo : PFooBase 
    {
        ...(snip)...

        [EditorBrowsable(EditorBrowsableState.Never)]
        public class zzEchoInt32 : IBehaviorPreparable 
        {
            public  Body    // This is invalid!!
            {
                get
                {
                    var holder = LooseCrossDomainAccessor.GetOrRegister<IndirectionHolder<>>(); // This is invalid!!
                    return holder.GetOrDefault(Info);
                }
                set
                {
                    var holder = LooseCrossDomainAccessor.GetOrRegister<IndirectionHolder<>>(); // This is invalid!!
                    if (value == null)
                    {
                        holder.Remove(Info);
                    }
                    else
                    {
                        holder.AddOrUpdate(Info, value);
                        RuntimeHelpers.PrepareDelegate(Body);
                    }
                }
            }

            ...(snip)...

Nested Type can't be resolved in its indirection stub.

In Prig 0.0.0-alpha8, when I used Nested Type in indirection stub, I got some build errors. The trial code is the followings:

Target

using System;
namespace ConsoleApplication38
{
    public class Foo
    {
        public class Bar
        {
            public int Echo(int arg0)
            {
                return arg0;
            }
        }
    }
}

Stub Setting

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="prig" type="Urasandesu.Prig.Framework.PilotStubberConfiguration.PrigSection, Urasandesu.Prig.Framework" />
  </configSections>
  <prig>
    <stubs>
      <add name="EchoInt32" alias="EchoInt32">
        <RuntimeMethodInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection">
          <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">Echo</Name>
          <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">ConsoleApplication38, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</AssemblyName>
          <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">ConsoleApplication38.Foo+Bar</ClassName>
          <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">Int32 Echo(Int32)</Signature>
          <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">System.Int32 Echo(System.Int32)</Signature2>
          <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">8</MemberType>
          <GenericArguments i:nil="true" xmlns="" />
        </RuntimeMethodInfo>
      </add>
    </stubs>
  </prig>
</configuration>

Build Errors

The build errors are followings:

1>------ ビルド開始: プロジェクト:ConsoleApplication38, 構成:Debug Any CPU ------
1>2014/09/19 19:39:22 にビルドを開始しました。
1>PreBuildEvent:
1>  cmd /c " "%VS120COMNTOOLS%VsDevCmd.bat" & %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -File "C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\packages\Prig.0.0.0-alpha8\tools\Invoke-PilotStubber.ps1" -ReferenceFrom "@('C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\packages\Prig.0.0.0-alpha8\lib\net40\Urasandesu.NAnonym.dll','C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\packages\Prig.0.0.0-alpha8\lib\net40\Urasandesu.Prig.Framework.dll')" -AssemblyFrom "C:\Users\Akira\Documents\visual studio 2013\Projects\ConsoleApplication38\ConsoleApplication38\bin\Debug\ConsoleApplication38.exe" -TargetFrameworkVersion v4.5.1 -KeyFile "C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\packages\Prig.0.0.0-alpha8\tools\Urasandesu.Prig.snk" -OutputPath "C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\ConsoleApplication38\bin\Debug\." -Settings "C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\ConsoleApplication38\ConsoleApplication38.v4.0.30319.v1.0.0.0.prig" "
1>  Microsoft (R) Build Engine バージョン 12.0.30723.0
1>  [Microsoft .NET Framework、バージョン 4.0.30319.34014]
1>  Copyright (C) Microsoft Corporation. All rights reserved.
1>  
1>  2014/09/19 19:39:25 にビルドを開始しました。
1>  ノード 1 上のプロジェクト "C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\ConsoleApplication38\ConsoleApplication38.v4.0.30319.v1.0.0.0.MSIL.Prig\ConsoleApplication38.Prig.g.csproj" (rebuild ターゲット)。
1>  CoreClean:
1>    ディレクトリ "obj\Debug\" を作成しています。
1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3270: 構築されているプロジェクトのプロセッサ アーキテクチャ "MSIL" と、参照 "mscorlib" のプロセッサ アーキテクチャ "x86" の間には不一致がありました。この不一致は、ランタイム エラーを発生させる可能性があります。プロジェクトと参照の間でプロセッサ アーキテクチャが一致するように、構成マネージャーを使用してターゲットとするプロジェクトのプロセッサ アーキテクチャを変更するか、ターゲットとするプロジェクトのプロセッサ アーキテクチャに一致するプロジェクト アーキテクチャとの依存関係を参照で設定することを検討してください。 [C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\ConsoleApplication38\ConsoleApplication38.v4.0.30319.v1.0.0.0.MSIL.Prig\ConsoleApplication38.Prig.g.csproj]
1>  GenerateTargetFrameworkMonikerAttribute:
1>  すべての出力ファイルが入力ファイルに対して最新なので、ターゲット "GenerateTargetFrameworkMonikerAttribute" を省略します。
1>  CoreCompile:
1>    C:\Program Files (x86)\MSBuild\12.0\bin\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:AnyCPU /define:_M_MSIL;_NET_4_5_1 /highentropyva+ /reference:"C:\Users\Akira\Documents\visual studio 2013\Projects\ConsoleApplication38\ConsoleApplication38\bin\Debug\ConsoleApplication38.exe" /reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Core.dll" /reference:C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll /reference:C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Urasandesu.NAnonym\v4.0_0.2.0.0__ce9e95b04334d5fb\Urasandesu.NAnonym.dll /reference:C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Urasandesu.Prig.Framework\v4.0_0.1.0.0__acabb3ef0ebf69ce\Urasandesu.Prig.Framework.dll /debug:pdbonly /filealign:512 /optimize+ /out:obj\Debug\ConsoleApplication38.v4.0.30319.v1.0.0.0.MSIL.Prig.dll /subsystemversion:6.00 /target:library /utf8output AutoGen\Tokens.g.cs ConsoleApplication38\PBar.cs ConsoleApplication38\PProxyBar.cs "C:\Users\Akira\AppData\Local\Temp\.NETFramework,Version=v4.5.1.AssemblyAttributes.cs"
1>C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\ConsoleApplication38\ConsoleApplication38\PBar.cs(62,49): error CS0246: 型または名前空間名 'Bar' が見つかりませんでした。using ディレクティブまたはアセンブリ参照が不足しています。 [C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\ConsoleApplication38\ConsoleApplication38.v4.0.30319.v1.0.0.0.MSIL.Prig\ConsoleApplication38.Prig.g.csproj]
1>C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\ConsoleApplication38\ConsoleApplication38\PBar.cs(90,52): error CS0246: 型または名前空間名 'Bar' が見つかりませんでした。using ディレクティブまたはアセンブリ参照が不足しています。 [C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\ConsoleApplication38\ConsoleApplication38.v4.0.30319.v1.0.0.0.MSIL.Prig\ConsoleApplication38.Prig.g.csproj]
1>  プロジェクト "C:\Users\Akira\Documents\Visual Studio 2013\Projects\ConsoleApplication38\ConsoleApplication38\ConsoleApplication38.v4.0.30319.v1.0.0.0.MSIL.Prig\ConsoleApplication38.Prig.g.csproj" (rebuild ターゲット) のビルドが終了しました -- 失敗。
1>  
1>  ビルドに失敗しました。
1>  
...(snip)...

I checked PBar.cs(62,49) to see what is cause for the errors:

            ...(snip)...

            public IndirectionInfo Info
            {
                get
                {
                    var info = new IndirectionInfo();
                    info.AssemblyName = "ConsoleApplication38, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                    info.Token = TokenOfEchoInt32;
                    return info;
                }
            }
            internal void SetTargetInstanceBody(Bar /* !?!?!? */ target, IndirectionFunc<ConsoleApplication38.Foo.Bar, System.Int32, System.Int32> value)
            {
                RuntimeHelpers.PrepareDelegate(value);

                ...(snip)...

It seems that Bar should be specified its full name.

TypeLoadException is occurred when trying to detour multiple assemblies.

When I was porting JustMock's samples to Prig, I got the following exception:

System.TypeLoadException: Could not load type 'Invalid_Token.0x0100040E' from assembly 'StaticMockingSample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

It seems that the exception is occurred when detouring the multiple assemblies that are loaded in the same AppDomain. For your information, this issue is NOT occurred when detouring mscorlib and another assembly. Because mscorlib is domain neutral, so it gives the appearance that another AppDomain from the testing program.

Support Chocolatey v0.9.9

Prig v2.0.0-alpha01 can no longer install from Chocolatey because NuGet.exe isn't contained from the version v0.9.9. To install Prig, we have to add NuGet source for the NuGet package to use Prig management commands in the Package Manager Console.

`.cctor()` can't replace with indirection stub.

When I tried replacing .cctor() with Prig's indirection stub, I got some build errors as the follows:

error CS1519: Invalid token '{' in class, struct, or interface member declaration [c:\users\user\documents\visual studio 2013\Projects\StaticMockingSample\StaticMockingSampleTest\StaticMockingSample.v4.0.30319.v1.0.0.0.MSIL.Prig\StaticMockingSample.Prig.g.csproj]

Indirection stub setting I used is the following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="prig" type="Urasandesu.Prig.Framework.PilotStubberConfiguration.PrigSection, Urasandesu.Prig.Framework" />
  </configSections>
  <prig>
    <stubs>
      <add name="StaticConstructor" alias="StaticConstructor">
        <RuntimeConstructorInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection">
          <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">.cctor</Name>
          <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">StaticMockingSample</AssemblyName>
          <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">StaticMockingSample.Foo</ClassName>
          <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">Void .cctor()</Signature>
          <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">.cctor()</Signature2>
          <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">1</MemberType>
          <GenericArguments i:nil="true" xmlns="" />
        </RuntimeConstructorInfo>
      </add>
    </stubs>
  </prig>
</configuration>

It should be able to replace as same as like another member.

`Environment.GetFolderPath(SpecialFolder)` can't call indirectly

I created the indirection setting of Environment.GetFolderPath(SpecialFolder) and used it, but the program is stalled.

When the above problem was occured, the program output the log as follows:

2014/09/11 06:32:23.151928,ERROR,00000x2750,2172,0x0000238c,"            D:\Prig\Swathe\Urasandesu.Swathe\Urasandesu/Swathe/Metadata/BaseClassPimpl/BaseInstructionMetadataPimpl.hpp(242): Throw in function unsigned long __thiscall Urasandesu::Swathe::Metadata::BaseClassPimpl::BaseInstructionMetadataPimpl<struct Urasandesu::Swathe::AutoGen::Metadata::DefaultClassPimplApiHolder::DefaultInstructionMetadataPimplApiHolder>::TakeRawData(const unsigned char *,const unsigned char *)
Dynamic exception type: class boost::exception_detail::clone_impl<struct Urasandesu::CppAnonym::CppAnonymNotImplementedException>
std::exception::what: This process is not implemented.
[struct Urasandesu::CppAnonym::tag_stack_trace *] = 
","D:\Prig\Swathe\Urasandesu.Swathe\Urasandesu/Swathe/Profiling/ICorProfilerCallbackImpl.h",274,"long __stdcall CWeaverDetail::CWeaverImpl::JITCompilationStartedCore(__w64 unsigned int,int)=>Weaver.cpp,359","pModProf.IsPersisted()=>Weaver.cpp,376","(result = prigData.m_indirectables.find(mdt)) != prigData.m_indirectables.end()=>Weaver.cpp,418","Modifying method=>Weaver.cpp,424"

It seems that some IL decoding procedure is not implemented :(

`WebClient.DownloadStringTaskAsync` can't create indirection stub.

I tried to create the indirection stub of System.Net.WebClient.DownloadStringTaskAsync(System.String), but it wasn't created.

In the build log, there was an error as below:

1>------ ビルド開始: プロジェクト:ConsoleApplication23, 構成:Debug Any CPU ------
1>2014/09/13 19:32:43 にビルドを開始しました。
1>PreBuildEvent:
1>  cmd /c " "%VS120COMNTOOLS%VsDevCmd.bat" & %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -File "c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication23\packages\Prig.0.0.0-alpha7\tools\Invoke-PilotStubber.ps1" -ReferenceFrom "@('c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication23\packages\Prig.0.0.0-alpha7\lib\net40\Urasandesu.NAnonym.dll','c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication23\packages\Prig.0.0.0-alpha7\lib\net40\Urasandesu.Prig.Framework.dll')" -AssemblyFrom "C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" -TargetFrameworkVersion v4.5.1 -KeyFile "c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication23\packages\Prig.0.0.0-alpha7\tools\Urasandesu.Prig.snk" -OutputPath "c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication23\ConsoleApplication23\bin\Debug\." -Settings "c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication23\ConsoleApplication23\System.prig" "
1>  "1" 個の引数を指定して "GetSection" を呼び出し中に例外が発生しました: "prig のための構成セクション ハンドラーを作成中にエラーが発生しました。: メンバー 'DownloadStringTaskAsync' を取得できません。 (c:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication23\ConsoleApplication23\System.prig line 39)"
1>  発生場所 C:\users\akira\documents\visual studio 2013\Projects\ConsoleApplication23\packages\Prig.0.0.0-alpha7\tools\Invoke-PilotStubber.ps1:120 文字: 1
1>  + $section = $config.GetSection("prig")
1>  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1>      + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
1>      + FullyQualifiedErrorId : ConfigurationErrorsException
1>   

At the time, the indirection setting is as below:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="prig" type="Urasandesu.Prig.Framework.PilotStubberConfiguration.PrigSection, Urasandesu.Prig.Framework" />
  </configSections>
  <prig>
    <stubs>
      <add name="DownloadStringTaskAsyncString" alias="DownloadStringTaskAsyncString">
        <RuntimeMethodInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" z:Id="1" z:FactoryType="MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/System.Reflection">
          <Name z:Id="2" z:Type="System.String" z:Assembly="0" xmlns="">DownloadStringTaskAsync</Name>
          <AssemblyName z:Id="3" z:Type="System.String" z:Assembly="0" xmlns="">System</AssemblyName>
          <ClassName z:Id="4" z:Type="System.String" z:Assembly="0" xmlns="">System.Net.WebClient</ClassName>
          <Signature z:Id="5" z:Type="System.String" z:Assembly="0" xmlns="">System.Threading.Tasks.Task`1[System.String] DownloadStringTaskAsync(System.String)</Signature>
          <Signature2 z:Id="6" z:Type="System.String" z:Assembly="0" xmlns="">System.Threading.Tasks.Task`1[[System.String, mscorlib</Signature2>
          <MemberType z:Id="7" z:Type="System.Int32" z:Assembly="0" xmlns="">8</MemberType>
          <GenericArguments i:nil="true" xmlns="" />
        </RuntimeMethodInfo>
      </add>
    </stubs>
  </prig>
</configuration>

It seems that the content of the tag Signature2 is broken.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.