Skip to content

Commit

Permalink
Fixes a range of build warnings in the toolkit api projects
Browse files Browse the repository at this point in the history
  • Loading branch information
dotMorten committed May 14, 2024
1 parent 5925a61 commit 3dd2dce
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Esri.ArcGISRuntime.Toolkit.Maui;
internal class BoolToOpacityConverter : IValueConverter
{
/// <inheritdoc/>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is bool boolValue)
{
Expand All @@ -35,7 +35,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
}

/// <inheritdoc/>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ internal class ByteArrayToImageSourceConverter : IValueConverter
/// <summary>
/// Converts a byte array to an image source for display in Microsoft .NET MAUI.
/// </summary>
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is byte[] rawBuffer)
{
return ImageSource.FromStream(() => new MemoryStream(rawBuffer));
}

AppTheme currentTheme = Application.Current.RequestedTheme;
AppTheme? currentTheme = Application.Current?.RequestedTheme;

if (currentTheme == AppTheme.Dark)
{
Expand All @@ -43,7 +43,7 @@ internal class ByteArrayToImageSourceConverter : IValueConverter
}

/// <inheritdoc/>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Toolkit/Toolkit.Maui/Internal/EmptyToFalseConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Esri.ArcGISRuntime.Toolkit.Maui.Internal
internal class EmptyToFalseConverter : IValueConverter
{
public static EmptyToFalseConverter Instance { get; } = new EmptyToFalseConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is null) return false;
if (value is string str) return !string.IsNullOrWhiteSpace(str);
Expand All @@ -30,7 +30,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
return true;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Esri.ArcGISRuntime.Toolkit.Maui.Internal;
internal class LoadStatusToVisibilityConverter : IValueConverter
{
/// <inheritdoc/>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (DesignMode.IsDesignModeEnabled)
{
Expand Down Expand Up @@ -66,7 +66,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
}

/// <inheritdoc/>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class BoolToCollectionIconImageConverter : IValueConverter
/// <summary>
/// Converts a bool to an icon representing either a search (true) or an individual result (false).
/// </summary>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is bool boolvalue && boolvalue)
{
Expand All @@ -47,7 +47,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
}

/// <inheritdoc/>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class EmptyStringToBoolConverter : IValueConverter
/// <summary>
/// Converts a string to a bool, true if not empty, false otherwise.
/// </summary>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is string stringvalue && !string.IsNullOrEmpty(stringvalue))
{
Expand All @@ -34,7 +34,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
}

/// <inheritdoc/>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#if WPF
using System.Windows.Controls.Primitives;
#endif

#pragma warning disable CS0618 // SketchEditor is Obsolete
namespace Esri.ArcGISRuntime.Toolkit.UI.Controls
{
/// <summary>
Expand Down Expand Up @@ -771,4 +771,5 @@ private static void OnSelectedAreaUnitPropertyChanged(DependencyObject d, Depend
}
}
}
#pragma warning restore CS0618 // SketchEditor is Obsolete
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ private async void Refresh()
/// Triggered when the image source has updated
/// </summary>
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
#if NETCOREAPP
public new event System.EventHandler? SourceUpdated;
#else
public event System.EventHandler? SourceUpdated;
#endif
#pragma warning restore CS0108
#pragma warning restore IDE0079
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<TargetPlatformMinVersion>$(UWPTargetPlatformMinVersion)</TargetPlatformMinVersion>
<GenerateLibraryLayout>true</GenerateLibraryLayout>
<RootNamespace>Esri.ArcGISRuntime.Toolkit</RootNamespace>
<AppxBundlePlatforms>AnyCPU</AppxBundlePlatforms> <!-- this has no practical effect on class libraries besides avoiding an irrelevant build warning -->
</PropertyGroup>
<Import Project="..\..\CommonProperties.targets" />

Expand Down
5 changes: 3 additions & 2 deletions src/Toolkit/Toolkit/LayerContentDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,9 @@ protected virtual void OnDocumentReset()
{
}

private void Layer_PropertyChanged(ILayerContent sender, string? propertyName)
private void Layer_PropertyChanged(ILayerContent? sender, string? propertyName)
{
if (sender is null) return;
var layer = sender as ILayerContent;
if (layer is ILoadable loadable && propertyName == nameof(ILoadable.LoadStatus) && loadable.LoadStatus == LoadStatus.Loaded)
{
Expand Down Expand Up @@ -379,7 +380,7 @@ private IEnumerable<Action> TrackLayerContentsRecursive(IEnumerable<ILayerConten
{
var listener = new WeakEventListener<LayerContentDataSource<T>, INotifyPropertyChanged, object?, PropertyChangedEventArgs>(this, inpc)
{
OnEventAction = static (instance, source, eventArgs) => instance.Layer_PropertyChanged((ILayerContent)source, eventArgs.PropertyName),
OnEventAction = static (instance, source, eventArgs) => instance.Layer_PropertyChanged((ILayerContent?)source, eventArgs.PropertyName),
OnDetachAction = static (instance, source, weakEventListener) => source.PropertyChanged -= weakEventListener.OnEvent,
};
inpc.PropertyChanged += listener.OnEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ private void OnIsCheckedPropertyChanged(object oldValue, object newValue)
{
var state = (newValue is bool b && b);
if (state)
Checked();
OnChecked();
else
Unchecked();
OnUnchecked();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ public partial class SwitchFormInputView : CheckBox
/// <inheritdoc/>
protected override void OnChecked(RoutedEventArgs e)
{
Checked();
OnChecked();
base.OnChecked(e);
}

/// <inheritdoc/>
protected override void OnUnchecked(RoutedEventArgs e)
{
Unchecked();
OnUnchecked();
base.OnUnchecked(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ private void Element_PropertyChanged(object? sender, System.ComponentModel.Prope
#endif
}

private void Checked()
private void OnChecked()
{
if (Element is not null && Element.Input is SwitchFormInput input && !object.Equals(input.OnValue.Code, Element.Value))
{
Element.UpdateValue(input.OnValue.Code);
}
}

private void Unchecked()
private void OnUnchecked()
{
if (Element is not null && Element.Input is SwitchFormInput input && !object.Equals(input.OffValue.Code, Element.Value))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,14 @@ private static char ContentTypeToCalciteGlyph(string contentType)
private class AttachmentViewModelConverter : IValueConverter
{
internal static AttachmentViewModelConverter Instance { get; } = new AttachmentViewModelConverter();
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is PopupAttachment attachment)
return new AttachmentViewModel(attachment);
return value;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException();
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private static Block VisitBlock(MarkupNode node)
var para = new Paragraph();
// In HTML, <p> has default margin but other blocks (like <div>) do not.
// In WPF, all of these map to Paragraphs that *does* have a default margin.
if (node?.Token?.Name != "p")
if (node.Token?.Name != "p")
para.Margin = new Thickness(0);
ApplyStyle(para, node);
para.Inlines.AddRange(VisitAndAddInlines(node.Children));
Expand Down

0 comments on commit 3dd2dce

Please sign in to comment.