2

I'm using Autofac (I've registered the base nuget package in a console app) and want to take a look at a list of registrations.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autofac;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            // First, create your application-level defaults using a standard
            // ContainerBuilder, just as you are used to.
            var builder = new ContainerBuilder();
            var appContainer = builder.Build();


            appContainer.ComponentRegistry.Registrations.Where(x => true);
        }
    }
}

The problem is the line

appContainer.ComponentRegistry.Registrations.Where(x => true);

Here intellisense is not giving me the Where linq method however it does compile as far as I can tell without any warnings, errors in messages.

I tried this further down

   IEnumerable<string> list = new List<string>();

    list.Where(x => true);

And intellisense is working correctly and giving me all the standard list methods.

I've tried this in a few different apps from scratch and I'm getting the same behaviour.

Any ideas as to whats going on?

EDIT:

The following works and shows correctly in intellisense

IEnumerable<IComponentRegistration> test = new List<IComponentRegistration>();
            test.Where(x => true);

I'm using

<package id="Autofac" version="3.0.1" targetFramework="net45" /> from nuget.

and hovering over the ComponentRegistrations gives enter image description here

and in this case scope is defined as

  ILifetimeScope _scope;

However I get the same thing if i try directly off this

 var builder = new ContainerBuilder();
 var appContainer = builder.Build();
 appContainer.ComponentRegistry.Registrations.Where(x => true);

Also IComponentRegistry is defined as (in Autofac)

public interface IComponentRegistry : IDisposable
{
    ...
    IEnumerable<IComponentRegistration> Registrations { get; }
    ...
}
Daniel Powell
  • 8,143
  • 11
  • 61
  • 108
  • I've had someone else try this as well and they have the same issue – Daniel Powell Feb 21 '13 at 01:16
  • I've also uploaded a demo that shows the intellisense not working https://dl.dropbox.com/u/78170732/ConsoleApplication1.zip – Daniel Powell Feb 21 '13 at 01:30
  • If I've understood you correctly and your problem is that intellisense isn't working on the line appContainer.ComponentRegistry.Registrations.Where(x => true); You should probably try and disable your addons and see if that takes care of it as it's working fine for me. Since you say you had someone else confirm it, maybe start with any addons that your installations have in common. – Peter Karlsson Feb 21 '13 at 06:03
  • 1
    I also do remember some problems with intellisense dropping completely in VS2012, usually resolved by a restart of VS. But it wasn't selective in the way you seem to be describing. – Peter Karlsson Feb 21 '13 at 06:05
  • http://youtrack.jetbrains.com/issue/RSRP-339056 for future reference – Daniel Powell Feb 21 '13 at 11:38

2 Answers2

0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autofac;

namespace ConsoleApplication2
{
  class Program
   {
    static void Main(string[] args)
    {
        // First, create your application-level defaults using a standard
        // ContainerBuilder, just as you are used to.
        var builder = new ContainerBuilder();
        var appContainer = builder.Build();


        var registrations = appContainer.ComponentRegistry.Registrations.Where(x => x.Target.Equals("test"));
    }
 }
}

Try assigning the linq expression to a variable and see if it works

Sandesh
  • 2,966
  • 1
  • 20
  • 34
0

Comment copied to answer.

If I've understood you correctly and your problem is that intellisense isn't working on the line

appContainer.ComponentRegistry.Registrations.Where(x => true); 

You should probably try and disable your addons and see if that takes care of it as it's working fine for me. Since you say you had someone else confirm it, maybe start with any addons that your installations have in common.

Peter Karlsson
  • 1,170
  • 7
  • 15