Fix "XamlC error: key was not present in the dictionary" when `OnIdiom` is used in… (#24367)
* Fix "key was not present in the dictionary" when `OnIdiom` is used in `OnPlatform` * Add test --------- Co-authored-by: Mike Corsaro <mikecorsaro@microsoft.com>
This commit is contained in:
Родитель
11aa1bdaf0
Коммит
9020670806
|
@ -650,12 +650,19 @@ namespace Microsoft.Maui.Controls.Build.Tasks
|
|||
yield return Create(Ldtoken, module.ImportReference(context.Cache, ("Microsoft.Maui.Controls", "Microsoft.Maui.Controls.Xaml", "IProvideValueTarget")));
|
||||
yield return Create(Call, module.ImportMethodReference(context.Cache, ("mscorlib", "System", "Type"), methodName: "GetTypeFromHandle", parameterTypes: new[] { ("mscorlib", "System", "RuntimeTypeHandle") }, isStatic: true));
|
||||
|
||||
if (node.Parent is IElementNode elementNode)
|
||||
foreach (var instruction in context.Variables[elementNode].LoadAs(context.Cache, module.TypeSystem.Object, module))
|
||||
if (node.Parent is IElementNode elementNode &&
|
||||
context.Variables.TryGetValue(elementNode, out VariableDefinition variableDefinition))
|
||||
{
|
||||
foreach (var instruction in variableDefinition.LoadAs(context.Cache, module.TypeSystem.Object, module))
|
||||
{
|
||||
yield return instruction;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return Create(Ldnull);
|
||||
|
||||
}
|
||||
|
||||
foreach (var instruction in PushTargetProperty(context, bpRef, propertyRef, declaringTypeReference, module))
|
||||
yield return instruction;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
</Style>
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
<StackLayout>
|
||||
<StackLayout Spacing="{OnPlatform iOS={OnIdiom Default=35, Phone=25}, WinUI=25, Android={OnIdiom Default=45, Phone=25}}">
|
||||
<Label x:Name="label0" FontAttributes="{StaticResource fontAttributes}" FontSize="{StaticResource fontSize}">
|
||||
<Label.IsVisible>
|
||||
<OnPlatform x:TypeArguments="x:Boolean">
|
||||
|
|
Загрузка…
Ссылка в новой задаче