-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add transitive CompilerServices.Unsafe dependency #41616
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
Conversation
for System.Memory and System.Threading.Tasks.Extensions package references. Adding the dependency as a P2P to prefer the live asset over the prebuilt.
|
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
| <ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Configuration.FileExtensions\ref\Microsoft.Extensions.Configuration.FileExtensions.csproj" /> | ||
| <ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Configuration\ref\Microsoft.Extensions.Configuration.csproj" /> | ||
| <ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.FileProviders.Abstractions\ref\Microsoft.Extensions.FileProviders.Abstractions.csproj" /> | ||
| <ProjectReference Include="$(LibrariesProjectRoot)System.CompilerServices.Unsafe\ref\System.CompilerServices.Unsafe.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised to see Unsafe show up in reference assemblies. I didn't think it had any exchange types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it looks like all these paths are wrong since they omitted Runtime from System.Runtime.CompilerServices.Unsafe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised to see Unsafe show up in reference assemblies. I didn't think it had any exchange types.
I'm unsure what you mean by that. It's coming in as a transitive dependency from System.Memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsure what you mean by that
I don't think any reference assembly in repo should ever have a reference to System.Runtime.CompilerServices.Unsafe since it contains a single static type which will never appear in any other assembly's surface area.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I add a PackageReference to System.Memory or System.Threading.Tasks.Extensions, the reference to System.Runtime.CompilerServices.Unsafe is added transitively. This is already happening in master today. How would I express that a PackageReference should not pass its dependency to the compiler?
|
Looks System.Diagnostics.DiagnosticSource.Tests on.NETFramework are encountering legit failures: |
|
It looks for S.R.CompilerServices.Unsafe 4.0.4.1 which is in the 4.5.3 version of the package. We put the 5.0.0 asset into the output directory and no binding redirects are present, hence the TypeLoadException. @ericstj if we want to use the live asset we need the binding redirect, right? |
Correct. It may also be indicative of a problem our customers might encounter with the package, since that also references latest Unsafe: https://www.nuget.org/packages/System.Diagnostics.DiagnosticSource/5.0.0-preview.8.20407.11 Have a look at the test's RAR run to ensure that it sees both System.Memory with Unsafe reference and the direct reference to the live Unsafe dll. |
|
The binding redirect isn't generated because of runtime/eng/references.targets Lines 3 to 4 in 2ba6515
When I changed our references and RefPath I considered removing that variable but I wasn't entirely sure what it is for. Good that I now know its intent. |
|
I suspect that flag was there to ensure refpath + simple-name references was always WYSIWYG. You might try checking after removing it that we still force libraries to declare their reference closure and they don't automatically get transitive references because RAR sees them. If there's a problem consider a condition on that flag and only apply it in cases where we are forcing granular references. |
|
The only difference that I can tell is that RAR finds the dependencies and stores them in the |
|
If the flag doesn’t impact references nor copy local I am fine removing. Glad to eliminate private property usage. |
ericstj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm assuming green ci
for System.Memory and System.Threading.Tasks.Extensions package
references. Adding the dependency as a P2P to prefer the live asset
over the prebuilt.
Fixes #40208
I attempted to automate this but didn't find a viable solution that would cover all cases. We can revisit this to add protection later.