Giter Club home page Giter Club logo

Comments (3)

mity1982 avatar mity1982 commented on September 3, 2024

My proposal for fixing the issue.
Add new interception strategy
Interceptor.cs

        private IEnumerable<IInterceptStrategy> InterceptionStrategies()
        {
            yield return new HandleDestructor();
            yield return new HandleTracking();
            yield return new InterceptMockPropertyMixin();
            yield return new InterceptToStringMixin();
                        yield return new InterceptMissingValuesProperties();
            yield return new AddActualInvocation();
            yield return new ExtractProxyCall();
            yield return new ExecuteCall();
            yield return new InvokeBase();
            yield return new HandleMockRecursion();
        }

InterceptorStrategies.cs

    internal class InterceptMissingValuesProperties : IInterceptStrategy
    {
        public InterceptionAction HandleIntercept(ICallContext invocation, InterceptorContext ctx, CurrentInterceptContext localctx)
        {

            for (int i = 0; i < invocation.Arguments.Length; i++)
            {
                if (invocation.Arguments[i] == System.Reflection.Missing.Value)
                invocation.SetArgumentValue(i,null);
            }

            return InterceptionAction.Continue;
        }
    }

My setup code

xrm.Setup(f => f.Range(It.IsAny<string>,null)).Returns(new Func<object, object, Excel.Range>(RangeReturnFunction))

tested, works

only issue - i have to add null in setup in the place of optional argument. That is because if i don't moq will create constant matcher for "System.Reflection.Missing" which i relpace with null.

from moq4.

stakx avatar stakx commented on September 3, 2024

Hi @mity1982, I was going to look into this, but I can't actually get your repro code to compile (on VS 2015, referencing Moq 4.7.63 and Microsoft.Office.Interop.Excel version 15). The compiler won't allow access to property f.Range as if it were a method. Also, the compiler forbids omitting optional arguments (in an expression tree).

If you are still interested in having this issue looked at, could you please provide an updated repro code that compiles without errors?

from moq4.

stakx avatar stakx commented on September 3, 2024

Closing this due to inactivity. If you still want to have this looked into, just reply with repro code and we can reopen this issue.

from moq4.

Related Issues (20)

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.