Please also see: https://github.com/iwhp/Mef1-vs-Mef2-CycleComposition
MEF1
Im MEF1 it is possible to have a cycling reference between two components (see ClassA and ClassB), even if the components are non-shared ([PartCreationPolicy(CreationPolicy.NonShared)]).
This is possible by using Lazy
public Lazy<ClassB> ClassB { get; set; }
MEF2
Im MEF2 this is not working.
Is there a work-around?
@iwhp does this reproduce on .NET Framework? This repo is for .NET Core.
cc @weshaggard
IIRC this is by design because of the way MEF2 composes the graph but it it has been a long time since I've looked into the code. I will say it was never our intention that MEF2 be 100% compatible with MEF1 which is why we implemented it as a separate package in a separate namespace. MEF2 isn't exactly an upgrade from MEF1 it is an alternative framework with focus on throughput instead of large application composition. I'd suggest you stick with MEF1 if it is serving your needs.
Thankx, weshaggard!
I am in the process to move our projects to .NET CORE. And I believe there is no .NET CORE support planed for MEF1, maybe I am wrong.
A) Could you make a statement about .NET CORE and MEF1?
B) Could you imagine that this issue maybe solved by the end of this year for MEF2?
C) If no .NET CORE support is available for MEF1 and this issue will not be solved with MEF2, which library would you suggest for IOC and DIP with .NET CORE support?
Many thankx, Harry
MEF1 is supported on .NET Core see https://github.com/dotnet/corefx/tree/master/src/System.ComponentModel.Composition. You might need to add a reference to the package https://www.nuget.org/packages/System.ComponentModel.Composition/.
As for whether or not this issue will get fixed in MEF2, I'm no longer on this team but from what I remember I don't think there is any good way to fix that within that framework so I suspect it will not get fixed.
We don't have any plans to do new feature work in MEF2 (or MEF1).
@danmosemsft - thankx for the information.
Maybe it would be helpful to clearly state that to the community (roadmap).
Also, if one likes to use MEF, when to use MEF1 and when MEF2, and when to use other libraries.
If you would have suggestions for other libraries to use, that what certainly help the community (readme.md).
Thankx for all your work, support and communication!
@iwhp that's a good idea. I will try to gather some information as part of readme so it becomes clear.
Most helpful comment
MEF1 is supported on .NET Core see https://github.com/dotnet/corefx/tree/master/src/System.ComponentModel.Composition. You might need to add a reference to the package https://www.nuget.org/packages/System.ComponentModel.Composition/.
As for whether or not this issue will get fixed in MEF2, I'm no longer on this team but from what I remember I don't think there is any good way to fix that within that framework so I suspect it will not get fixed.