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

[Bug]: Core version of RAR fails to read WinRT runtime version from assemblies #8731

Closed
ladipro opened this issue May 4, 2023 · 0 comments · Fixed by #8752
Closed

[Bug]: Core version of RAR fails to read WinRT runtime version from assemblies #8731

ladipro opened this issue May 4, 2023 · 0 comments · Fixed by #8752

Comments

@ladipro
Copy link
Member

ladipro commented May 4, 2023

Issue Description

The non-Framework / non-Windows implementation of RAR has a bug where it incorrectly assumes that the metadata version - referred to as "runtime version" in the code - has to start with 'v'. Metadata version of WinRT files looks like WindowsRuntime 1.4 or WindowsRuntime 1.4;CLR v4.0.30319.

Steps to Reproduce

Create a WinRT component using the Windows Runtime Component template in VS and add it as a reference to a .NET project. Build the project.

Expected Behavior

image

Actual Behavior

image

Analysis

Here's the bug:

// Read the version string
var v = Encoding.UTF8.GetString(sr.ReadBytes(length));
if (v.Length < 2 || v[0] != 'v')
{
return string.Empty;
}

It's not clear what the downstream effect is. Since .winmd's cannot be referenced by modern .NET projects anyway - the build errors out in the CheckForUnsupportedWinMDReferences task - it is possible that this part of Core RAR may be deleted.

Versions & Configurations

MSBuild version 17.6.0-preview-23174-01+e7de13307 for .NET

@ladipro ladipro added bug needs-triage Have yet to determine what bucket this goes in. labels May 4, 2023
@AR-May AR-May removed the needs-triage Have yet to determine what bucket this goes in. label May 9, 2023
@ladipro ladipro self-assigned this May 11, 2023
@ladipro ladipro added the size:1 label May 16, 2023
JaynieBai pushed a commit that referenced this issue May 18, 2023
Fixes #8731

Context
The .NET Core version of MSBuild has its own metadata reader implementation and GetRuntimeVersion contains checks that are stricter than what the full Framework implementation does. Specifically, it allows only "version-like" runtime versions, which makes it fail to read the version of WinRT assemblies.

Changes Made
Removed the incorrect checks.

Testing
New unit test.
Verified that referencing a WinRT assembly now makes RAR produce the right output.
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants