Resolving warnings and treating warnings as errors in WinUI project. (#824)
This commit is contained in:
@@ -15,7 +15,7 @@ namespace Wino.Calendar.Helpers;
|
||||
public static class CalendarXamlHelpers
|
||||
{
|
||||
public static CalendarItemViewModel GetFirstAllDayEvent(CalendarEventCollection collection)
|
||||
=> (CalendarItemViewModel)collection.AllDayEvents.FirstOrDefault();
|
||||
=> collection.AllDayEvents.OfType<CalendarItemViewModel>().FirstOrDefault()!;
|
||||
|
||||
/// <summary>
|
||||
/// Returns full date + duration info in Event Details page details title.
|
||||
|
||||
@@ -6,18 +6,20 @@ namespace Wino.Helpers;
|
||||
|
||||
public static class WinoVisualTreeHelper
|
||||
{
|
||||
public static T GetChildObject<T>(DependencyObject obj, string name) where T : FrameworkElement
|
||||
public static T? GetChildObject<T>(DependencyObject? obj, string name) where T : FrameworkElement
|
||||
{
|
||||
DependencyObject child = null;
|
||||
T grandChild = null;
|
||||
if (obj == null) return null;
|
||||
|
||||
DependencyObject? child = null;
|
||||
T? grandChild = null;
|
||||
|
||||
for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(obj) - 1; i++)
|
||||
{
|
||||
child = VisualTreeHelper.GetChild(obj, i);
|
||||
|
||||
if (child is T && (((T)child).Name == name | string.IsNullOrEmpty(name)))
|
||||
if (child is T typedChild && (typedChild.Name == name || string.IsNullOrEmpty(name)))
|
||||
{
|
||||
return (T)child;
|
||||
return typedChild;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -31,7 +33,7 @@ public static class WinoVisualTreeHelper
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IEnumerable<T> FindDescendants<T>(this DependencyObject depObj) where T : DependencyObject
|
||||
public static IEnumerable<T> FindDescendants<T>(this DependencyObject? depObj) where T : DependencyObject
|
||||
{
|
||||
if (depObj != null)
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ public static class XamlHelpers
|
||||
public static ListViewSelectionMode BoolToSelectionMode(bool isSelectionMode) => isSelectionMode ? ListViewSelectionMode.Multiple : ListViewSelectionMode.None;
|
||||
public static string BoolToSelectionModeText(bool isSelectionMode) => isSelectionMode ? Translator.Buttons_Cancel : Translator.Buttons_Multiselect;
|
||||
|
||||
public static Microsoft.UI.Xaml.Media.Imaging.BitmapImage Base64ToBitmapImage(string base64String)
|
||||
public static Microsoft.UI.Xaml.Media.Imaging.BitmapImage? Base64ToBitmapImage(string base64String)
|
||||
{
|
||||
if (string.IsNullOrEmpty(base64String))
|
||||
return null;
|
||||
@@ -154,7 +154,7 @@ public static class XamlHelpers
|
||||
if (groupObject is string stringObject)
|
||||
return stringObject;
|
||||
|
||||
object dateObject = null;
|
||||
object? dateObject = null;
|
||||
|
||||
// From regular mail header template
|
||||
if (groupObject is DateTime groupedDate)
|
||||
@@ -180,7 +180,7 @@ public static class XamlHelpers
|
||||
|
||||
}
|
||||
else
|
||||
return dateObject.ToString();
|
||||
return dateObject.ToString() ?? string.Empty;
|
||||
}
|
||||
|
||||
return Translator.UnknownDateHeader;
|
||||
@@ -321,6 +321,10 @@ public static class XamlHelpers
|
||||
"xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'>" +
|
||||
"<Path.Data>" + pathMarkup + "</Path.Data></Path>";
|
||||
var path = XamlReader.Load(xaml) as Microsoft.UI.Xaml.Shapes.Path;
|
||||
if (path?.Data == null)
|
||||
{
|
||||
return new PathGeometry();
|
||||
}
|
||||
|
||||
Geometry geometry = path.Data;
|
||||
path.Data = null;
|
||||
|
||||
Reference in New Issue
Block a user