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

Make .NET Framework and .NET Standard facade changes trackable #65997

Closed
ViktorHofer opened this issue Mar 1, 2022 · 4 comments · Fixed by #79147
Closed

Make .NET Framework and .NET Standard facade changes trackable #65997

ViktorHofer opened this issue Mar 1, 2022 · 4 comments · Fixed by #79147

Comments

@ViktorHofer
Copy link
Member

ViktorHofer commented Mar 1, 2022

GenFacade is a tool that inspects a contract assembly's public API surface safe area, compares it with a passed in assembly closure and emits a C# source file with type forwards in it so that the satisfied API can be forwarded from the contract to the "implementation". GenFacades is used to construct the .NETFramework and the .NETStandard shim assemblies which live under src/libraries/shims/.

The generated source file isn't checked into the tree, it's placed into the project's intermediate output path. IMO it would help if we check these files into the tree so that any changes that impact shims - intentional or unintentional - are trackable. As an example, I just recently refactored how the shims are structured under src/libraries/shims and unintentionally removed a type forward from an assembly. I only noticed this regression by pure luck later.

The priority of this issue just rose because source build plans to remove their .NET Framework reference assembly packages during the .NET 8 release. That means that we can't automatically generate the type forwards during source-build. I will work on removing the dependency and check the type forwards in instead.

@dotnet/area-infrastructure-libraries @ericstj

@ghost
Copy link

ghost commented Mar 1, 2022

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

Issue Details

GenFacade is a tool that inspects the satisfied and unsatisfied public API surface safe area based on a contract assembly and a passed in assembly closure. GenFacades is used to construct the .NETFramework and the .NETStandard shim assemblies which live under src/libraries/shims/.

The generated source file isn't checked into the tree, it's placed into the project's intermediate output path. IMO it would help if we check these files into the tree so that any changes that impact shims - intentional or unintentional - are trackable. As an example, I just recently refactored how the shims are structured under src/libraries/shims and unintentionally removed a type forward from an assembly. I only noticed this regression by pure luck later.

Additionally, adding the generated type-forward files to the tree would make it possible to construct the shims during the "libs.sfx" subset and later then, when the closure to compute the type forwards is complete during the "libs.oob" subset, invoke GenFacades to make sure that the generated files are up-to-date.

@dotnet/area-infrastructure-libraries @ericstj

Author: ViktorHofer
Assignees: -
Labels:

area-Infrastructure-libraries

Milestone: -

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Mar 1, 2022
@ViktorHofer ViktorHofer added this to the Future milestone Apr 19, 2022
@ViktorHofer ViktorHofer removed the untriaged New issue has not been triaged by the area owner label Apr 19, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Dec 2, 2022
@ViktorHofer
Copy link
Member Author

The priority of this issue just rose because source build plans to remove their .NET Framework reference assembly packages during the .NET 8 release. That means that we can't automatically generate the type forwards during source-build. I will work on removing the dependency and check the type forwards in instead.

cc @NikolaMilosavljevic @MichaelSimons

@ViktorHofer ViktorHofer modified the milestones: Future, 8.0.0 Mar 27, 2023
ViktorHofer added a commit to ViktorHofer/runtime that referenced this issue Mar 27, 2023
Fixes dotnet#65997

GenFacade is a tool that inspects a contract assembly's public API surface safe area, compares it with a passed in assembly closure and emits a C# source file with type forwards in it so that the satisfied API can be forwarded from the contract to the "implementation". GenFacades is used to construct the .NETFramework and the .NETStandard shim assemblies which live under src/libraries/shims/.

The generated source file isn't checked into the tree, it's placed into the project's intermediate output path. IMO it would help if we check these files into the tree so that any changes that impact shims - intentional or unintentional - are trackable. As an example, I just recently refactored how the shims are structured under src/libraries/shims and unintentionally removed a type forward from an assembly. I only noticed this regression by pure luck later.

The priority of this issue just rose because source build plans to remove their .NET Framework reference assembly packages during the .NET 8 release. That means that we can't automatically generate the type forwards during source-build. I will work on removing the dependency and check the type forwards in instead.
@carlossanlop
Copy link
Member

@ViktorHofer for my own education, would you mind telling me why the last sentence was struck through? Why does this not apply anymore?

Additionally, adding the generated type-forward files to the tree would make it possible to construct the shims during the "libs.sfx" subset and later then, when the closure to compute the type forwards is complete during the "libs.oob" subset, invoke GenFacades to make sure that the generated files are up-to-date.

@ViktorHofer
Copy link
Member Author

Checking in the type forwards avoids calculating them at build time but you still need a resolvable target type that is pointed to, i.e. System.Text.RegularExpressions.dll for typeof(System.Text.RegularExpressions.Regex) (which lives in System.dll in .NET Framework).

I previously was under the impression that we can compile these type forwards without having the target type assemblies available which isn't true.

@ghost ghost added in-pr There is an active PR which will close this issue when it is merged and removed in-pr There is an active PR which will close this issue when it is merged labels Mar 28, 2023
ViktorHofer added a commit that referenced this issue Mar 28, 2023
…g targeting packs (#79147)

* Make .NET Framework and .NET Standard facade changes trackable

Fixes #65997

GenFacade is a tool that inspects a contract assembly's public API surface safe area, compares it with a passed in assembly closure and emits a C# source file with type forwards in it so that the satisfied API can be forwarded from the contract to the "implementation". GenFacades is used to construct the .NETFramework and the .NETStandard shim assemblies which live under src/libraries/shims/.

The generated source file isn't checked into the tree, it's placed into the project's intermediate output path. IMO it would help if we check these files into the tree so that any changes that impact shims - intentional or unintentional - are trackable. As an example, I just recently refactored how the shims are structured under src/libraries/shims and unintentionally removed a type forward from an assembly. I only noticed this regression by pure luck later.

The priority of this issue just rose because source build plans to remove their .NET Framework reference assembly packages during the .NET 8 release. That means that we can't automatically generate the type forwards during source-build. I will work on removing the dependency and check the type forwards in instead.

* Make shim projects declare the dependencies explicitly

Also remove the System.Xml special runtime project which isn't necessary
anymore as the compiler now allows type forwards to Obsolete types with
error=true.

* System.Core build fix

* Remove unused file

* Revert "Remove unused file"

This reverts commit 2f5d410.

* Add README and fix GenFacades zero version logic
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 28, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Apr 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants