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

Conversation

@joperezr
Copy link
Member

cc: @weshaggard @atsushikan @joshfree

Initial configuration work for System.Reflection.Emit in order to unblock the work of writing a netsandard 2.0 implementation of the library. @atsushikan will work on top of this changes in order to actually provide the implementation later.

@joperezr joperezr requested review from a user, ericstj and weshaggard June 28, 2018 21:10
@ghost
Copy link

ghost commented Jun 28, 2018

I think we concluded we need to give System.Reflection.Emit.Lightweight.dll the same treatment?

@joperezr
Copy link
Member Author

Right, I'll add that too.

protected override bool IsPointerImpl() { throw null; }
protected override bool IsPrimitiveImpl() { throw null; }
#if !TargetsNetstandard
public override bool IsByRefLike { get { throw null; } }
Copy link

Choose a reason for hiding this comment

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

Non-blocking comment: These could be declared in the s.r.e.netstandard.cs file rather than using #if?

Other than that, looks plausible to me though Wes will have do to review all the config/msbuild stuff.

Copy link
Member

Choose a reason for hiding this comment

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

Yes given the number of #ifdef's you should move them to another file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

lgtm but Wes or Eric will have to review the config/msbuild stuff.

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{4FBD1556-7B96-414E-9EA4-85281956D60E}</ProjectGuid>
<DefineConstants Condition="'$(TargetGroup)' == 'netstandard'">$(DefineConstants);TargetsNetstandard</DefineConstants>
Copy link
Member

Choose a reason for hiding this comment

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

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'll take care of this.

<BuildConfigurations>
netcoreapp;
uap;
netstandard;
Copy link
Member

Choose a reason for hiding this comment

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

You'll need a netfx configuration for all of these that typeforwards so that you don't have duplicate types.

Copy link
Member

Choose a reason for hiding this comment

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

This assembly exists inbox on .NET Framework already so I think the placeholder configuration is correct but we should validate that the contract is valid which would happen in the shim apicompat run (which I think are currently manual).

Copy link
Member

Choose a reason for hiding this comment

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

May not be the same version here so you may need to dial the assembly version of the netstandard ref back.

Copy link
Member Author

Choose a reason for hiding this comment

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

For now the real intention was to unblock @atsushikan for his implementation changes, so I just added the placeholder one for netfx for now so that the build would pass. If we decide we need a runtime facade instead, then I can change that later.

<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<SkipValidatePackage>true</SkipValidatePackage>
Copy link
Member

Choose a reason for hiding this comment

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

Curious what validation errors you came up with. I would imagine that getting the shape of the package correct is the goal of this PR and that's what validation checks.

Copy link
Member Author

Choose a reason for hiding this comment

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

mm a bunch of errors where due to not harvesting the old package contents but validation seeing it so noticing that we dropped support of a bunch of TFMs. The goal of this PR is not really to have a working package, but instead to unblock NS2.0 development for these libraries. I was planning to deal with packaging later.

Copy link
Member Author

Choose a reason for hiding this comment

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

With my latest set of changes I have the pkgproj working and almost passing validation. The last piece failing validation is:

F:\git\corefx\Tools\Packaging.targets(1131,5): error : System.Reflection.Emit should be supported on .NETStandard,Version=v1.1 but has no runtime assets. [F:\git\corefx\src\System.Reflection.Emit\pkg\System.Reflection.Emit.pkgproj]
F:\git\corefx\Tools\Packaging.targets(1131,5): error : System.Reflection.Emit should be supported on .NETStandard,Version=v1.2 but has no runtime assets. [F:\git\corefx\src\System.Reflection.Emit\pkg\System.Reflection.Emit.pkgproj]

And that makes sense, it is caused because in the latest package (4.3.0) we have a ref for netstandard1.1, but have an implementation for netstandard1.3. I guess that in order for these errors to go away, I would have to add a cross compilation of the assembly on netstandard1.1 which would be a turd assembly as well. I'm curious as to why did we ever shipped a package like that which seems pretty broken to me.

Copy link
Member

Choose a reason for hiding this comment

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

That requirement was a new one we started following in 2.0. Before that we relied on NuGet doing ref/lib matching to reject the package if it had a ref with no lib. NuGet ended up removing that check and relying on ref with no lib as a valid encoding for shared framework.

We should add that not-supported assembly for ns1.1. We should also double check if the ns1.3 impl should be moved to netcoreapp / uap (for instance if it is forwarding to our corelib).

<ReferenceFromRuntime Include="System.Private.CoreLib" />
</ItemGroup>
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<!-- TODO: Add NS2.0 implementation here -->
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the plan to have this be a "PNSE" generated assembly?

@@ -0,0 +1,13 @@
Compat issues with assembly System.Reflection.Emit:
TypesMustExist : Type 'System.Reflection.Emit.AssemblyBuilder' does not exist in the implementation but it does exist in the contract.
Copy link
Member

Choose a reason for hiding this comment

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

What configuration is this baseline file needed for?

Copy link
Member Author

Choose a reason for hiding this comment

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

it was for netstandard, sorry I didn't add it to the file name, I'll fix that.

<ItemGroup Condition="'$(IsPartialFacadeAssembly)' == 'true'">
<ReferenceFromRuntime Include="System.Private.CoreLib" />
</ItemGroup>
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
Copy link
Member

Choose a reason for hiding this comment

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

Generate a PNSE assembly

Copy link
Member Author

Choose a reason for hiding this comment

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

But the idea here is that @atsushikan will provide the implementation, If I understood correctly these won't be turd assemblies but ones with actual implementation.

Copy link
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.

Why placeholders for Netfx? Are you sure you don’t need a newer facade? Please doublecheck package content and targeting pack.

<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<GenFacadesIgnoreMissingTypes Condition="'$(TargetGroup)'=='uapaot'">true</GenFacadesIgnoreMissingTypes>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' != 'netstandard'">true</IsPartialFacadeAssembly>
<GenFacadesIgnoreMissingTypes Condition="'$(TargetGroup)'=='uapaot' And '$(IsPartialFacadeAssembly)' != 'true'">true</GenFacadesIgnoreMissingTypes>
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to keep the $(TargetGroup)'=='uapaot' condition here and in other files? Should I have deleted this in #30472?

@joperezr
Copy link
Member Author

The failing test on Windows Nano is not related to my PR.

<IsPartialFacadeAssembly Condition="'$(TargetGroup)' != 'netstandard'">true</IsPartialFacadeAssembly>
<GenFacadesIgnoreMissingTypes Condition="'$(TargetGroup)'=='uapaot' And '$(IsPartialFacadeAssembly)' == 'true'">true</GenFacadesIgnoreMissingTypes>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetGroup)' == 'netstandard'">SR.PlatformNotSupported_RefEmitILGeneration</GeneratePlatformNotSupportedAssemblyMessage>
<ProjectGuid>{8F05FFD6-6697-41CA-B733-709F5A6D3BF1}</ProjectGuid>
Copy link
Member

Choose a reason for hiding this comment

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

The resx should be conditioned so that we don't add resources to the partial facade.

@ericstj
Copy link
Member

ericstj commented Jul 2, 2018

This is still missing PKGProjs for Reflection.Emit.ILGeneration and Reflection.Emit.Lightweight.

These packages all needed the following workarounds:
1. Matching not-supported implementation assemblies for netstandard1.x
2. Not support implementation for AOT frameworks
3. Ensure we don't add API to old frameworks (eg: UAP10.0.16299, desktop) or frameworks compatible with those (netstandard2).
@ericstj
Copy link
Member

ericstj commented Jul 3, 2018

Test Windows x64 Debug Build

@ericstj
Copy link
Member

ericstj commented Jul 3, 2018

@weshaggard please have a look

public virtual void Emit(System.Reflection.Emit.OpCode opcode, System.Type cls) { }
public virtual void EmitCall(System.Reflection.Emit.OpCode opcode, System.Reflection.MethodInfo methodInfo, System.Type[] optionalParameterTypes) { }
public virtual void EmitCalli(System.Reflection.Emit.OpCode opcode, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[] parameterTypes, System.Type[] optionalParameterTypes) { }
public virtual void EmitCalli(System.Reflection.Emit.OpCode opcode, System.Runtime.InteropServices.CallingConvention unmanagedCallConv, Type returnType, Type[] parameterTypes) { }
Copy link
Member

Choose a reason for hiding this comment

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

Why was this API removed?

Copy link
Member

Choose a reason for hiding this comment

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

It was moved into a netcore-specific file since it wasn't present in all frameworks that support netstandard2.0 (eg: nca2.0, uwp)
https://github.com/dotnet/corefx/pull/30741/files/7eb9a5f89446dbb4aa97fa2d3575cca8fe5bae87#diff-17fa736219e2458643a24ea213deb9e4

<PropertyGroup>
<PackageConfigurations>
netstandard;
netstandard1.0;
Copy link
Member

Choose a reason for hiding this comment

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

Aren't you harvesting netstandard1.0?

Copy link
Member

Choose a reason for hiding this comment

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

Not for source, we need a not-supported assembly.

<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion Condition="'$(TargetsNetStandard)' == 'true'">4.0.0.0</AssemblyVersion>
Copy link
Member

Choose a reason for hiding this comment

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

Might be worth a comment saying this needs to match .NET Framework.

<PackageDestination Include="lib/netstandard1.1">
<TargetFramework>netstandard1.1</TargetFramework>
</PackageDestination>
<PackageDestination Include="runtimes/aot/lib/netcore50">
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this getting harvested?

Copy link
Member

Choose a reason for hiding this comment

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

No, we need a not-supported assembly. We didn't have one in the package previously, we used a placeholder (relying on the old NuGet gaurdrails feature).

Copy link
Member

@weshaggard weshaggard left a comment

Choose a reason for hiding this comment

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

LGTM

@ghost ghost merged commit 1e72f59 into dotnet:master Jul 3, 2018
@ericstj
Copy link
Member

ericstj commented Jul 3, 2018

Thanks for merging @atsushikan.

You may still want to tweak this a bit in your work.

For instance the old netcoreapp1.x impl is still in the nestandard1.3 folder in the package: we may want to move that to netcoreapp1.0.

Also the UWP-non-aot implementations are inbetween the core surface area and the netstandard surface area. In the past we never shipped a reference for this dll to UAP, but did have the implementation. In the latest UWP that even had the netcore-version (4.1.x) so I kept the core versions. Since then, some API has been exposed from CoreLib. This wasn't present in UWP-version-last, so I left it out of that reference assembly, but it is present in the latest UWP reference. Ideally we might want to stop shipping the UWP dlls in this package so that we don't have to keep bloating the package with version-specific references and version-specific implementations which forward to private assemblies. That's what we do for netcoreapp: we just have a placeholder and let the framework package provide it. The downside of that is we expose Ref.Emit to UWP customers even though it won't work for AOT.

@karelz karelz added this to the 3.0 milestone Jul 8, 2018
@joperezr joperezr deleted the RefEmitNS20 branch November 2, 2018 20:09
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…nst netstandard2.0 (dotnet/corefx#30741)

* Configuration changes so that System.Reflection.Emit may compile against
netstandard2.0

* Adding NS2.0 config for System.Reflection.Emit.Lightweight

* Fixing netfx vertical

* Addressing PR Feedback

* Fixing mscorlib facade generation now that there are a few type
conflicts

* Add back Ref.Emit packages

These packages all needed the following workarounds:
1. Matching not-supported implementation assemblies for netstandard1.x
2. Not support implementation for AOT frameworks
3. Ensure we don't add API to old frameworks (eg: UAP10.0.16299, desktop) or frameworks compatible with those (netstandard2).


Commit migrated from dotnet/corefx@1e72f59
This pull request was closed.
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.

5 participants