-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
AssemblyName.ProcessorArchitecture no longer returns the correct result #77697
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
cc @VSadov |
Related discussion in #74040 |
I do not think that this was intentional behavior change. We should be able to make it return what it returned before if it is important. @VSadov ?
The target support has to stay in compiler for as long the compiler targets .NET Framework. Compiler targeting is superfluous in .NET Core. It was replaced by RID targeting. Use of compiler targeting in .NET Core only leads to problems. For example, see warning that we have added in dotnet/sdk#27776 .
Note that the code fragment that you have linked won't work well for .NET Framework Arm64 targeting. The only way to make it work well for .NET Framework Arm64 targeting is to switch to reading PE header Machine architecture directly. |
no, I think this should be fixed for compat reasons. |
Will keep this open to track backporting to 7.0 |
@VSadov looks like the backporting to 7.0 didn't happen. Can we close it as 8.0 now? |
Yes, since 7.0 is out of support, I think this is no longer actionable. |
Description
Starting in .NET 7.0 AssemblyName.ProcessorArchitecture is not correct.
Build tools like ResolveAssemblyReferences in MSBuild used this to determine if an application was referencing an assembly for a different architecture than what it targeted. https://github.com/dotnet/msbuild/blob/3777dcaf7edb3e86a070037ba53e742dd1872873/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs#L2578-L2599 cc @rainersigwald
I noticed that starting with .NET 7.0 MSBuild stopped warning in this case. I was able to trace it down to #63915 which moved the AssemblyName.GetAssemblyName implementation to use the one in System.Reflection.Metadata
runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/MetadataReader.netstandard.cs
Lines 14 to 45 in 3dbc850
That version never set ProcessorArchitecture, for whatever reason, but it could. So that might be the fix for this if we want to fix it.
@jkotas you obsoleted this member in #59061. Given what you said about this, should we also proceed with obsoleting the PlatformTarget support in the compiler and references as well? If not, shouldn't we bring back this part of AssemblyName since our tools support building assemblies with it, and using it?
Reproduction Steps
Run attached project.
archConsole.zip
Expected behavior
It emits
Amd64
for both thenet6.0
andnet7.0
builds.Actual behavior
It emits
Amd64
for thenet6.0
build andNone
for thenet7.0
build.Regression?
Yes, from .NET 6.0
Known Workarounds
Calculate the ProcessorArchitecture of the assembly yourself? This would imply we find all the places in the dotnet tooling (like MSBuild or the compiler) that might use this property and fix them to avoid this regression.
Configuration
.NET 7.0 RC2, x64
Other information
No response
The text was updated successfully, but these errors were encountered: