Resolving types not working during code cleanup

I'm tyring to write a simple code cleanup, I've looked and based it off the SamplePlugin in the SDK (C:\Program Files (x86)\JetBrains\ReSharper\v7.1\SDK\Samples\SamplePlugin\SamplePlugin\src\CodeCleanup), specifically file UseIntConstantsInsteadOfLiterals.

I can see the file being parsed and I can see it call the action to process the IExpressions (in reverse order for an assignment etc).

When I try to resolve the reference of an invoked expression to obtain an instance of IMethod it appears to fail with INCORRECT_PARAMETER_TYPE, it doesn't fail for all method only some.

resolve issue 01.png
I'm attempting to cleanup the following code, as you can see I've added the R# metadata ('{caret}') to the test data - specifically it is failing to resolve 'Merge' back to a method.

        public IObservable<int> Method()
        {
            return new List<int> {1, 2, 3}
                .ToObservable(_testScheduler)
                .Timeout(TimeSpan.FromSeconds(10))
                .Select(GenerateNumbers)
                .Merge();{caret}
        }




All the third party libraries have been loaded for the test using the TestReferences attribute & ExtraAssemblyResolveFoldersCookie method in a base test class so I know they are available for resolution.

I'm trying to extract the method using the following code:

            try
            {
                var invokedExpression = expression.InvokedExpression as IReferenceExpression;
                if (invokedExpression == null)
                {
                    return false;
                }


                var resolveResult = invokedExpression.Reference.Resolve();
                method = resolveResult.DeclaredElement as IMethod;


                return method != null;
            }
            catch (Exception exn)
            {
                Debug.WriteLine(exn);
                return false;
            }


Does anyone know why it is failing to resolve?


ta

Ollie
1 comment
Comment actions Permalink

Solve the problem, the simple answer is I forgot to explicitly add the [TestNetFramework45] or [TestNetFramework4] attribute to the test fixture class.

Once this was added then the IType could be resolved.


ta

Ollie

0

Please sign in to leave a comment.