Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support .NET 9.0 #2215

Open
wants to merge 167 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
c4169ed
Point to the .NET 9.0 release candidate
bijington Sep 18, 2024
e8e4c21
Tweak versions in the pipeline
bijington Sep 18, 2024
0223b47
allow prerelease builds
bijington Sep 18, 2024
24f1026
Find overlapping versions for AnxroidX libraries
bijington Sep 18, 2024
616ca9c
Fix null reference type issue
bijington Sep 18, 2024
590d8df
Shift to TypedBindings
bijington Sep 18, 2024
39df165
Keep disabling IL2092 for NET9_0
bijington Sep 18, 2024
39de8a0
Mark types as Dynamically accessed
bijington Sep 18, 2024
51dc62d
Merge branch 'main' into feature/sl-dotnet-nine
brminnick Sep 19, 2024
9514390
Patch up Analyzer unit tests
bijington Sep 19, 2024
5677465
Fix the AvatarView unit tests
bijington Sep 19, 2024
0e90207
Suppress warning disable IL2026
bijington Sep 19, 2024
0674abf
Update comments in Camera project
bijington Sep 19, 2024
446ed60
Update src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharp…
bijington Sep 19, 2024
7e02482
Update src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharp…
bijington Sep 19, 2024
8f1ab91
Include preview builds for benchmarks
bijington Sep 19, 2024
18e5892
Merge branch 'feature/sl-dotnet-nine' of github.com:CommunityToolkit/…
bijington Sep 19, 2024
d430867
Remove Obsolete code
brminnick Sep 19, 2024
bb378bd
Remove pragma now that unsafe code has been removed
brminnick Sep 19, 2024
92213aa
Update ICommunityToolkitBehavior.shared.cs
brminnick Sep 19, 2024
dce03ba
Update Expander.shared.cs
brminnick Sep 19, 2024
bc7d67b
`MainPage` -> `Windows[0].Page`
brminnick Sep 19, 2024
6d80b85
use `override CreateWindow(IActivationState)` to initialize AppShell
brminnick Sep 23, 2024
0756b7a
Increase to Xcode 16
brminnick Sep 26, 2024
a9e6143
Make use of a TypedBinding instance to workaround current limitations
bijington Oct 2, 2024
7a42193
Merge branch 'main' into feature/sl-dotnet-nine
bijington Oct 2, 2024
9303b48
Remove ifdef
brminnick Oct 4, 2024
de624c6
Enable `NuGetAudit`
brminnick Oct 14, 2024
39d1408
Add WarningsAsErrors for `NuGetAudit`
brminnick Oct 14, 2024
8dec573
Merge branch 'main' into feature/sl-dotnet-nine
brminnick Oct 15, 2024
83ba19a
Remove Obsolete PopupService method
brminnick Oct 15, 2024
8bdbc6f
Update for .NET 9 RC 2
brminnick Oct 15, 2024
4dbaf75
Merge branch 'main' into feature/sl-dotnet-nine
brminnick Oct 15, 2024
189c16d
Update Android dependencies
brminnick Oct 15, 2024
5daf804
Remove unrequired NuGet Packages
brminnick Oct 15, 2024
b66ae83
Fix Vulnerabilities
brminnick Oct 15, 2024
9be58a7
Merge branch 'main' into feature/sl-dotnet-nine
brminnick Oct 15, 2024
c0b7a6e
Resolve NuGet Dependency Conflicts
brminnick Oct 15, 2024
552c31c
Remove reflection
brminnick Oct 16, 2024
e1e3f5e
Fix `Camera` Android Dependencies
brminnick Oct 16, 2024
9a0b537
Refactor return statement
brminnick Oct 16, 2024
2f20c4a
Fix nullability error
brminnick Oct 16, 2024
6f2817c
Merge branch 'feature/sl-dotnet-nine' of https://github.com/Community…
brminnick Oct 16, 2024
1996cd5
Update AppShell.xaml
brminnick Oct 16, 2024
e5bc87b
Increase to RC2
brminnick Oct 16, 2024
b6841ce
Use `static`
brminnick Oct 16, 2024
ecc7d50
Merge branch 'main' into feature/sl-dotnet-nine
brminnick Oct 16, 2024
e119e53
Use `private protected` constructor
brminnick Oct 16, 2024
f2a36fd
Stop automatically assigning Behavior BindingContext
brminnick Oct 16, 2024
a9d4d38
Merge branch 'feature/sl-dotnet-nine' of https://github.com/Community…
brminnick Oct 16, 2024
7c004e4
Remove References to `TrySetBindingContextToAttachedViewBindingContext`
brminnick Oct 16, 2024
a5f0e86
Update BaseBehaviorTest.cs
brminnick Oct 16, 2024
c2bbb86
Refactor GravatarImageSource
brminnick Oct 16, 2024
0bae474
Update CommunityToolkit.Maui.Sample.csproj
brminnick Oct 16, 2024
cf4e34c
Merge branch 'feature/sl-dotnet-nine' of https://github.com/Community…
brminnick Oct 16, 2024
3210586
Update for CsWinRT1028, CsWinRT1030, XC0045, and XC0103
brminnick Oct 16, 2024
0594549
Use `partial` for source generators
brminnick Oct 16, 2024
298e12b
Use Syntax Highlighting for code blocks
brminnick Oct 16, 2024
eddf68f
Removed duplicate string
brminnick Oct 16, 2024
df98a42
Remove References to Application.Current.MainPage
brminnick Oct 16, 2024
0251dcf
Fix typos
brminnick Oct 16, 2024
47fcdd8
Update samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sam…
brminnick Oct 16, 2024
f6cddbd
Update samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/Expa…
brminnick Oct 16, 2024
7d0d182
Fix Find + Replace typo
brminnick Oct 16, 2024
cdfba47
Remove unused namespace
brminnick Oct 16, 2024
05dd7ec
Remove `MainPage`
brminnick Oct 16, 2024
c917bd0
Add BindingContext to Behaviors in Sample App
brminnick Oct 17, 2024
ce8deb8
Increase Android SupportedOSPlatformVersion to 26
brminnick Oct 17, 2024
1f9c06d
Fix XAML Warnings
brminnick Oct 17, 2024
0272350
Use `macos-15-arm64`
brminnick Oct 27, 2024
32ecaab
Update azure-pipelines.yml
brminnick Oct 27, 2024
26d43e1
Use Xcode version `16`
brminnick Oct 27, 2024
72857ba
Revert back to macOS14
brminnick Oct 27, 2024
eb6ac01
Merge branch 'main' into feature/sl-dotnet-nine
jfversluis Oct 31, 2024
810b69c
Use BindingMode.OneWay
brminnick Oct 31, 2024
7b52c4a
Fix PopupService Tests
brminnick Oct 31, 2024
8bfc313
Fix AvatarView Tests
brminnick Oct 31, 2024
813c143
Fix AvatarView Tests
brminnick Oct 31, 2024
43ffcdb
Fix ParentWindowTests
brminnick Oct 31, 2024
3c1acca
Resolve AppTheme Tests
brminnick Oct 31, 2024
d2b9d8b
Add `[RequiresUnreferencedCode]` attribute to `ValidationBehavior`
brminnick Nov 1, 2024
bb36172
Update BehaviorsGalleryPage.cs
brminnick Nov 1, 2024
c762fb2
`dotnet format`
brminnick Nov 1, 2024
6aedd2e
Remove `Obsolete` attributes from `dotnet format`
brminnick Nov 1, 2024
2cd0c7a
Update `Microsoft.CodeAnalysis.CSharp.Workspaces`
brminnick Nov 4, 2024
ac437a6
Update Sample App NuGet Packages to .NET 9
brminnick Nov 4, 2024
e3e6211
Remove Duplicate NuGet Packages
brminnick Nov 4, 2024
b916b28
Merge branch 'main' into feature/sl-dotnet-nine
brminnick Nov 5, 2024
c19b3d6
Fix https://github.com/CommunityToolkit/Maui/issues/2109
brminnick Nov 5, 2024
b4869b7
Fix CameraView warnings
brminnick Nov 5, 2024
2dd57b5
Refactor ShowKeyboardAsync
brminnick Nov 5, 2024
27e218e
Refactor Code + Performance Improvements
brminnick Nov 5, 2024
928b19f
`dotnet format`
brminnick Nov 5, 2024
4284967
Remove unused using directives
brminnick Nov 5, 2024
3ef7ef9
Add `[EditorBrowsable(EditorBrowsableState.Never)]`
brminnick Nov 5, 2024
a983d56
Use `BindingBase.Create`
brminnick Nov 6, 2024
8d54b5e
Merge branch 'main' into feature/sl-dotnet-nine
brminnick Nov 6, 2024
8e00d1c
Update Options.cs
brminnick Nov 6, 2024
800dd72
Merge branch 'main' into feature/sl-dotnet-nine
brminnick Nov 7, 2024
e066f17
Renaming and changing ValidationFlags.ValidateOnFocus and ValidateOnU…
CliffAgius Nov 7, 2024
7713aab
Fix compiled bindings For MediaElement
ne0rrmatrix Nov 8, 2024
01575bb
Fix Windows crash on exiting Page or Application when using Media Ele…
ne0rrmatrix Nov 8, 2024
fdd8168
Remove trace log added by accident
ne0rrmatrix Nov 8, 2024
5924b2a
Fix `MultiValidationBehavior` compiled bindings
ne0rrmatrix Nov 8, 2024
9d63b86
Fix `MultiConverterPage` Compiled Bindings
ne0rrmatrix Nov 8, 2024
36b6b72
Remove `x:DataType` from several lines
ne0rrmatrix Nov 8, 2024
95b2ff1
Add using to enable support for logging
ne0rrmatrix Nov 8, 2024
23fe7c9
Merge branch 'main' into feature/sl-dotnet-nine
brminnick Nov 8, 2024
2248d70
Fix `ColorsConverterPage` compiled bindings. This casts the `x:DataTy…
ne0rrmatrix Nov 8, 2024
da066cd
Set `x:DataType` in `AppShell.xaml` to support compiled bindings
ne0rrmatrix Nov 9, 2024
752e8a1
Update `LazyViewPage` to add support for compiled bindings
ne0rrmatrix Nov 9, 2024
0fdb280
Update `EmailValidationBehaviorPage` to support Compiled bindings
ne0rrmatrix Nov 9, 2024
e538eed
Update params collections
brminnick Nov 10, 2024
0eb39a8
Update Xcode logic
brminnick Nov 10, 2024
7d609a1
Update azure-pipelines.yml
brminnick Nov 10, 2024
8cb078c
Update azure-pipelines.yml
brminnick Nov 10, 2024
6e5c417
Update azure-pipelines.yml
brminnick Nov 10, 2024
2238534
Increase to macOS-15
brminnick Nov 11, 2024
67a7caf
Add SourceLink
brminnick Nov 11, 2024
a3a83aa
Update CommunityToolkit.Maui.Sample.csproj
brminnick Nov 11, 2024
0260cef
Merge branch 'main' into feature/sl-dotnet-nine
brminnick Nov 11, 2024
7065b2d
Update PopupServiceTests.cs
brminnick Nov 11, 2024
5bda93d
Resolve Failing DrawingView Unit Tests
brminnick Nov 11, 2024
b0c9ee0
Use Partial Properties
brminnick Nov 12, 2024
f4fb321
Support `CarouselViewHandler2` + `CollectionViewHandler2` for MediaEl…
brminnick Nov 12, 2024
700a82b
Update comment text
brminnick Nov 12, 2024
503cf4e
Update for .NET 9 GA
brminnick Nov 12, 2024
8bd0184
Update samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sam…
brminnick Nov 12, 2024
cc5a669
Add `x:DataType` for Compiled Bindings
brminnick Nov 12, 2024
acf646c
Update NuGet Packages
brminnick Nov 12, 2024
90b6baa
Remove reference
brminnick Nov 12, 2024
5762236
Update CommunityToolkit.Maui.Sample.csproj
brminnick Nov 12, 2024
1d524c3
Sort alphabetically
brminnick Nov 12, 2024
f30f541
Set Behavior BindingContext
brminnick Nov 12, 2024
660c27d
Merge branch 'feature/sl-dotnet-nine' of https://github.com/Community…
brminnick Nov 12, 2024
bd8d383
Enable IServiceProvider
brminnick Nov 12, 2024
89eb97b
Fix compareconverter demo
brminnick Nov 12, 2024
6c5816e
Fix Crash
brminnick Nov 12, 2024
bdc00fc
Fix Behavior Binding
brminnick Nov 12, 2024
28a9e54
Add Behavior BindingContext
brminnick Nov 12, 2024
e1fdb07
Add behavior BindingContext
brminnick Nov 12, 2024
6363975
Fix DrawingView sample
brminnick Nov 13, 2024
ded531f
Use Enum.IsDefined<T>
brminnick Nov 13, 2024
e2fc7e7
Fix Expander Binding
brminnick Nov 13, 2024
67fb9a4
Update Maps for async/await + Trimming
brminnick Nov 13, 2024
9fce650
Catch Element Not Found Exception
brminnick Nov 13, 2024
d53c847
Modify CompareConverter signature to match IsInRangeConverter
bijington Nov 13, 2024
f043544
Update Directory.Build.props
brminnick Nov 14, 2024
0e991c2
run `dotnet workload update` following `dotnet workload install maui`
brminnick Nov 14, 2024
c240aea
Update azure-pipelines.yml
brminnick Nov 15, 2024
7d2f431
Revert "Update azure-pipelines.yml"
brminnick Nov 15, 2024
c84e785
Use Primary Constructor, Update Formatting
brminnick Nov 15, 2024
bfb9629
Disable warnings on compiler-generated code
brminnick Nov 15, 2024
b96594e
Prevent Usage with Microsoft.Maui.Controls v10.0.0+
brminnick Nov 17, 2024
e8a1d5f
Organize Build props
brminnick Nov 17, 2024
0029b45
Add `[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]`
brminnick Nov 17, 2024
cb41208
Merge branch 'main' into feature/sl-dotnet-nine
brminnick Nov 17, 2024
3f31948
Merge branch 'main' into feature/sl-dotnet-nine
brminnick Nov 20, 2024
f802f5f
Update NuGet Packages
brminnick Nov 22, 2024
9841ee0
Add `//lang=csharp` to raw string literals
brminnick Nov 26, 2024
69eee10
Implement `TheoryData`
brminnick Nov 26, 2024
d723a14
Use `field` keyword
brminnick Nov 26, 2024
074baa2
Add Xunit Usage Analyzers
brminnick Nov 26, 2024
662c5ed
Add Xunit Assertion Analyzers
brminnick Nov 26, 2024
71f0a02
Add Xunit Extensibility Analyzers
brminnick Nov 26, 2024
a79e8cf
Resolve Trimming Errors
brminnick Nov 26, 2024
ccc8392
Bump Xcode to 16.1
brminnick Nov 27, 2024
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
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project>
<PropertyGroup>
<NetVersion>net8.0</NetVersion>
<MauiPackageVersion>8.0.71</MauiPackageVersion>
<NetVersion>net9.0</NetVersion>
<MauiPackageVersion>9.0.0-rc.1.24453.9</MauiPackageVersion>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
8 changes: 4 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ variables:
NugetPackageVersionCamera: '$(CurrentSemanticVersion)'
NugetPackageVersionMediaElement: '$(CurrentSemanticVersion)'
NugetPackageVersionMaps: '$(CurrentSemanticVersion)'
TOOLKIT_NET_VERSION: '8.0.303'
LATEST_NET_VERSION: '8.0.x'
TOOLKIT_NET_VERSION: '9.0.100-rc.1.24452.12'
LATEST_NET_VERSION: '9.0.x'
PathToLibrarySolution: 'src/CommunityToolkit.Maui.sln'
PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Sample.sln'
PathToCommunityToolkitCsproj: 'src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj'
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
inputs:
packageType: 'sdk'
version: '$(LATEST_NET_VERSION)'
includePreviewVersions: false
includePreviewVersions: true
brminnick marked this conversation as resolved.
Show resolved Hide resolved

- task: CmdLine@2
displayName: 'Install Latest .NET MAUI Workload'
Expand Down Expand Up @@ -206,7 +206,7 @@ jobs:
inputs:
packageType: 'sdk'
version: '$(TOOLKIT_NET_VERSION)'
includePreviewVersions: false
includePreviewVersions: true
brminnick marked this conversation as resolved.
Show resolved Hide resolved

- task: CmdLine@2
displayName: 'Install .NET MAUI Workload $(TOOLKIT_NET_VERSION)'
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "8.0.303",
"version": "9.0.100-rc.1.24452.12",
"rollForward": "latestFeature",
"allowPrerelease": false
"allowPrerelease": true
brminnick marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class Test : CSharpAnalyzerTest<TAnalyzer, Microsoft.CodeAnalysis.Testing
{
public Test(params Type[] assembliesUnderTest)
{
#if NET8_0
ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net80;
#if NET9_0
ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net90;
#else
#error ReferenceAssemblies must be updated to current version of .NET
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ protected class Test : CSharpCodeFixTest<TAnalyzer, TCodeFix, DefaultVerifier>
{
public Test(params Type[] assembliesUnderTest)
{
#if NET8_0
ReferenceAssemblies = ReferenceAssemblies.Net.Net80;
#if NET9_0
ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net90;
#else
#error ReferenceAssemblies must be updated to current version of .NET
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,25 @@
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
<PackageReference Include="Xamarin.AndroidX.Camera.View" Version="1.3.1.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.3.1.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.View" Version="1.3.4.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.3.4.1" />

<!-- Xamarin.AndroidX.Camera 1.3.1.1 depends on Xamarin.AndroidX.Lifecycle.LiveData 2.7.0.1:
<!-- Xamarin.AndroidX.Camera 1.3.4.1 depends on Xamarin.AndroidX.Lifecycle.LiveData 2.8.4.0:
https://www.nuget.org/packages/Xamarin.AndroidX.Camera.Core/#dependencies-body-tab
However, Dotnet MAUI still implicitly references Xamarin.AndroidX.Lifecycle.LiveData 2.6.1.3:
However, Dotnet MAUI still implicitly references Xamarin.AndroidX.Lifecycle.LiveData 2.8.3.1:
https://github.com/dotnet/maui/blob/main/eng/AndroidX.targets
This causes build error "Detected package downgrade":
https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1605
Workaround: add a package reference to the higher version of the package. Possibly can be removed when MAUI bumps the implicit reference version.
-->
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.7.0.1" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.8.4.0" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.8.4.0" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData.Core" Version="2.8.4.0" />

<!--Adding the above package reference requires Workaround for https://github.com/xamarin/AndroidX/issues/800#issuecomment-1774639627 -->
<!-- Tracking issue https://github.com/xamarin/AndroidX/issues/764 -->
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.4.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.4.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.4.3.1" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.4.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void ConstructorTest()
avatarView.TextColor.Should().Be(Colors.Pink);
avatarView.Text.Should().Be("GL");
avatarView.TextTransform.Should().Be(TextTransform.Lowercase);
Size request = avatarView.Measure(double.PositiveInfinity, double.PositiveInfinity).Request;
Size request = avatarView.Measure(double.PositiveInfinity, double.PositiveInfinity);
request.Width.Should().Be(10);
request.Height.Should().Be(20);
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public void DefaultFontSize()
public void DefaultHeightRequest()
{
var avatarView = new Maui.Views.AvatarView();
Size request = avatarView.Measure(double.PositiveInfinity, double.PositiveInfinity).Request;
Size request = avatarView.Measure(double.PositiveInfinity, double.PositiveInfinity);
request.Height.Should().Be(AvatarViewDefaults.DefaultHeightRequest);
}

Expand Down Expand Up @@ -228,7 +228,7 @@ public void DefaultProperties()
public void DefaultWidthRequest()
{
var avatarView = new Maui.Views.AvatarView();
Size request = avatarView.Measure(double.PositiveInfinity, double.PositiveInfinity).Request;
Size request = avatarView.Measure(double.PositiveInfinity, double.PositiveInfinity);
request.Width.Should().Be(AvatarViewDefaults.DefaultWidthRequest);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public class EventToCommandBehavior : BaseBehavior<VisualElement>
public static readonly BindableProperty EventArgsConverterProperty =
BindableProperty.Create(nameof(EventArgsConverter), typeof(IValueConverter), typeof(EventToCommandBehavior));

#pragma warning disable IL2026 // NET9.0 - check if this can be fixed
brminnick marked this conversation as resolved.
Show resolved Hide resolved
readonly MethodInfo eventHandlerMethodInfo = typeof(EventToCommandBehavior).GetTypeInfo().GetDeclaredMethod(nameof(OnTriggerHandled)) ?? throw new InvalidOperationException($"Cannot find method {nameof(OnTriggerHandled)}");
#pragma warning restore IL2026

Delegate? eventHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ internal bool TrySetBindingContextToAttachedViewBindingContext()
return false;
}

#pragma warning disable IL2026 // NET9.0 - check if this can be fixed
brminnick marked this conversation as resolved.
Show resolved Hide resolved
behavior.SetBinding(BindableObject.BindingContextProperty, new Binding
{
Source = View,
Path = BindableObject.BindingContextProperty.PropertyName
});
#pragma warning restore IL2026

return true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,13 @@ async Task OnValuePropertyChanged(CancellationToken token)

void OnValuePropertyNamePropertyChanged()
{
#pragma warning disable IL2026 // NET9.0 - check if this can be fixed
brminnick marked this conversation as resolved.
Show resolved Hide resolved
SetBinding(ValueProperty, new Binding
{
Path = ValuePropertyName,
Source = View
});
#pragma warning restore IL2026
}

async ValueTask UpdateStateAsync(VisualElement? view, ValidationFlags flags, bool isForced, CancellationToken? parentToken = null)
Expand Down Expand Up @@ -410,13 +412,8 @@ async ValueTask UpdateStateAsync(VisualElement? view, ValidationFlags flags, boo
void UpdateStyle(in VisualElement view, bool isValid)
{
VisualStateManager.GoToState(view, isValid ? ValidVisualState : InvalidVisualState);

if ((ValidStyle ?? InvalidStyle) == null)
{
return;
}

view.Style = isValid ? ValidStyle : InvalidStyle;

view.Style = (isValid ? ValidStyle : InvalidStyle) ?? view.Style;
}

void ResetValidationTokenSource(CancellationTokenSource? newTokenSource)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public interface ICommunityToolkitValueConverter : IValueConverter


/// <inheritdoc />
#if NET8_0 // Should be fixed in .NET 9
#if NET8_0 || NET9_0 // Should be fixed in .NET 9 - Not fixed in the first RC
brminnick marked this conversation as resolved.
Show resolved Hide resolved
#pragma warning disable IL2092
#endif
object? IValueConverter.Convert(object? value, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type targetType, object? parameter, CultureInfo culture) =>
Expand All @@ -61,7 +61,7 @@ public interface ICommunityToolkitValueConverter : IValueConverter
/// <inheritdoc />
object? IValueConverter.ConvertBack(object? value, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type targetType, object? parameter, CultureInfo culture) =>
ConvertBack(value, targetType, parameter, culture);
#if NET8_0
#if NET8_0 || NET9_0
#pragma warning restore IL2092
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace CommunityToolkit.Maui.Converters;
public sealed class IsInRangeConverter : IsInRangeConverter<IComparable, object>;

/// <summary>Converts the incoming value to a <see cref="bool"/> indicating whether or not the value is within a range.</summary>
public abstract class IsInRangeConverter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] TValue, TReturnObject> : BaseConverterOneWay<TValue, object> where TValue : IComparable
public abstract class IsInRangeConverter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TValue, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TReturnObject> : BaseConverterOneWay<TValue, object> where TValue : IComparable
{
/// <summary>
/// Bindable property for <see cref="FalseObject"/>
Expand Down
4 changes: 2 additions & 2 deletions src/CommunityToolkit.Maui/Converters/MultiConverter.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class MultiConverter : List<ICommunityToolkitValueConverter>, ICommunityT
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
Type ICommunityToolkitValueConverter.ToType => throw new NotSupportedException($"{nameof(ICommunityToolkitMultiValueConverter)} does not implement {nameof(ICommunityToolkitValueConverter.ToType)}");

#if NET8_0 // Should be fixed in .NET 9
#if NET8_0 || NET9_0 // Should be fixed in .NET 9
#pragma warning disable IL2092
#endif
/// <summary>
Expand All @@ -44,7 +44,7 @@ public class MultiConverter : List<ICommunityToolkitValueConverter>, ICommunityT
/// <returns>N/A</returns>
public object? ConvertBack(object? value, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type targetType, object? parameter, System.Globalization.CultureInfo? culture)
=> throw new NotSupportedException("Impossible to revert to original value. Consider setting BindingMode to OneWay.");
#if NET8_0 // Should be fixed in .NET 9
#if NET8_0 || NET9_0 // Should be fixed in .NET 9
#pragma warning restore IL2092
#endif
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace CommunityToolkit.Maui.ImageSources;
using Microsoft.Maui.Controls.Internals;

namespace CommunityToolkit.Maui.ImageSources;

using CommunityToolkit.Maui.Extensions;
using Microsoft.Maui.Controls;
Expand Down Expand Up @@ -143,8 +145,8 @@ protected override void OnParentSet()
return;
}

SetBinding(ParentWidthProperty, new Binding(nameof(VisualElement.Width), BindingMode.OneWay, source: parentElement));
SetBinding(ParentHeightProperty, new Binding(nameof(VisualElement.Height), BindingMode.OneWay, source: parentElement));
SetBinding(ParentWidthProperty, BindingBase.Create<VisualElement, double>(static p => p.Width, source: parentElement));
SetBinding(ParentHeightProperty, BindingBase.Create<VisualElement, double>(static p => p.Height, source: parentElement));
}

static string DefaultGravatarName(DefaultImage defaultGravatar) => defaultGravatar switch
Expand Down
4 changes: 2 additions & 2 deletions src/CommunityToolkit.Maui/Views/AvatarView.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public AvatarView()
CornerRadius = new CornerRadius(AvatarViewDefaults.DefaultCornerRadius.TopLeft, AvatarViewDefaults.DefaultCornerRadius.TopRight, AvatarViewDefaults.DefaultCornerRadius.BottomLeft, AvatarViewDefaults.DefaultCornerRadius.BottomRight),
};
Content = avatarLabel;
avatarImage.SetBinding(WidthRequestProperty, new Binding(nameof(WidthRequest), source: this));
avatarImage.SetBinding(HeightRequestProperty, new Binding(nameof(HeightRequest), source: this));
avatarImage.SetBinding(WidthRequestProperty, BindingBase.Create<VisualElement, double>(static p => p.WidthRequest, source: this));
avatarImage.SetBinding(HeightRequestProperty, BindingBase.Create<VisualElement, double>(static p => p.HeightRequest, source: this));
}

/// <summary>Gets or sets the control font.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void OnContentPropertyChanged(BindableObject bindable, object oldValue, o
var expander = (Expander)bindable;
if (newValue is View view)
{
view.SetBinding(IsVisibleProperty, new Binding(nameof(IsExpanded), source: bindable));
view.SetBinding(IsVisibleProperty, BindingBase.Create<Expander, bool>(static p => p.IsExpanded, source: expander));

expander.ContentGrid.Remove(oldValue);
expander.ContentGrid.Add(newValue);
Expand Down
Loading