Skip to content

Commit

Permalink
Merge pull request #4807 from MartinZikmund/dev/mazi/tabview-bitmapicon
Browse files Browse the repository at this point in the history
fix: Double query of ApiInformation.IsPropertyPresent returns different results
  • Loading branch information
davidjohnoliver authored Dec 29, 2020
2 parents c3bb057 + 6715a1e commit 71cf635
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</controls:TabViewItem>
<controls:TabViewItem Header="Document 1">
<controls:TabViewItem.IconSource>
<controls:SymbolIconSource Symbol="Document" />
<controls:BitmapIconSource ShowAsMonochrome="False" UriSource="/Assets/ingredient1.png" />
</controls:TabViewItem.IconSource>
</controls:TabViewItem>
<controls:TabViewItem Header="Document 2">
Expand Down
24 changes: 13 additions & 11 deletions src/Uno.Foundation/Metadata/ApiInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,25 @@ public static bool IsEnumNamedValuePresent(string enumTypeName, string valueName
{
lock (_assemblies)
{
if (!_typeCache.TryGetValue(typeName, out var type))
if (_typeCache.TryGetValue(typeName, out var type))
{
foreach (var assembly in _assemblies)
{
type = assembly.GetType(typeName);
return type;
}

if (type != null)
{
_typeCache[typeName] = type;
foreach (var assembly in _assemblies)
{
type = assembly.GetType(typeName);

return type;
}
if (type != null)
{
_typeCache[typeName] = type;

return type;
}
}
}

return null;
return null;
}
}

internal static void TryRaiseNotImplemented(string type, string memberName)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Threading.Tasks;
using Windows.Foundation.Metadata;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Uno.UI.RuntimeTests.Tests.Windows_Foundation.Metadata
{
[TestClass]
public class Given_ApiInformation
{
[TestMethod]
public async Task When_IsPropertyPresent_Called_Twice()
{
// Verifies fix for issue #4803
// SharedHelpers called IsPropertyPresent twice for an implemented property
// but the second call resulted in false

// Application.Current is implemented on all targets
var isPresent = ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Application", "Current");
Assert.IsTrue(isPresent);
var secondIsPresent = ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Application", "Current");
Assert.IsTrue(secondIsPresent);
}
}
}
1 change: 0 additions & 1 deletion src/Uno.UI/UI/Xaml/Controls/BitmapIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public partial class BitmapIcon : IconElement
public BitmapIcon()
{
this.SetValue(ForegroundProperty, SolidColorBrushHelper.Black, DependencyPropertyValuePrecedences.Inheritance);

}

protected override Size MeasureOverride(Size availableSize)
Expand Down

0 comments on commit 71cf635

Please sign in to comment.