Open Sergio0694 opened 11 hours ago
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas See info in area-owners.md if you want to be subscribed.
Tagging subscribers to this area: @dotnet/illink See info in area-owners.md if you want to be subscribed.
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas See info in area-owners.md if you want to be subscribed.
Tagging subscribers to this area: @dotnet/illink See info in area-owners.md if you want to be subscribed.
Making ILLink/ILC also trim branches just comparing the fully qualified type name
Since anyone can have their own System.Type descendants that may return anything as their ToString or FullName, we'd need guarantees that this is the real deal (RuntimeType). So it would have to be something like someInstance.GetType().FullName
(it cannot be a System.Type that we obtained from who-knows-where). Would such restriction work?
Making ILLink/ILC support this via some magic intrinsic (eg. GetType() == Type.GetType("The.Type.Name")
We'd probably not want to introduce patterns that only perform well when rewritten. I wonder if it would be feasible to introduce an UnsafeAccessor that can do the equivalent for Type.GetType at compile time (e.g. [UnsafeAccessor(Kind.Type, Name = "The.Type.Name, Assembly")] extern Type GetTheType();
- runtime magic would rewrite this to a method that returns a typeof
basically)
Overview
This is a follow up to #102248 which primarily affects CsWinRT. In order to support marshalling types we don't own (meaning we cannot attach a vtable to them via an attribute), the AOT generators in CsWinRT also generate a global lookup table with all necessary vtables for types it has seen as possibly used across the ABI boundary, in a given project. This looks something like this:
This works just fine, but we noticed the linker isn't able to remove all branches for types that are not constructed.
Repro steps
Console.WriteLine(new MyViewModel());
public sealed partial class MyViewModel : ObservableObject { }