Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project>
<PropertyGroup>
<!-- Fixes https://github.com/dotnet/maui/pull/12114 -->
<PublishReadyToRun>false</PublishReadyToRun>
<LangVersion>latest</LangVersion>
<NetVersion>net8.0</NetVersion>
<MauiPackageVersion>8.0.0-rc.2.9511</MauiPackageVersion>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<NoWarn>NETSDK1023</NoWarn>
<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
Expand Down
7 changes: 4 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
variables:
CurrentSemanticVersionBase: '1.0.0'
CurrentSemanticVersionBase: '99.0.0'
PreviewNumber: $[counter(variables['CurrentSemanticVersionBase'], 1001)]
CurrentSemanticVersion: '$(CurrentSemanticVersionBase)-preview$(PreviewNumber)'
NugetPackageVersion: '$(CurrentSemanticVersion)'
NET_VERSION: '7.0.x'
NET_VERSION: '8.0.x'
RunPoliCheck: false
PathToLibrarySolution: 'src/CommunityToolkit.Maui.Markup.sln'
PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Markup.Sample.sln'
PathToCommunityToolkitCsproj: 'src/CommunityToolkit.Maui.Markup/CommunityToolkit.Maui.Markup.csproj'
PathToCommunityToolkitSampleCsproj: 'samples/CommunityToolkit.Maui.Markup.Sample/CommunityToolkit.Maui.Markup.Sample.csproj'
PathToCommunityToolkitUnitTestCsproj: 'src/CommunityToolkit.Maui.Markup.UnitTests/CommunityToolkit.Maui.Markup.UnitTests.csproj'
PathToCommunityToolkitSourceGeneratorsCsproj: 'src/CommunityToolkit.Maui.Markup.SourceGenerators/CommunityToolkit.Maui.Markup.SourceGenerators.csproj'
XcodeVersion: '14.3.1'
XcodeVersion: '15.0.1'
ShouldCheckDependencies: true

trigger:
Expand Down Expand Up @@ -84,6 +84,7 @@ jobs:
inputs:
packageType: 'sdk'
version: '$(NET_VERSION)'
includePreviewVersions: true

- task: CmdLine@2
displayName: 'Install .NET MAUI Workload'
Expand Down
8 changes: 4 additions & 4 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "7.0.100",
"rollForward": "latestMajor",
"allowPrerelease": false
"version": "8.0.100-rc.2.23502.2",
"rollForward": "latestFeature",
"allowPrerelease": true
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);net7.0-tizen</TargetFrameworks>
<TargetFrameworks>$(NetVersion)-android;$(NetVersion)-ios;$(NetVersion)-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);$(NetVersion)-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);$(NetVersion)-tizen</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>CommunityToolkit.Maui.Markup.Sample</RootNamespace>
<UseMaui>true</UseMaui>
Expand Down
21 changes: 13 additions & 8 deletions src/CommunityToolkit.Maui.Markup.UnitTests/BindingHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace CommunityToolkit.Maui.Markup.UnitTests;
static class BindingHelpers
{
static MethodInfo? getContextMethodInfo;
static FieldInfo? bindingFieldInfo;
static FieldInfo? bindingsFieldInfo;

internal static void AssertBindingExists(
BindableObject bindable,
Expand Down Expand Up @@ -146,8 +146,8 @@ internal static void AssertBindingExists<TDest>(
TDest? fallbackValue = default,
Action<IMultiValueConverter>? assertConvert = null)
=> AssertBindingExists<TDest, object>(
bindable, targetProperty, bindings, converter, null, mode, assertConverterInstanceIsAnyNotNull,
stringFormat, targetNullValue, fallbackValue, assertConvert);
bindable, targetProperty, bindings, converter, null, mode, assertConverterInstanceIsAnyNotNull,
stringFormat, targetNullValue, fallbackValue, assertConvert);

internal static void AssertBindingExists<TDest, TParam>(
BindableObject bindable,
Expand Down Expand Up @@ -199,21 +199,26 @@ internal static void AssertBindingExists<TDest, TParam>(
{
getContextMethodInfo ??= typeof(BindableObject).GetMethod("GetContext", BindingFlags.NonPublic | BindingFlags.Instance);

var context = getContextMethodInfo?.Invoke(bindable, new object[] { property });
var context = getContextMethodInfo?.Invoke(bindable, new object[]
{
property
});
if (context is null)
{
return null;
}

bindingFieldInfo ??= context?.GetType().GetField("Binding");
bindingsFieldInfo ??= context.GetType().GetField("Bindings");

var bindingsList = bindingsFieldInfo?.GetValue(context) as SortedList<SetterSpecificity, BindingBase>;

return bindingFieldInfo?.GetValue(context) as TBinding;
return (TBinding?)bindingsList?.First().Value;
}

internal static IValueConverter AssertConvert<TValue, TConvertedValue>(this IValueConverter converter, TValue value, object? parameter, TConvertedValue expectedConvertedValue, bool twoWay = false, bool backOnly = false, CultureInfo? culture = null)
{
Assert.That(converter.Convert(value, typeof(object), parameter, culture), Is.EqualTo(backOnly ? default : expectedConvertedValue));
Assert.That(converter.ConvertBack(expectedConvertedValue, typeof(object), parameter, culture), Is.EqualTo(twoWay || backOnly ? value : default(TValue)));
Assert.That(converter.Convert(value, typeof(object), parameter, culture ?? CultureInfo.InvariantCulture), Is.EqualTo(backOnly ? default : expectedConvertedValue));
Assert.That(converter.ConvertBack(expectedConvertedValue, typeof(object), parameter, culture ?? CultureInfo.InvariantCulture), Is.EqualTo(twoWay || backOnly ? value : default(TValue)));
return converter;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFramework>$(NetVersion)</TargetFramework>
<UseMaui>true</UseMaui>
<IsPackable>false</IsPackable>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace CommunityToolkit.Maui.Markup.UnitTests;
class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGestureElement : View, IGestureRecognizers, new()
{
[Test]
[Obsolete($"ClickGestureRecognizer is now obsolete")]
public void BindClickGestureDefaults()
{
var gestureElement = new TGestureElement();
Expand All @@ -20,6 +21,7 @@ public void BindClickGestureDefaults()
}

[Test]
[Obsolete($"ClickGestureRecognizer is now obsolete")]
public void BindClickGesturePositionalParameters()
{
const int numberOfClicks = 2;
Expand Down Expand Up @@ -68,6 +70,7 @@ public void BindTapGesturePositionalParameters()
}

[Test]
[Obsolete($"ClickGestureRecognizer is now obsolete")]
public void ClickGesture()
{
const int numberOfClicks = 2;
Expand Down Expand Up @@ -216,6 +219,7 @@ public void SupportDerivedFromLabel() // A View
class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixture where TGestureElement : View, IGestureRecognizers, new()
{
[Test]
[Obsolete($"ClickGestureRecognizer is now obsolete")]
public void BindClickGestureDefaults()
{
var gestureElement = new TGestureElement
Expand All @@ -231,6 +235,7 @@ public void BindClickGestureDefaults()
}

[Test]
[Obsolete($"ClickGestureRecognizer is now obsolete")]
public void BindClickGestureDefaultsWithNestedBindings()
{
var guid = Guid.NewGuid();
Expand All @@ -255,6 +260,7 @@ public void BindClickGestureDefaultsWithNestedBindings()
}

[Test]
[Obsolete($"ClickGestureRecognizer is now obsolete")]
public void BindClickGesturePositionalParameters()
{
const int numberOfClicks = 2;
Expand All @@ -281,6 +287,7 @@ public void BindClickGesturePositionalParameters()


[Test]
[Obsolete($"ClickGestureRecognizer is now obsolete")]
public void BindClickGesturePositionalParametersWithNestedBindings()
{
const int numberOfClicks = 2;
Expand Down Expand Up @@ -536,6 +543,7 @@ public void BindSwipeGesturePositionalParametersWithNestedBindings()
}

[Test]
[Obsolete]
public void MultipleGestureBindings()
{
var gestureElement = new TGestureElement
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>$(NetVersion)</TargetFramework>
<UseMaui>true</UseMaui>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down Expand Up @@ -40,6 +40,10 @@
<None Include="ReadMe.txt" pack="true" PackagePath="." />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiPackageVersion)"/>
</ItemGroup>

<ItemGroup>
<None Include="..\CommunityToolkit.Maui.Markup.SourceGenerators\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Maui.Markup.SourceGenerators.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/CommunityToolkit.Maui.Markup/DefaultBindableProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public static class DefaultBindableProperties
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(Button)}", Button.CommandProperty },
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(CarouselPage)}", Page.TitleProperty },
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(CheckBox)}", CheckBox.IsCheckedProperty },
#pragma warning disable CS0618
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(ClickGestureRecognizer)}", ClickGestureRecognizer.CommandProperty },
#pragma warning disable CS0618
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(CollectionView)}", CollectionView.ItemsSourceProperty },
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(ContentPage)}", Page.TitleProperty },
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(ContentPresenter)}", ContentPresenter.ContentProperty },
Expand Down Expand Up @@ -85,7 +87,9 @@ public static class DefaultBindableProperties
{ // Key: full type name of BindableObject, Value: command property and corresponding commandParameter property
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(Button)}", (Button.CommandProperty, Button.CommandParameterProperty) },
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(TextCell)}", (TextCell.CommandProperty, TextCell.CommandParameterProperty) },
#pragma warning disable CS0618
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(ClickGestureRecognizer)}", (ClickGestureRecognizer.CommandProperty, ClickGestureRecognizer.CommandParameterProperty) },
#pragma warning restore CS0618
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(ImageButton)}", (ImageButton.CommandProperty, ImageButton.CommandParameterProperty) },
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(MenuItem)}", (MenuItem.CommandProperty, MenuItem.CommandParameterProperty) },
{ $"{nameof(Microsoft)}.{nameof(Microsoft.Maui)}.{nameof(Microsoft.Maui.Controls)}.{nameof(RefreshView)}", (RefreshView.CommandProperty, RefreshView.CommandParameterProperty) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace CommunityToolkit.Maui.Markup;
public static partial class GesturesExtensions
{
/// <summary>Add a <see cref="ClickGestureRecognizer"/> and bind to its Command</summary>
[Obsolete($"{nameof(BindClickGesture)} is deprecated; please use ${nameof(BindTapGesture)} instead.")]
public static TGestureElement BindClickGesture<TGestureElement, TCommandBindingContext>(
this TGestureElement gestureElement,
Expression<Func<TCommandBindingContext, ICommand>> getter,
Expand All @@ -24,6 +25,7 @@ public static TGestureElement BindClickGesture<TGestureElement, TCommandBindingC
}

/// <summary>Add a <see cref="ClickGestureRecognizer"/> and bind to its Command and (optionally) CommandParameter properties</summary>
[Obsolete($"{nameof(BindClickGesture)} is deprecated; please use ${nameof(BindTapGesture)} instead.")]
public static TGestureElement BindClickGesture<TGestureElement, TCommandBindingContext, TParameterBindingContext, TParameterSource>(
this TGestureElement gestureElement,
Expression<Func<TCommandBindingContext, ICommand>> getter,
Expand Down Expand Up @@ -65,6 +67,7 @@ public static TGestureElement BindClickGesture<TGestureElement, TCommandBindingC
}

/// <summary>Add a <see cref="ClickGestureRecognizer"/> and bind to its Command </summary>
[Obsolete($"{nameof(BindClickGesture)} is deprecated; please use ${nameof(BindTapGesture)} instead.")]
public static TGestureElement BindClickGesture<TGestureElement, TCommandBindingContext>(
this TGestureElement gestureElement,
Func<TCommandBindingContext, ICommand> getter,
Expand All @@ -84,6 +87,7 @@ public static TGestureElement BindClickGesture<TGestureElement, TCommandBindingC
}

/// <summary>Add a <see cref="ClickGestureRecognizer"/> and bind to its Command and (optionally) CommandParameter properties</summary>
[Obsolete($"{nameof(BindClickGesture)} is deprecated; please use ${nameof(BindTapGesture)} instead.")]
public static TGestureElement BindClickGesture<TGestureElement, TCommandBindingContext, TParameterBindingContext, TParameterSource>(
this TGestureElement gestureElement,
Func<TCommandBindingContext, ICommand> getter,
Expand Down
3 changes: 3 additions & 0 deletions src/CommunityToolkit.Maui.Markup/GesturesExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static partial class GesturesExtensions
/// <param name="parameterSource">Binding source for Command Binding</param>
/// <param name="numberOfClicksRequired">Total number of clicks required to trigger <see cref="ICommand"/></param>
/// <returns><paramref name="gestureElement"/></returns>
[Obsolete($"{nameof(BindClickGesture)} is deprecated; please use ${nameof(BindTapGesture)} instead.")]
public static TGestureElement BindClickGesture<TGestureElement>(this TGestureElement gestureElement,
string commandPath,
object? commandSource = null,
Expand Down Expand Up @@ -76,6 +77,7 @@ public static TGestureElement BindTapGesture<TGestureElement>(this TGestureEleme
/// <param name="onClicked"><see cref="Action"/>invoked once <paramref name="numberOfClicksRequired"/> threshold is reached</param>
/// <param name="numberOfClicksRequired">Total number of clicks required to trigger <paramref name="onClicked"/></param>
/// <returns><paramref name="gestureElement"/></returns>
[Obsolete($"{nameof(ClickGesture)} is deprecated; please use ${nameof(TapGesture)} instead.")]
public static TGestureElement ClickGesture<TGestureElement>(this TGestureElement gestureElement,
Action onClicked,
int? numberOfClicksRequired = null) where TGestureElement : IGestureRecognizers
Expand Down Expand Up @@ -205,6 +207,7 @@ public static TGestureElement TapGesture<TGestureElement>(this TGestureElement g
return gestureElement;
}

[Obsolete($"{nameof(BindClickGesture)} is deprecated; please use ${nameof(BindTapGesture)} instead.")]
static TGestureElement ConfigureClickGesture<TGestureElement>(this TGestureElement gestureElement,
ClickGestureRecognizer clickGesture,
int? numberOfClicksRequired = null) where TGestureElement : IGestureRecognizers
Expand Down