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

[X] Simplify XamlServiceProvider setup code generated by XamlC when invoking markup extensions #19650

Closed
simonrozsival opened this issue Jan 2, 2024 · 2 comments · Fixed by #19945
Assignees
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-9.0.0-preview.2.10247 fixed-in-9.0.0-preview.2.10293 t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.)

Comments

@simonrozsival
Copy link
Member

The IL generated by XamlC to prepare an instance of XamlServiceProvider for a call to IMarkupExtension.ProvideValue often contains unnecessary services. For example, the generated code creates a new instance of XamlTypeResolver whenever we call ConstraintExpression, DynamicResourceExtension, ReferenceExtension, or StaticResourceExtension, but none of these extensions uses it.

We already have the [AcceptEmptyServiceProvider] attribute to optimize the service provider for some extensions. We could add a new attribute [RequiredService(typeof(IXmlLineInfoProvider))] which would be used by XamlC to prepare only the services which are actually needed.

/cc @StephaneDelcroix

@simonrozsival simonrozsival added the area-xaml XAML, CSS, Triggers, Behaviors label Jan 2, 2024
@StephaneDelcroix StephaneDelcroix self-assigned this Jan 12, 2024
@StephaneDelcroix
Copy link
Contributor

we should also warn if a converter doesn't have any attribute

@StephaneDelcroix StephaneDelcroix added the area-perf Startup / Runtime performance label Jan 16, 2024
StephaneDelcroix added a commit that referenced this issue Jan 17, 2024
MarkupExtensions, ValueProviders and some TypeConverters require a
serviceProvider. Only add the services that are actually required. This
will reduce IL size, time to JIT, number of allocations, ...

Also add a warning when users do not attribute their MarkupExctensions

- fixes #19650
github-actions bot pushed a commit that referenced this issue Jan 19, 2024
MarkupExtensions, ValueProviders and some TypeConverters require a
serviceProvider. Only add the services that are actually required. This
will reduce IL size, time to JIT, number of allocations, ...

Also add a warning when users do not attribute their MarkupExctensions

- fixes #19650
StephaneDelcroix added a commit that referenced this issue Jan 19, 2024
MarkupExtensions, ValueProviders and some TypeConverters require a
serviceProvider. Only add the services that are actually required. This
will reduce IL size, time to JIT, number of allocations, ...

Also add a warning when users do not attribute their MarkupExctensions

- fixes #19650
github-actions bot pushed a commit that referenced this issue Feb 12, 2024
MarkupExtensions, ValueProviders and some TypeConverters require a
serviceProvider. Only add the services that are actually required. This
will reduce IL size, time to JIT, number of allocations, ...

Also add a warning when users do not attribute their MarkupExctensions

- fixes #19650
StephaneDelcroix added a commit that referenced this issue Feb 13, 2024
MarkupExtensions, ValueProviders and some TypeConverters require a
serviceProvider. Only add the services that are actually required. This
will reduce IL size, time to JIT, number of allocations, ...

Also add a warning when users do not attribute their MarkupExctensions

- fixes #19650
StephaneDelcroix added a commit that referenced this issue Feb 14, 2024
MarkupExtensions, ValueProviders and some TypeConverters require a
serviceProvider. Only add the services that are actually required. This
will reduce IL size, time to JIT, number of allocations, ...

Also add a warning when users do not attribute their MarkupExctensions

- fixes #19650
@simonrozsival
Copy link
Member Author

Implementation merged into net9.0

@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2024
@Eilon Eilon added t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) and removed area-perf Startup / Runtime performance labels May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-9.0.0-preview.2.10247 fixed-in-9.0.0-preview.2.10293 t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants