Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Bugfix Issue #1705 (MAUI: 184): Allow null handling for BaseConverterOneWay<TFrom, TTo> #1733

Merged
merged 25 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bec1467
Fix typo ArgumenException for unit tests
Nov 25, 2021
2a1a7a0
Add AllowsNullOrDefault handling for BaseConverterOneWay
Nov 25, 2021
d4660ec
Add BaseConverterOneWay_Tests for new AllowsNullOrDefault
Nov 25, 2021
3b6d615
Merge branch 'main' into main
bijington Nov 25, 2021
850e470
Implement recommended changes
Nov 25, 2021
e479465
Merge branch 'main' into main
pictos Nov 25, 2021
70b11ce
Update null check in BaseConverterOneWay<TFrom, TTo>
Nov 26, 2021
c86e723
Implement recommended changes
Countryen Nov 26, 2021
9d8a6f0
Rename property AllowsNullOrDefault to AllowsNull of BaseConverterOne…
Countryen Nov 26, 2021
d7a02ff
Update IsNullOrEmptyConverter to inherit from BaseConverterOneWay<TFr…
Countryen Nov 26, 2021
05c66b6
Migrated more converters to base
bijington Nov 29, 2021
a53e354
Revert compare converter changes
bijington Nov 30, 2021
c59280a
Fixed unit tests and code review tidy up
bijington Nov 30, 2021
bb73468
Switch to separate nullable converter base class
bijington Nov 30, 2021
2626937
Add null support to BaseConverter
bijington Nov 30, 2021
cacf2da
Remove Null-Forgiving Operator
TheCodeTraveler Nov 30, 2021
8caf5be
Rename converters to start with Base
bijington Nov 30, 2021
1e3a376
Merge branch 'main' of https://github.com/Countryen/XamarinCommunityT…
bijington Nov 30, 2021
1309cfb
Merge branch 'main' into main
TheCodeTraveler Dec 2, 2021
31d953b
Code review improvement
bijington Dec 2, 2021
366d1d0
Merge branch 'main' of https://github.com/Countryen/XamarinCommunityT…
bijington Dec 2, 2021
9b4e47e
Add global.json
TheCodeTraveler Dec 3, 2021
d20394a
`dotnet format`
TheCodeTraveler Dec 3, 2021
f3ff5c1
Move global.json to root folder
TheCodeTraveler Dec 3, 2021
f89c7eb
`dotnet format`
TheCodeTraveler Dec 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'">
<LangVersion>9.0</LangVersion>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
</PropertyGroup>
Expand Down
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "6.0.*",
"rollForward": "latestMajor"
}
}
8 changes: 4 additions & 4 deletions samples/XCT.Sample.WPF/DrawingViewRenderer.wpf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void OnStrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
Element.Lines.Clear();
}

var lines = Element.MultiLineMode ? e.Added : new StrokeCollection() {e.Added.First()};
var lines = Element.MultiLineMode ? e.Added : new StrokeCollection() { e.Added.First() };

foreach (var line in lines)
{
Expand All @@ -100,7 +100,7 @@ void OnStrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
Points = new ObservableCollection<Point>(points),
LineColor = Color.FromRgba(line.DrawingAttributes.Color.R, line.DrawingAttributes.Color.G,
line.DrawingAttributes.Color.B, line.DrawingAttributes.Color.A),
LineWidth = (float) line.DrawingAttributes.Width
LineWidth = (float)line.DrawingAttributes.Width
});
}

Expand All @@ -127,12 +127,12 @@ void LoadLines()
var lines = Element.MultiLineMode
? Element.Lines
: Element.Lines.Any()
? new ObservableCollection<Line> {Element.Lines.LastOrDefault()}
? new ObservableCollection<Line> { Element.Lines.LastOrDefault() }
: new ObservableCollection<Line>();
foreach (var line in lines)
{
var stylusPoints = line.Points.Select(point => new StylusPoint(point.X, point.Y)).ToList();
if (stylusPoints is {Count: > 0})
if (stylusPoints is { Count: > 0 })
{
var stroke = new Stroke(new StylusPointCollection(stylusPoints))
{
Expand Down
1 change: 1 addition & 0 deletions samples/XCT.Sample.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\.editorconfig = ..\.editorconfig
..\Directory.Build.props = ..\Directory.Build.props
..\Xamarin.CommunityToolkit.ruleset = ..\Xamarin.CommunityToolkit.ruleset
..\global.json = ..\global.json
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.CommunityToolkit.Sample.WPF", "XCT.Sample.WPF\Xamarin.CommunityToolkit.Sample.WPF.csproj", "{C4D6CD2D-8DF4-4D46-936C-1AB31C87B5EA}"
Expand Down
2 changes: 1 addition & 1 deletion samples/XCT.Sample/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public App()
MainPage = new BaseNavigationPage(new WelcomePage());
}
}
}
}
2 changes: 1 addition & 1 deletion samples/XCT.Sample/Pages/Animations/AnimationPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ public AnimationPage()
InitializeComponent();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
public partial class AnimationBehaviorPage : BasePage
{
public AnimationBehaviorPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class BoolToObjectConverterPage
{
public BoolToObjectConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class CompareConverterPage : BasePage
{
public CompareConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class DoubleToIntConverterPage
{
public DoubleToIntConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Xamarin.CommunityToolkit.Sample.Pages.Converters
{
public partial class EnumToBoolConverterPage
{
public EnumToBoolConverterPage() => InitializeComponent();
}
public partial class EnumToBoolConverterPage
{
public EnumToBoolConverterPage() => InitializeComponent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class EnumToIntConverterPage
{
public EnumToIntConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class EqualConverterPage
{
public EqualConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class IndexToArrayItemConverterPage
{
public IndexToArrayItemConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class IntToBoolConverterPage
{
public IntToBoolConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class InvertedBoolConverterPage
{
public InvertedBoolConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class IsInRangeConverterPage
{
public IsInRangeConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class IsNotNullOrEmptyConverterPage
{
public IsNotNullOrEmptyConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ public IsNullOrEmptyConverterPage()
InitializeComponent();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ public ListIsNotNullOrEmptyConverterPage()
InitializeComponent();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class ListToStringConverterPage
{
public ListToStringConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class MathExpressionConverterPage
{
public MathExpressionConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class NotEqualConverterPage
{
public NotEqualConverterPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ public StringToListConverterPage()
InitializeComponent();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class TextCaseConverterPage
{
public TextCaseConverterPage() => InitializeComponent();
}
}
}
2 changes: 1 addition & 1 deletion samples/XCT.Sample/Pages/Effects/ShadowEffectPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class ShadowEffectPage
{
public ShadowEffectPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public partial class StatusBarEffectPage
{
public StatusBarEffectPage() => InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Xamarin.CommunityToolkit.Sample.Pages.TestCases.Popups
{
public partial class SimplePopup
public partial class SimplePopup
{
public SimplePopup() => InitializeComponent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public TouchEffectCollectionViewPage()

public ICommand LongPressCommand { get; }
}
}
}
4 changes: 2 additions & 2 deletions samples/XCT.Sample/Pages/Views/DrawingViewPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
using Xamarin.CommunityToolkit.UI.Views;
using System.Collections.ObjectModel;
using System.Linq;
using Xamarin.CommunityToolkit.UI.Views;
using Xamarin.Forms;

namespace Xamarin.CommunityToolkit.Sample.Pages.Views
{
Expand Down
2 changes: 1 addition & 1 deletion samples/XCT.Sample/Pages/Views/Popups/PopupSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ static class PopupSize

public static Size Large => new Size(0.9 * (DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density), 0.8 * (DeviceDisplay.MainDisplayInfo.Height / DeviceDisplay.MainDisplayInfo.Density));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.CommunityToolkit.PlatformConfiguration.iOSSpecific;
using Xamarin.CommunityToolkit.PlatformConfiguration.iOSSpecific;
using Xamarin.CommunityToolkit.PlatformConfiguration.WindowsSpecific;
using Xamarin.Forms.PlatformConfiguration;

namespace Xamarin.CommunityToolkit.Sample.Pages.Views.Popups
{
Expand Down
2 changes: 1 addition & 1 deletion samples/XCT.Sample/Pages/Views/TextSwitcherPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public TextSwitcherPage()
public ICommand UpdateTextCommand { get; }
= new Command<TextSwitcher>(textSwitcher => textSwitcher.Text = Path.GetRandomFileName());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,4 @@ public AnimationDetailModel(string name, Func<View, Action<double, bool>, Compou
CreateAnimation = createAnimation;
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ protected override IEnumerable<SectionModel> CreateItems() => new[]
"A group of converters that convert a Color to your strings values (RGB, HEX, HSL, etc)"),
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public double Input
set => SetProperty(ref index, value);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public IssueState SelectedState
set => SetProperty(ref selectedState, value);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ImageResourceConverterViewModel : BaseViewModel
const string img1 = "button.png";
const string img2 = "logo.png";
const string imagesPath = "Images";

string defaultNamespace;

string? imageName;
Expand Down Expand Up @@ -38,4 +38,4 @@ public ImageResourceConverterViewModel()
string BuildEmbededImagePath(string imgName)
=> $"{defaultNamespace}.{imagesPath}.{imgName}";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public int Index
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public int Number
set => SetProperty(ref index, value);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public string? SelectedItem
set => SetProperty(ref selectedItem, value);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ protected override IEnumerable<SectionModel> CreateItems() => new[]
"A XAML extension that helps to display images from embedded resources"),
};
}
}
}
4 changes: 2 additions & 2 deletions samples/XCT.Sample/ViewModels/Markup/SearchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public SearchViewModel()
public ICommand OpenHelpCommand { get; }

void Back()
{
}
{
}

void Like(Tweet tweet) => tweet.IsLikedByMe = !tweet.IsLikedByMe;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Windows.Input;
using Xamarin.Forms;
using Xamarin.CommunityToolkit.Sample.Pages.TestCases.Popups;
using Xamarin.CommunityToolkit.Extensions;
using Xamarin.CommunityToolkit.Sample.Pages.TestCases.Popups;
using Xamarin.Forms;

namespace Xamarin.CommunityToolkit.Sample.ViewModels.TestCases.Popups
{
Expand Down Expand Up @@ -32,4 +32,4 @@ async void PerformPopModal()
await Navigation.PopModalAsync();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Xamarin.CommunityToolkit.Sample.ViewModels.TestCases
{
public class TabViewItemBindingViewModel : BaseViewModel
{
public static TabViewItemBindingViewModel Current { get; } = new ();
public static TabViewItemBindingViewModel Current { get; } = new();

int countClick;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ async Task OnDisplayPopup(Type? popupType)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ public class CsharpBindingPopupViewModel

public string Message { get; } = "This is a native popup with a Xamarin.Forms View being rendered. The behaviors of the popup will confirm to 100% native look and feel, but still allows you to use your Xamarin.Forms controls.";
}
}
}
Loading