Skip to content

API Compat fixes - #9254

Merged
ViktorHofer merged 3 commits into
dotnet:mainfrom
ericstj:apiComaptCoreAssm
May 4, 2022
Merged

ViktorHofer merged 3 commits into
dotnet:mainfrom
ericstj:apiComaptCoreAssm

Conversation

@ericstj

@ericstj ericstj commented May 3, 2022

Copy link
Copy Markdown
Member

This addresses two problems with API compat. Fixes dotnet/runtime#68699

The first issue is that the task would never fail the build, even when it had errors. This happened due to the task refactoring where it lost functionality provided by the exec task which would change the error code to -1 if the task logged errors but otherwise returned 0. I just copied that from ToolTask:
https://github.com/dotnet/msbuild/blob/10dbde3bf1986251a5e958af8c7391ad0d9e7f11/src/Utilities/ToolTask.cs#L761-L765

The second issue is that the task failed when consuming the System.Runtime facade and running on .NETFramework. Details are in the linked issue. I considered actually looking for the System.Object typeforward and following that but resolving TypeForwards in CCI actually requires this same code-path, which caused this to be re-entrant. I was able to workaround that by capturing state to determine when the method was re-entrant but that complicated the solution. Instead I chose to go with a simpler heuristic -> just push down into the references of the assembly. This will eventually find an assembly that defines System.Object.

There is the chance that this hits a cycle. For example if someone had a System.Runtime facade with all typeforwards to mscorlib and an mscorlib with all typeforwards to System.Runtime. Previously we'd just bail from this loop and fallback to corelib used by CCI (since CCI didn't understand full facades). I didn't hit this in my testing but I can't abide leaving it since anyone hitting it would see a hang, so I also added a check for this and preserved the old behavior.

ericstj added 3 commits May 2, 2022 12:36
We should never hit this, but the behavior before was to iterate forever.
Now it will break and assume the default behavior.
@ericstj
ericstj requested review from a team and ViktorHofer May 3, 2022 19:36
@ericstj

ericstj commented May 3, 2022

Copy link
Copy Markdown
Member Author

I have tested this change in dotnet/runtime. build libs and build libs -allConfigurations still work correctly. VS no longer exhibits the problems described in dotnet/runtime#68699. I can also force an API compat issue and that will fail the build.

@ViktorHofer
ViktorHofer merged commit 635482d into dotnet:main May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ApiCompat errors when building System.Runtime inside Visual Studio

3 participants