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

[XC] Compile StaticResource when possible #20917

Merged
merged 1 commit into from
Sep 27, 2024
Merged

[XC] Compile StaticResource when possible #20917

merged 1 commit into from
Sep 27, 2024

Conversation

StephaneDelcroix
Copy link
Contributor

@StephaneDelcroix StephaneDelcroix commented Feb 29, 2024

Description of Change

when a resource can be compiled locally, do it.

Issues Fixed

@StephaneDelcroix StephaneDelcroix requested a review from a team as a code owner February 29, 2024 14:06
@jsuarezruiz jsuarezruiz added the area-xaml XAML, CSS, Triggers, Behaviors label Feb 29, 2024
Comment on lines +140 to +153
var staticResourceExtensionType = module.ImportReference(context.Cache,
("Microsoft.Maui.Controls.Xaml", "Microsoft.Maui.Controls.Xaml", "StaticResourceExtension"));
yield return Create(Newobj, module.ImportCtorReference(context.Cache,
staticResourceExtensionType,
paramCount: 0));

SetPropertiesVisitor.TryGetPropertyName(node, node.Parent, out var propertyName);
var localName = propertyName.LocalName;

//Set the Key
var keyProperty = staticResourceExtensionType.GetProperty(context.Cache, pd => pd.Name == "Key", out _);
yield return Create(Dup);
yield return Create(Ldstr, key);
yield return Create(Callvirt, module.ImportReference(keyProperty.SetMethod));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is creating a duplicate StaticResourceExtension instance, this is what I see in decompiled code:

staticResourceExtension.Key = "Primary";
StaticResourceExtension obj = new StaticResourceExtension
{
    Key = "Primary"
};

Could we reuse the original StaticResourceExtension instance instead of creating a new one?

@samhouts samhouts added the stale Indicates a stale issue/pr and will be closed soon label Aug 29, 2024
when a resource can be compiled locally, do it.

TODO: convert OnPlatform
TODO: walk up DataTemplates

- fixes #20244
@rmarinho rmarinho merged commit 5bf94a9 into main Sep 27, 2024
97 checks passed
@rmarinho rmarinho deleted the fix_20244 branch September 27, 2024 12:56
rmarinho pushed a commit that referenced this pull request Sep 30, 2024
when a resource can be compiled locally, do it.

TODO: convert OnPlatform
TODO: walk up DataTemplates

- fixes #20244
@samhouts samhouts added fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-net8.0-nightly This may be available in a nightly release! labels Oct 1, 2024
@samhouts samhouts added fixed-in-9.0.0-rc.2.24503.2 fixed-in-net8.0-nightly This may be available in a nightly release! fixed-in-net9.0-nightly This may be available in a nightly release! and removed fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-net8.0-nightly This may be available in a nightly release! labels Oct 14, 2024
@PureWeen PureWeen added this to the .NET 9 SR1 milestone Oct 20, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Nov 20, 2024
@samhouts samhouts added fixed-in-9.0.12 and removed fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-net8.0-nightly This may be available in a nightly release! labels Dec 16, 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-rc.2.24503.2 fixed-in-9.0.12 stale Indicates a stale issue/pr and will be closed soon
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Grid layout breaks in build target='Release' when ColumnDefinitions defined via StaticResource
6 participants