Skip to content
This repository was archived by the owner on Sep 13, 2022. It is now read-only.

Add shims to netstandard2.1 for types that used to have OOB packages#1180

Merged
wtgodbe merged 8 commits intodotnet:masterfrom
wtgodbe:Shimalimadingdong
May 15, 2019
Merged

Add shims to netstandard2.1 for types that used to have OOB packages#1180
wtgodbe merged 8 commits intodotnet:masterfrom
wtgodbe:Shimalimadingdong

Conversation

@wtgodbe
Copy link
Copy Markdown
Member

@wtgodbe wtgodbe commented May 8, 2019

Resolves https://github.com/dotnet/corefx/issues/36719 & #1063. These TypeForward files were generated with GenApi, using the netstandard2.0 assets from the packages I added to netstandard.depproj.

Still to do:

@ericstj @terrajobst PTAL

CC @bartonjs

@wtgodbe wtgodbe changed the title Shimalimadingdong Add shims to netstandard2.1 for types that used to have OOB packages May 8, 2019
@wtgodbe wtgodbe requested review from ericstj and terrajobst May 8, 2019 22:11
@@ -1,13 +1,25 @@
Compat issues with assembly System.Memory:
CannotRemoveAttribute : Attribute 'Microsoft.Cci.DummyTypeReference' exists on 'System.Memory<T>' in the contract but not the implementation.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This looks like there are type resolution errors. Are those expected?

@wtgodbe
Copy link
Copy Markdown
Member Author

wtgodbe commented May 9, 2019

@ericstj this should be ready for review now, PTAL when you get the chance. Thanks for all the help!

@wtgodbe wtgodbe closed this May 9, 2019
@wtgodbe wtgodbe reopened this May 9, 2019
@ericstj
Copy link
Copy Markdown
Member

ericstj commented May 13, 2019

Nice branch name

<RestoreOutputPath>$(IntermediateOutputPath)$(TargetFramework)\</RestoreOutputPath>
<ProjectAssetsFile>$(RestoreOutputPath)/project.assets.json</ProjectAssetsFile>
<MSBuildProjectExtensionsPath>$(RestoreOutputPath)</MSBuildProjectExtensionsPath>
<_InitialMSBuildProjectExtensionsPath>$(MSBuildProjectExtensionsPath)</_InitialMSBuildProjectExtensionsPath>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you still need this hack? Makes me nervous we are using the internal property.

Copy link
Copy Markdown
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 sure how else to get around the issue, we do need to get the targets file imported for netstandard.library.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the reason we did this hack was due to order of import / targetframework definition. I believe you could find a different order of defining properties that would get this set eariler (if you move some things into Directory.Build.props). Alternatively you could just ignore the targets and manually include the items. I'd prefer either of those approaches over using the private property (I know we spent some time figuring this out but we shouldn't sink ourselves in the fragile solution because of that).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I just pushed a commit that resolves the NetStandard.Library assets explicitly & removes this workaround

Compat issues with assembly System.Xml.ReaderWriter:
CannotRemoveAttribute : Attribute 'System.ComponentModel.EditorBrowsableAttribute' exists on 'System.Xml.Schema.XmlSchema' in the contract but not the implementation.
Total Issues: 9
Compat issues with assembly System.Memory:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What are these diffs about?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm guessing these are real errors, which we weren't seeing before since we just added System.Memory to the contract

Copy link
Copy Markdown
Member

@ericstj ericstj May 14, 2019

Choose a reason for hiding this comment

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

Does that mean we broke the API surface System.Memory previously exposed to netstandard2.0 consumers? That'd be a bad issue and should be addressed by adding that surface area to netstandard2.1, or producing a new version of System.Memory that is non breaking. I don't think that's what is happening, but we need to have an understanding and not guess. We should be filing issues if we introduce baselines that imply breaking changes. @terrajobst

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks like that's the case, these members (e.g. TryGetMemoryManager) exist in the Ref in CoreFx but aren't defined in the Standard (https://github.com/dotnet/corefx/blob/1f9b84a0804e868c7e0f37a3c10fbaf7c735ae14/src/System.Memory/ref/System.Memory.cs#L471). @terrajobst what's the best way for us to add these in Standard?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please open an issue and make sure these are tracked for ns2.1.

</PackageReference>
</ItemGroup>

<Target Name="ResolveNetStandardLibraryAssets"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a comment?

Copy link
Copy Markdown
Member

@ericstj ericstj left a comment

Choose a reason for hiding this comment

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

Thanks for following up on my suggestions.

Compat issues with assembly netstandard:
TypeCannotChangeClassification : Type 'System.RuntimeArgumentHandle' is a 'ref struct' in the implementation but is a 'struct' in the contract.
TypeCannotChangeClassification : Type 'System.TypedReference' is a 'ref struct' in the implementation but is a 'struct' in the contract.
CannotSealType : Type 'System.ComponentModel.BaseNumberConverter' is effectively (has a private constructor) sealed in the implementation but not sealed in the contract.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It may be worth adding functionality to APICompat so that we can produce a baseline file that doesn't have these duplicate entries (in this case, one each for netstandard, system, and System.ComponentModel). We could separate the concept of baseline files (like this one) with dev-friendly baseline files (without the duplicates). APICompat reads the former, and writes both.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NETStandard2.0 libraries referencing types absorbed into NETStandard2.1 cannot be used in NS2.1

4 participants