-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
VisualTypeConverter loops over all assemblies looking for IVisual types #4937
Comments
@PureWeen is this done? can this be closed now? I see a PR linked that was closed but not merged. |
@Redth not yet The solution for this changed once we decided to move a bunch of stuff around between |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 1.0. Can repro with provided repro steps in terminal. |
Fixed by #20417 |
Description
We are getting trimmer warnings here:
The issue is that the
VisualTypeConverter
looks at all the assemblies in the process looking for types that implementIVisual
:maui/src/Controls/src/Core/Visuals/VisualTypeConverter.cs
Lines 27 to 38 in 5d8b798
maui/src/Controls/src/Core/Visuals/VisualTypeConverter.cs
Lines 68 to 77 in 5d8b798
This is not trim-safe, since Types that are not referenced by IL can be trimmed by the trimmer. But in the converter code, it takes a
string
object and then tries looking up in the "registered mapping" for theIVisual
by the string name. This can break trimmed apps because the Type being referenced by that string may have been trimmed.In talking with @Redth and @PureWeen this approach is out-of-date, and we should remove the assembly scanning. Instead, we should add a "trim-compatible" method for doing this registration. For example:
builder.RegisterVisual<TVisual>()
method that people can add to theirCreateMauiApp()
method. This will register the Visual type statically, and the Types that aren't referenced can be safely trimmed.Steps to Reproduce
dotnet new maui
dotnet restore
dotnet build -f net6.0-android -r android-arm64 -t:Run -c Release --no-restore -p:SuppressTrimAnalysisWarnings=false -p:TrimmerSingleWarn=false /bl
VisualTypeConverter
.Version with bug
Unknown/Other (please specify)
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android
Affected platform versions
All
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: