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 OnIdiom #21799

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

[XC] compile OnIdiom #21799

wants to merge 1 commit into from

Conversation

StephaneDelcroix
Copy link
Contributor

Description of Change

Compile OnIdiom markup extension. Doing that we can infer the type of the ProvidedValue instead of using Object

Issues Fixed

Compile OnIdiom markup extension. Doing that we can infer the type of
the ProvidedValue instead of using Object

- fixes #18697
@StephaneDelcroix
Copy link
Contributor Author

as draft for now. have to look at what happen with valuetypes, and think about sending warning if the different idiom types doesn't match

@jsuarezruiz jsuarezruiz added the area-xaml XAML, CSS, Triggers, Behaviors label Apr 16, 2024
methodName: "op_Equality",
parameterTypes: new[] { ("Microsoft.Maui.Essentials", "Microsoft.Maui.Devices", "DeviceIdiom"), ("Microsoft.Maui.Essentials", "Microsoft.Maui.Devices", "DeviceIdiom") },
isStatic: true)));
instructions.Add(Create(Brfalse, instr_getDefault));
Copy link
Member

Choose a reason for hiding this comment

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

Is this correct? Wouldn't this jump to the getDefault branch if the first idiom doesn't match the idiom, effectively skipping over all the other cases?

Comment on lines +42 to +47
var idiomTypeRef = (idiom.Value as IElementNode).XmlType.GetTypeReference(context.Cache, module, node as IXmlLineInfo);
if (TypeRefComparer.Instance.Compare(memberRef, idiomTypeRef) != 0)
{
//should this issue a warning?
memberRef = module.TypeSystem.Object;
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm worried this comparison is too strict, especially when comparing ints and doubles (e.g., Phone=0, Tablet=2.5). Would it be possible to try to find the "lowest common denominator" between all the types instead of immediately fall back to object?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Windows] [RC2] Conditional ToolbarItem Text Display Using OnIdiom Not Working in Release Mode
3 participants