This project has moved and is read-only. For the latest updates, please go here.

Will there be support for Method imports with > 4 args?

Jan 15, 2009 at 12:36 PM
Right now method imports are limited to 4 or fewer arguments AFAIKT, because of the Action<> and Func<> delegate type declarations.  Are there any plans to add support for importing methods with > 4 arguments?

Jan 15, 2009 at 2:58 PM
Yeah the current limitation exists because of the number of arguments you can use in Action<> and Func<>. Could you provide some code to illustrate how you would like for it to work with >4 arguments? I'm developing a custom model for the framework and could look in to adding this functionality.
Jan 15, 2009 at 5:16 PM
Yes, additional Action<> and Func<> versions are being added in .NET 4.0, (I think I saw a version with 15 type parameters), we'll support as many parameters as they support.
Jan 15, 2009 at 5:19 PM
Here is a brief example of what I want to do:

NOTE: I realize that there are many approaches to repackaging the parameters to make them fit into 4 arguments, however, I need to support legacy functions where I can't change the signature of the function and right now I have one function with 11 arguments.  I can easily import them as Delegates as what I need to do with them requires subsequent processing to integrate them into the program. 

namespace MEFFunctionSpike
    class Program
        public static object ImportantFunction(string s1, int i1, double d1, string s2, int i2, double d2, string s3, int i3, double d3)
            // do something important here - typicly this would be in an external assembly
            // perhaps not even written by the same team.
            return null;

        static void Main(string[] args)
            Program p = new Program();

        private IList<Delegate> _functions;

        public IList<Delegate> Functions
            get { return _functions; }
            set { _functions = value; }

        public void Run()

        private void Compose()
            var catalog = new AggregatingComposablePartCatalog();
            catalog.Catalogs.Add(new AttributedAssemblyPartCatalog(Assembly.GetExecutingAssembly()));
            catalog.Catalogs.Add(new DirectoryPartCatalog("Libraries"));
            var container = new CompositionContainer(catalog);
Jan 15, 2009 at 9:55 PM
Eventhough I'm not on the MEF team (gimme a job got damit! hehe), I'm confident to say that MEF will be migrated to the NET4 codebase before it's realease. There are comments in the source code that indicate this and the fact that VS2010 will be using MEF adds further proof. Now if this means that they will add support for extended delegate types I do not know. What I do know is that it's literally a 2 minute job for someone on the team to do it (just add the new types to the arrays they use internally) so its highly unlikely that they wont do it - My prediction is; MEF will support the new delegate types in NET 4.0
Jan 15, 2009 at 11:18 PM
I'm on the MEF team, and as mentioned above, we'll eventually support whatever .NET 4.0 supports.
Jan 15, 2009 at 11:20 PM
Whoops! Completly missed your reply up there :)