Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Adding missing typeforward for Lazy<T,TMetadata> to S.CM.Composition #27337

Merged
merged 8 commits into from
Feb 23, 2018

Conversation

maryamariyan
Copy link
Member

Adding missing typeforward for Lazy<T,TMetadata> to System.ComponentModel.Composition

Fixes #27299

@maryamariyan
Copy link
Member Author

This PR needs work. This wouldn't work for netfx.

@@ -5,6 +5,8 @@
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------

[assembly: System.Runtime.CompilerServices.TypeForwardedTo(destination: typeof(System.Lazy<,>))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are going to need to #ifdef this and include it only for netcoreapp, and for the other configurations you will need to include the API for Lazy<T,M> in the ref.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @weshaggard

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry your comment about netfx through me off but after looking at the configurations more closely you don't need to #ifdef this you should always have the type-forward here.

As for the netfx build issue you need to fix it by adding a "_netfx" configuration in the src project for this library. However when you do that you will start having test failures because of https://github.com/dotnet/corefx/issues/25781 so you can either tackle that issue now or temporarily add a "_netfx" placeholder configuration in the test project as well.

@weshaggard
Copy link
Member

While looking at the pkgproj I also noticed https://github.com/dotnet/corefx/blob/master/src/System.ComponentModel.Composition/pkg/System.ComponentModel.Composition.pkgproj#L13,L15 which isn't necessary and should be removed.

Copy link
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming you'll add the _netfx configurations to src and tests as we discussed offline this LGTM.

@weshaggard
Copy link
Member

Looks like the binary serialization tests are failing to find the assembly. We many need to make some tweaks to those tests to fix them when running on netfx. @ViktorHofer any ideas on how those tests look for the assembly?

@ViktorHofer
Copy link
Member

ViktorHofer commented Feb 22, 2018

The following two exceptions types are causing the FileNotFoundException:

  • CompositionContractMismatchException
  • ImportCardinalityMismatchException

both from System.ComponentModel.Composition. The test isn't doing anything fancy. I can repro the issue just by calling the ctor of one of the types:

[Fact]
public void X()
{
    var exception = new Exception();
    var x = new System.ComponentModel.Composition.CompositionContractMismatchException("message", exception);
}

In my environment there is no System.ComponentModel.Composition.dll in ~\git\corefx2\bin\runtime\netfx-Windows_NT-Debug-x64.

Building the project with netfx results in the following error:

~:\git\corefx2\src\System.ComponentModel.Composition\src>msbuild /t:Rebuild /v:m /p:TargetGroup=netfx
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

~\git\corefx2\Tools\ApiCompat.targets(56,5): error : TypesMustExist : Type 'System.Lazy<T, TMetadata>' does not exist
in the implementation but it does exist in the contract. [~\git\corefx2\src\System.ComponentModel.Composition\src\Syst
em.ComponentModel.Composition.csproj]
~\git\corefx2\Tools\ApiCompat.targets(70,5): error : ApiCompat failed for '~\git\corefx2\bin\AnyOS.AnyCPU.Debug\Syste
m.ComponentModel.Composition\netstandard\System.ComponentModel.Composition.dll' [~\git\corefx2\src\System.ComponentMod
el.Composition\src\System.ComponentModel.Composition.csproj]

@joperezr
Copy link
Member

In my environment there is no System.ComponentModel.Composition.dll

This is expected since what we are doing in this change is stop producing it. That is what the _netfx Configuration does.

Building the project with netfx results in the following error:

Again, this is expected, that is why we intentionally want to skip the build of this project on the netfx configuration.

@ViktorHofer shouldn't your tests pick up the System.ComponentModel.Composition.dll on the GAC for netfx?

@weshaggard
Copy link
Member

There are a couple of issues with this change I'm making some tweaks locally and will push them once I validate.

@ViktorHofer
Copy link
Member

If you need me to step in again, just ping me.

@weshaggard
Copy link
Member

Thanks @ViktorHofer I've fixed the serialization tests. I'm just investigating the apicompat issues in all configurations.

@maryamariyan
Copy link
Member Author

Thanks @weshaggard and @ViktorHofer.

@weshaggard
Copy link
Member

@maryamariyan I pushed a few commits which should fix some these issues.

@weshaggard
Copy link
Member

We still seem to be hitting some kind of apicompat issue. I didn't hit it on my rebuild locally but I'm trying a clean build to see if I can repro it.

@weshaggard
Copy link
Member

OK I pushed a new commit as I believe I found the reason the netstandard configuration wasn't building correctly.

Since this assembly identity should match what is in
.NET Framework we should use the ECMA key for it.
We don't want to bin-place System.ComponentModel.Composition
from the Netstandard.Library package becasue we build it ourselves
and we need it to be built as part of our all configurations build.

While we could overwrite it in the output there are some logic
in resolving contracts that prevent the correct configurations to
be built when it is already present so we need to make sure the
wrong one is no longer in the output.
<ExcludeNetStandardRefs Include="System.ComponentModel.Composition" />
<NetStandardRefs
Include="$(_NETStandardRefFolder)\*.dll"
Exclude="@(ExcludeNetStandardRefs -> '$(_NETStandardRefFolder)\%(Identity).dll')" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wes couldn't you have just done

<Reference Include="@(NetStandardRefs)" Condition="'%(Identity)' != 'System.ComponentModel.Composition'">

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but that doesn't scale as nicely if we need to add more to the list.

We are building a newer version of System.ComponentModel.Composition
in our live builds and we need to exclude it from the netcorepp2.0
targeting pack otherwise we end up with the wrong one for our build.
@weshaggard
Copy link
Member

Pushed one more change to fix the all configurations build for netcoreapp2.0.

@weshaggard
Copy link
Member

test Alpine.3.6 x64 Debug Build
test OSX x64 Debug Build

@weshaggard weshaggard merged commit a188af6 into dotnet:master Feb 23, 2018
@maryamariyan maryamariyan deleted the typeforward-lazy branch March 6, 2018 00:50
@karelz karelz added this to the 2.1.0 milestone Mar 10, 2018
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…lazy

Adding missing typeforward for Lazy<T,TMetadata> to S.CM.Composition

Commit migrated from dotnet/corefx@a188af6
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants