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

Move DependencyModel to libraries #34296

Merged
merged 11 commits into from
Apr 4, 2020
Merged

Conversation

eerhardt
Copy link
Member

@eerhardt eerhardt commented Mar 30, 2020

Moving DependencyModel to the same folder and infrastructure as the rest of our libraries, and out of the installer folder.

I also dropped support for building live anything below netstandard2.0 so we don't need to reference Newtonsoft. The lower TFMs are harvested from the previously shipped package.

Contributes to #3470
Fix #3425

@eerhardt eerhardt requested review from ericstj, joperezr and safern March 30, 2020 20:41
@Dotnet-GitSync-Bot
Copy link
Collaborator

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@eerhardt
Copy link
Member Author

error:

C:\Users\eerhardt\.nuget\packages\microsoft.dotnet.genfacades\5.0.0-beta.20171.1\build\Microsoft.DotNet.GenPartialFacadeSource.targets(30,5):
error : The type 'System.Collections.Generic.CollectionExtensions' is defined in multiple seed assemblies.
The multiple assemblies are Microsoft.Extensions.DependencyModel.dll, System.Collections.dll. If this is intentional, specify the alias for this type and project reference 
[F:\git\runtime\src\libraries\shims\generated\netstandard.csproj]

This is unfortunate that we shipped this API already. Would this be OK to make a breaking change in 5.0 for this assembly? We are already making other breaking changes -

  • dropping support for net451, netstandard1.x
  • In 3.0, we accidentally shipped an unintentional public type in this assembly:

<Compile Include="..\Microsoft.DotNet.PlatformAbstractions\HashCodeCombiner.cs" />

However, this would be a binary and potentially source breaking change to change CollectionExtensions, but I think it might be worth it going forward.

Thoughts - @ericstj @joperezr @safern ?

@ericstj
Copy link
Member

ericstj commented Mar 31, 2020

We found a similar bug in other extensions libraries #33998. Since its just extension methods that folks aren't going to directly reference it's not a terrible type conflict. I'd just suppress the error for now and file a bug. If folks have a scenario for using the two types and notice the clash we can address it.

<!-- Type duplicated: https://github.com/dotnet/runtime/issues/33998 -->
<IgnoredTypes Include="Microsoft.Extensions.Logging.LoggingBuilderExtensions" />

HashCodeCombiner

What do you suggest? Removing is breaking, we could obsolete it and/or implement on top of System.HashCode?

<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.0" />
<PackageReference Include="FluentAssertions" Version="4.19.4" />
<PackageReference Include="Moq" Version="$(MoqVersion)" />
<PackageReference Include="Microsoft.DotNet.ProjectModel" Version="1.0.0-rc2-002702" />
Copy link
Member

Choose a reason for hiding this comment

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

@safern do you think that the versions of these packages should live in Versions.props?

Copy link
Member Author

Choose a reason for hiding this comment

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

Both Microsoft.DotNet.InternalAbstractions and Microsoft.DotNet.ProjectModel are obsolete packages (think project.json and .xproj time frame). The issue is our unit tests are written relying on these old packages, and we never took the time to rewrite the tests. But we don't want to lose the test coverage.

These versions will never be updated, so I didn't think we would want them in a global/central place.

FluentAssertions is different - this version could get updated in the future. However since no other test in src\libraries appears to use this package, my hope is we can remove this dependency in the future.

Copy link
Member

Choose a reason for hiding this comment

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

I think it is fine to keep them here. Maybe FluentAssertions as you mention might be good to move it, but since you intend to remove it, I don't have an strong opinion.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we intend to use FluentAssertions more in the repo? If we wanted to use it more, then I'd be OK with moving it. But I was thinking we didn't want to use it (since no one uses it today).

Copy link
Member

Choose a reason for hiding this comment

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

My impression is that we don't want to - as it's inconsistent with what we've been doing (amongst some other reasons). if we want to, we should have a discussion first and achieve consensus.

@joperezr
Copy link
Member

joperezr commented Apr 1, 2020

Left a few comments but this Looks good in general.

eerhardt added 4 commits April 1, 2020 17:21
Moving DependencyModel to the same folder and infrastructure as the rest of our libraries, and out of the installer folder.

I also dropped support for anything below netstandard2.0 at this time.

Contributes to dotnet#3470
Fix dotnet#3425
@eerhardt eerhardt force-pushed the MoveDependencyModel branch from 63f665d to 2e20e8b Compare April 1, 2020 23:46
Also, clean up references to the old DependencyModel project.
@eerhardt
Copy link
Member Author

eerhardt commented Apr 2, 2020

Since its just extension methods that folks aren't going to directly reference it's not a terrible type conflict. I'd just suppress the error for now and file a bug. If folks have a scenario for using the two types and notice the clash we can address it.

Done - #34420

HashCodeCombiner

What do you suggest? Removing is breaking, we could obsolete it and/or implement on top of System.HashCode?

My suggestion is to make the breaking change in 5.0 (which I've done in this PR). It was just added in 3.0 (mistakenly since it was a shared source file, and the type is public), and if anyone is using it, they shouldn't be. Also, if they were using it - it would collide with the same type in PlatformAbstractions. So I think we can make this small break, so we don't have to worry about it going forward.

eerhardt added 3 commits April 2, 2020 10:33
This also means we start building DependencyModel for net461 to ensure full framework support works correctly, and doesn't pick up the old net451 asset.
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

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

NIT: technically since you are not shipping the ref in the package and the API surface is not changing between netstandard2.0 and net461, it should be fine to only keep the netstandard2.0 configuration in this project if you wanted.

<ReferencePath
Include="$(RefPath)*.dll"
Exclude="$(RefPath)$(MSBuildProjectName).dll;$(RefPath)netstandard.dll" />
Exclude="$(RefPath)$(MSBuildProjectName).dll;$(RefPath)netstandard.dll;$(RefPath)Microsoft.Extensions.DependencyModel.dll" />
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we be able to just prefer one of the seed types so that we can still generate the shims using this dependency? I'm actually not too familiar with this so if @ericstj suggested this that's fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not aware of a better fix here. If there is one, I'd be happy to change this.

Honestly, I'm not sure why we are passing Microsoft.Extensions.* libraries in here at all.

Copy link
Member

Choose a reason for hiding this comment

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

We pass in the whole RefPath (line 17 above) if you think it would make sense to remove all of these that would be fine. Basically the idea of this shims are so that if some library tries to load types that have been moved into these Microsoft.Extensions* packages for core, that we redirect the types correctly.

Copy link
Member

Choose a reason for hiding this comment

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

You could, however I'm not sure how much value that has. We don't intent for any Micrsoft.Extensions assemblies to satisfy .NETFramework nor .NETStandard surface area, so I am fine omitting them.

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.

Left a couple of small questions, but this looks good to me otherwise. Thanks @eerhardt

@eerhardt eerhardt merged commit b93829c into dotnet:master Apr 4, 2020
@eerhardt eerhardt deleted the MoveDependencyModel branch April 4, 2020 01:47
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
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.

Should M.E.DependencyModel only target netstandard2.0+ going forward?
7 participants