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

Use TypeSystem.String instead of typeof(string) when resolving types from Cecil #11363

Merged
merged 1 commit into from
May 14, 2023

Conversation

maxkatz6
Copy link
Member

How was the solution implemented (if it's not obvious)?

  1. typeof(string) returns RuntimeType defined in System.Private.CoreLib.
  2. System.Private.CoreLib is used from the build runtime version, i.e. 7.0.
  3. It's getting included in the built assembly with the same version.
  4. Avoiding typeof helps to avoid System.Private.CoreLib completely.

TIL, to not use typeof with cecil.

Fixed issues

Fixes #10859

@maxkatz6 maxkatz6 enabled auto-merge May 14, 2023 05:32
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0034696-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue May 14, 2023
Merged via the queue into master with commit 515391f May 14, 2023
5 checks passed
@maxkatz6 maxkatz6 deleted the fix-unnecessary-corelib-reference branch May 14, 2023 06:33
@robloo
Copy link
Contributor

robloo commented May 14, 2023

This is a really good find! Still not sure how typeof(string) is resolving the way it is though. Very interesting

@maxkatz6
Copy link
Member Author

@robloo in short, Cecil used runtime reflection to resolve and import type instead of looking into assemblies known at compile time. Quite a known problem there apparently jbevain/cecil#895

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[11.0.0-preview5+] Can't debug in VSCode on .NET 6
4 participants