Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port System.ComponentModel.Composition (MEF1) to .NET Core #18625

Closed
dsplaisted opened this issue Sep 19, 2016 · 37 comments
Closed

Port System.ComponentModel.Composition (MEF1) to .NET Core #18625

dsplaisted opened this issue Sep 19, 2016 · 37 comments

Comments

@dsplaisted
Copy link
Member

@dsplaisted dsplaisted commented Sep 19, 2016

With the additional APIs that will be available in .NET Standard 2.0, it may be possible to make System.ComponetModel.Composition (MEF1) available for .NET Core and .NET Standard 2.0. System.Composition (MEF2) is already available, but has a different feature set which can sometimes be an obstacle to porting code to .NET Core.

@dsplaisted dsplaisted changed the title Port System.ComponentModel.Composition to .NET Core Port System.ComponentModel.Composition (MEF1) to .NET Core Sep 19, 2016
@karelz
Copy link
Member

@karelz karelz commented Nov 16, 2016

@weshaggard do you think it would be valuable, or should we just point devs to MEF2? (which already is part of .NET Core)

@weshaggard
Copy link
Member

@weshaggard weshaggard commented Nov 17, 2016

I think it really depends on the customer. For folks that are using MEF1 in there applications they might be able to move to MEF2 but it might require subtle changes in their code and likely their extensions as well. We have converted some of our own usages of MEF1 to MEF2 in our tools but we owned the host and all the extensions, however for folks that don't own all the extensions it might be a challenge to move to .NET Core. I've not personally seen anyone get blocked and need MEF1 on core yet so I think we should probably wait until there folks that need it.

cc @Petermarcu

@karelz
Copy link
Member

@karelz karelz commented Nov 18, 2016

@danmosemsft @terrajobst should we close the issue?

@terrajobst
Copy link
Member

@terrajobst terrajobst commented Nov 19, 2016

We should leave it open and mark it up for grabs. This allows folks to vote for it so we can collect feedback.

@karelz
Copy link
Member

@karelz karelz commented Nov 19, 2016

"up for grabs" issues have to be actionable for community members. The source code is not available in the open, which means internal source code access is needed.

@terrajobst
Copy link
Member

@terrajobst terrajobst commented Nov 19, 2016

MEF v1 was released as open-source. http://mef.codeplex.com. I've started the process to add it to https://github.com/microsoft/referencesource.

@danmosemsft
Copy link
Member

@danmosemsft danmosemsft commented Sep 6, 2017

If there are folks reading this who need MEFv1 on .NET Core, please thumbs up the top post and/or comment here.

@debasisj
Copy link

@debasisj debasisj commented Sep 21, 2017

my thumbs up to get it in .Net core 2.0

@ludbul
Copy link

@ludbul ludbul commented Sep 21, 2017

👍

@danmosemsft
Copy link
Member

@danmosemsft danmosemsft commented Sep 21, 2017

I've started porting the sources. Would any of you be willing to help with tests, when I have them building?
Note: if Mono has suitable ones, we can copy those. I did not look. I can also look internally for tests.

@safern
Copy link
Member

@safern safern commented Sep 21, 2017

Would any of you be willing to help with tests, when I have them building?

I would happily help.

@safern
Copy link
Member

@safern safern commented Sep 21, 2017

Obviously if there is no community willing to do so. I don’t want to still the chances to contribute :)

@mfe-
Copy link

@mfe- mfe- commented Oct 26, 2017

I can't find any official documents for MEF2.
https://mef.codeplex.com/ is the place to go(?) for MEF1, can anyone provide a good source for MEF2?

@danmosemsft
Copy link
Member

@danmosemsft danmosemsft commented Oct 26, 2017

@weshaggard where should @mfe- look?

@weshaggard
Copy link
Member

@weshaggard weshaggard commented Oct 26, 2017

I don't know of any good documentation for MEF2. You can look under https://github.com/dotnet/corefx/tree/master/src/System.Composition/ at some samples/tests in there as I suspect that might be the best we have.

@ghost
Copy link

@ghost ghost commented Nov 13, 2017

Is there anything left that was not ported in dotnet/corefx#24921 for MEF1?
Can we have a check list on remaining work?
Microsoft.Composition can be found under https://dotnet.myget.org/feed/dotnet-core/package/nuget/Microsoft.Composition which was last updated 5 months ago, where can i find nightly myget package for System.ComponentModel.Composition?
Has publishing all packages to myget feed stopped which this document promised: https://github.com/dotnet/corefx/blob/bd45cc980/Documentation/project-docs/dogfooding.md?
What's the new way to get nightlies, any announcements on the new world order?

KIS please 🙏
/end-of-confusions

@weshaggard
Copy link
Member

@weshaggard weshaggard commented Nov 13, 2017

@kasper3 the port of the library has been completed but we haven't yet started producing a nuget package for it yet. @maryamariyan can give you more information about when that will be ready.

@maryamariyan
Copy link
Member

@maryamariyan maryamariyan commented Nov 14, 2017

@kasper3 @weshaggard. We are porting the tests for System.ComponentModel.Composition and then we'll produce nuget packages. I am actively working on this.

@robooko
Copy link

@robooko robooko commented Nov 17, 2017

@maryamariyan any idea when the nuget packages will be available?

@safern
Copy link
Member

@safern safern commented Nov 17, 2017

We published a pre-release package 2 days ago into nugget.

https://www.nuget.org/packages/System.Data.Odbc/4.5.0-preview1-25914-04

Also we published Microsoft.Windows.Compatibility which depends on this package + another set of packages that ported a bunch of APIs From Full Framework.

https://www.nuget.org/packages/Microsoft.Windows.Compatibility/2.0.0-preview1-25914-04

@weshaggard
Copy link
Member

@weshaggard weshaggard commented Nov 17, 2017

@safern he is asking about System.ComponentModel.Composition. I expect once @maryamariyan finishes the testing in the next few weeks we will create the package and start publishing it to our myget feed.

@safern
Copy link
Member

@safern safern commented Nov 17, 2017

Hmmm, I misread and got confused as @maryamariyan also worked on System.Data.Odbc, sorry for the confusion.

@Petermarcu
Copy link
Member

@Petermarcu Petermarcu commented Nov 17, 2017

Any reason we can't create the package even if complete testing isn't done?

@safern
Copy link
Member

@safern safern commented Nov 17, 2017

Any reason we can't create the package even if complete testing isn't done?

@maryamariyan will be working with me on adding the packaging so that we can have a preview package in myget early next week.

maryamariyan referenced this issue in dotnet/corefx Nov 21, 2017
Fixes #11857
@safern
Copy link
Member

@safern safern commented Nov 22, 2017

We have a preview version of this package now in myget:

https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.ComponentModel.Composition

@steevcoco
Copy link

@steevcoco steevcoco commented Dec 1, 2017

I've got a basic CompositionContainer feature set working with AssemblyCatalog and DirectoryCatalog in a NetStandard 2.0 project ... So that's great for me here!

@aleksmelnikov
Copy link

@aleksmelnikov aleksmelnikov commented Feb 27, 2018

@safern
Excuse me. Are you a developer of https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.ComponentModel.Composition? I'm trying to make simple examples with the package but it fails.

@dgxhubbard
Copy link

@dgxhubbard dgxhubbard commented Mar 6, 2018

I am trying to load the package. I tried using the exact install cmd on site and got the following error.
What am I doing wrong?

Install-Package : Unable to find package System.Security.Permissions with version (>= 4.5.0-preview2-26306-04)

  • Found 6 version(s) in nuget.org [ Nearest version: 4.5.0-preview1-26216-02 ]
  • Found 0 version(s) in Microsoft Visual Studio Offline Packages
  • Found 0 version(s) in Local Packages
    At line:1 char:1
  • Install-Package System.ComponentModel.Composition -Version 4.5.0-prev ...
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : Package restore failed. Rolling back package changes for 'GtWebApi'.
At line:1 char:1

  • Install-Package System.ComponentModel.Composition -Version 4.5.0-prev ...
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    
    
@weshaggard
Copy link
Member

@weshaggard weshaggard commented Mar 7, 2018

@dgxhubbard try installing again, that package set took a while to upload and index so you might have been trying to restore it before it was fully indexed. I see the package is present now though (https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.Security.Permissions/4.5.0-preview2-26306-04).

@dgxhubbard
Copy link

@dgxhubbard dgxhubbard commented Mar 7, 2018

will do thanks

@dgxhubbard
Copy link

@dgxhubbard dgxhubbard commented Mar 7, 2018

Sorry I got the same result. Below is the command and response.

PM> Install-Package System.ComponentModel.Composition -Version 4.5.0-preview2-26306-04 -Source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Restoring packages for C:\Repository\GtNext\Source\Web\GtWebApi\GtWebApi.csproj...
GET https://api.nuget.org/v3-flatcontainer/system.security.permissions/index.json
OK https://api.nuget.org/v3-flatcontainer/system.security.permissions/index.json 287ms
Install-Package : Unable to find package System.Security.Permissions with version (>= 4.5.0-preview2-26306-04)

  • Found 6 version(s) in nuget.org [ Nearest version: 4.5.0-preview1-26216-02 ]
  • Found 0 version(s) in Microsoft Visual Studio Offline Packages
  • Found 0 version(s) in Local Packages
    At line:1 char:1
  • Install-Package System.ComponentModel.Composition -Version 4.5.0-prev ...
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : Package restore failed. Rolling back package changes for 'GtWebApi'.
At line:1 char:1

  • Install-Package System.ComponentModel.Composition -Version 4.5.0-prev ...
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Time Elapsed: 00:00:02.4345331

@weshaggard
Copy link
Member

@weshaggard weshaggard commented Mar 7, 2018

It doesn't look like it is even trying to use "https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" as a source. Can you add that to your package sources in VS and try again?

@ghost
Copy link

@ghost ghost commented Mar 7, 2018

@dgxhubbard, in csproj, you can also add:

<PropertyGroup>
  <RestoreAdditionalProjectSources>https://dotnet.myget.org/F/dotnet-core/api/v3/index.json</RestoreAdditionalProjectSources>
  <!-- from https://github.com/NuGet/Home/wiki/%5BSpec%5D-NuGet-settings-in-MSBuild#project-properties -->
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="System.ComponentModel.Composition" Version="4.5.0-*" />
</ItemGroup>

then dotnet restore, nuget restore or msbuild /restore (msbuild v15.3+, nuget 4.3+).

@dgxhubbard
Copy link

@dgxhubbard dgxhubbard commented Mar 8, 2018

Thanks adding "https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" as a source to vs worked.

@CZEMacLeod
Copy link

@CZEMacLeod CZEMacLeod commented Apr 18, 2018

Hi All. Thanks for the snipped @kasper3 - Very useful for me.
What I am currently struggling with now is that System.ComponentModel.Composition.Registration does not seem to have a package available for it and is not included in the System.ComponentModel.Composition package.

The specific types I need are

  • System.ComponentModel.Composition.Registration.RegistrationBuilder
  • System.ComponentModel.Composition.Registration.PartBuilder
  • System.ComponentModel.Composition.Registration.PartBuilder<>

I am also struggling in the same bit of code with a reference to System.Reflection.Context.CustomReflectionContext which appears to be in System.Reflection.Context.dll for net461 and the System.Reflection.Context NuGet package does not include a framework reference for .NETFramework4.5 - as least in the release package 4.3.0. I can work around this one for now with conditional references in my project file, but it shouldn't be needed.

I don't know if I should raise new issues for these items, or whether here under a request for MEF1 in .NETCore / .NETStandard is the best place. (Note: My goal is to be able to migrate an application currently targeting net461 with over 100 projects / modules / plugins to either target multiple platforms or target netstandard2.0)
Some of the newer parts of the platform do use MEF2, which I believe has better support cross-platform but I don't have the resources at the moment to migrate the older MEF1 code as suggested earlier in the thread.

@weshaggard
Copy link
Member

@weshaggard weshaggard commented Apr 25, 2018

@CZEMacLeod If you are interested in RegistrationBuilder APIs I suggest filing a new issue tracking it.

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.