Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isolation Enums fail #26

Open
Tarig0 opened this issue Jun 22, 2018 · 1 comment · Fixed by Miista/pose#40
Open

Isolation Enums fail #26

Tarig0 opened this issue Jun 22, 2018 · 1 comment · Fixed by Miista/pose#40
Labels

Comments

@Tarig0
Copy link

Tarig0 commented Jun 22, 2018

The following test will not be able to pass due to the Enum.IsDefined function

shims.Add(Shim.Replace(() => DateTime.Now).With(() => new DateTime(2004, 4, 4, 11, 50, 0)));

            //act
            string actual = null;
            PoseContext.Isolate(() => {
                Enum.IsDefined(typeof(DayOfWeek), 4); // error
                actual = DateTime.Now.ToString();
            }, shims.ToArray());
Result Message:	
Test method TestMethod1 threw exception: 
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Operation is not valid due to the current state of the object.

Result StackTrace:	
at dynamic_System.Runtime.CompilerServices.JitHelpers_UnsafeCastToStackPointer(RuntimeType& )
   at stub_System.Runtime.CompilerServices.JitHelpers_UnsafeCastToStackPointer(RuntimeType& , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.Runtime.CompilerServices.JitHelpers_GetObjectHandleOnStack(RuntimeType& )
   at stub_System.Runtime.CompilerServices.JitHelpers_GetObjectHandleOnStack(RuntimeType& , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.ModuleHandle_GetModuleType(RuntimeModule )
   at stub_System.ModuleHandle_GetModuleType(RuntimeModule , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.Reflection.RuntimeModule_get_RuntimeType(RuntimeModule )
   at stub_virt_System.Reflection.RuntimeModule_get_RuntimeType(RuntimeModule , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.RuntimeType+RuntimeTypeCache_.ctor(RuntimeTypeCache , RuntimeType )
   at stub_ctor_System.RuntimeType+RuntimeTypeCache_.ctor(RuntimeType , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.RuntimeType_get_Cache(RuntimeType )
   at stub_System.RuntimeType_get_Cache(RuntimeType , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.RuntimeType_get_GenericCache(RuntimeType )
   at stub_virt_System.RuntimeType_get_GenericCache(RuntimeType , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.Enum_GetCachedValuesAndNames(RuntimeType , Boolean )
   at stub_System.Enum_GetCachedValuesAndNames(RuntimeType , Boolean , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.Enum_InternalGetValues(RuntimeType )
   at stub_System.Enum_InternalGetValues(RuntimeType , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.RuntimeType_IsEnumDefined(RuntimeType , Object )
   at stub_virt_System.Type_IsEnumDefined(Type , Object , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.Enum_IsDefined(Type , Object )
   at stub_System.Enum_IsDefined(Type , Object , RuntimeMethodHandle , RuntimeTypeHandle )
   ~~redact~~
--- End of inner exception stack trace ---
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at Pose.PoseContext.Isolate(Action entryPoint, Shim[] shims)
~~redact~~


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants