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

Enable Nullable #1009

Merged
merged 150 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
8a74608
Enable Nullable on Unit Tests (#1008)
TheCodeTraveler Mar 3, 2021
968bdc0
Enable Nullability on Xamarin.CommunityToolkit.Markup (#1013)
TheCodeTraveler Mar 4, 2021
1e07fe6
Enable Nullability on Xamarin.CommunityToolkit.Sample (#1014)
TheCodeTraveler Mar 4, 2021
25bc636
Enable Nullability for Android, GTK, iOS, Tizen, UWP & WPF Sample Pro…
TheCodeTraveler Mar 4, 2021
568ef2e
Enable Nullability on Xamarin.CommunityToolkit (#1016)
TheCodeTraveler Mar 4, 2021
11dd05b
Enable Nullable on XamarinCommunityToolkit (#1023)
TheCodeTraveler Mar 5, 2021
d3b511d
Fix Unit Tests (#1036)
TheCodeTraveler Mar 5, 2021
bb115bd
Merge branch 'develop' into Enable-Nullable
TheCodeTraveler Mar 5, 2021
7d4be45
Resolve Nullable in SideMenuView
TheCodeTraveler Mar 5, 2021
2528906
Move <Nullable>enable</Nullable> to Directory.Build.props
TheCodeTraveler Mar 5, 2021
198b1f1
Update Xamarin.CommunityToolkit.Sample.csproj
TheCodeTraveler Mar 5, 2021
fd363a0
Revert Designer.cs
TheCodeTraveler Mar 5, 2021
18d0f02
Update Xamarin.CommunityToolkit.Sample.csproj
TheCodeTraveler Mar 5, 2021
ada794a
Update ItemSelectedEventArgsConverter_Tests.cs
TheCodeTraveler Mar 5, 2021
5f279d4
Update SearchViewModel.cs
TheCodeTraveler Mar 5, 2021
30d2cb4
Update ItemTappedEventArgsConverter_Tests.cs
TheCodeTraveler Mar 5, 2021
efe5551
Update Xamarin.CommunityToolkit.UnitTests.csproj
TheCodeTraveler Mar 5, 2021
afe4a3c
Add Nullability
TheCodeTraveler Mar 6, 2021
b4314fd
Resolve Compiler Warnings
TheCodeTraveler Mar 6, 2021
7d4a74e
Ignore Closing square brackets should be spaced correctly
TheCodeTraveler Mar 6, 2021
ce49c6d
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Behaviors/Implie…
TheCodeTraveler Mar 6, 2021
4ed10d8
Update CameraFragment.android.cs
TheCodeTraveler Mar 6, 2021
96b58f8
Merge branch 'Enable-Nullable' of https://github.com/xamarin/XamarinC…
TheCodeTraveler Mar 6, 2021
2def0b1
Update CameraFragment.android.cs
TheCodeTraveler Mar 6, 2021
8174fb4
Update ImpliedOrderGridBehavior.shared.cs
TheCodeTraveler Mar 6, 2021
f7ca1d3
Update MaskedBehavior.shared.cs
TheCodeTraveler Mar 6, 2021
285b291
Update PopupRenderer.uwp.cs
TheCodeTraveler Mar 6, 2021
ec66139
Use .NET 5.0
TheCodeTraveler Mar 6, 2021
6e26f09
Merge remote-tracking branch 'origin/develop' into Enable-Nullable
TheCodeTraveler Mar 6, 2021
3a75a59
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
e246e06
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
421e331
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
344445e
Add UWP to Release Build
TheCodeTraveler Mar 6, 2021
24348dc
Update Nullability
TheCodeTraveler Mar 6, 2021
7670900
Merge branch 'Enable-Nullable' of https://github.com/xamarin/XamarinC…
TheCodeTraveler Mar 6, 2021
9231ef5
Update Nullablity
TheCodeTraveler Mar 6, 2021
5017336
Update TabView.shared.cs
TheCodeTraveler Mar 6, 2021
e391b9c
Update Nullability
TheCodeTraveler Mar 6, 2021
2666435
Revert "Update Nullability"
TheCodeTraveler Mar 6, 2021
1708644
Resolved Nullable
TheCodeTraveler Mar 6, 2021
20e5818
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
77226bf
Revert UWP Build Properties
TheCodeTraveler Mar 6, 2021
9ce3ce3
Merge branch 'Enable-Nullable' of https://github.com/xamarin/XamarinC…
TheCodeTraveler Mar 6, 2021
e3c3da1
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
0842280
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
1fe2a4a
Revert "Update azure-pipelines.yml"
TheCodeTraveler Mar 6, 2021
9c0674d
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
26d2166
Revert "Revert UWP Build Properties"
TheCodeTraveler Mar 6, 2021
2d88bef
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
c4a46b5
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
06b4d9c
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
5843c70
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
6792b97
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
4eb36f4
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
b8714b5
Revert "Update azure-pipelines.yml"
TheCodeTraveler Mar 6, 2021
e41a477
Update azure-pipelines.yml
TheCodeTraveler Mar 6, 2021
5aa2259
Revert "Update azure-pipelines.yml"
TheCodeTraveler Mar 6, 2021
520f90f
Fix ValidationBehavior.ForceValidate and ValidationBehavior.DefaultFo…
TheCodeTraveler Mar 6, 2021
36a5e35
Update SelectAllTextEffect.ios.cs
TheCodeTraveler Mar 6, 2021
661ed20
Remove Nullabilty from LocalizedString.generator
TheCodeTraveler Mar 6, 2021
3270251
Update MediaElementRenderer.ios.cs
TheCodeTraveler Mar 6, 2021
5deca29
Update PopupRenderer.uwp.cs
TheCodeTraveler Mar 6, 2021
4c0582d
Update PopupRenderer.ios.cs
TheCodeTraveler Mar 6, 2021
885db12
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Views/Snackbar/H…
TheCodeTraveler Mar 6, 2021
00b615b
Update TranslateExtension.shared.cs
TheCodeTraveler Mar 6, 2021
a0e5b80
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Views/Snackbar/S…
TheCodeTraveler Mar 6, 2021
12a9dfd
Merge branch 'Enable-Nullable' of https://github.com/xamarin/XamarinC…
TheCodeTraveler Mar 6, 2021
a374685
Update Logic
TheCodeTraveler Mar 6, 2021
01ef3e6
Fix Failing ICommand Tests
TheCodeTraveler Mar 6, 2021
0f37697
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Views/Snackbar/S…
TheCodeTraveler Mar 6, 2021
ac6703b
Throw Faulted Task
TheCodeTraveler Mar 6, 2021
cb156ae
Use Cast instead of Pattern Matching
TheCodeTraveler Mar 6, 2021
8b34050
Update RangeSlider.shared.cs
TheCodeTraveler Mar 6, 2021
7166c7e
Fix missing semi-colons
TheCodeTraveler Mar 7, 2021
bb286d0
Throw InvalidOperationException in LocalizationResourceManager
TheCodeTraveler Mar 7, 2021
ae2f319
Make TranslateExtension.StringFormat nullable
TheCodeTraveler Mar 7, 2021
c772225
Update UserStoppedTypingBehavior.shared.cs
TheCodeTraveler Mar 7, 2021
a5ce463
Update SearchPage.logic.cs
TheCodeTraveler Mar 7, 2021
298f20a
Update TouchEffectCollectionViewPage.xaml.cs
TheCodeTraveler Mar 7, 2021
d71f459
Update AppResources.Designer.cs
TheCodeTraveler Mar 7, 2021
48b6157
Update AppResources.Designer.cs
TheCodeTraveler Mar 7, 2021
ca47912
Update EnumToBoolConverterViewModel.cs
TheCodeTraveler Mar 7, 2021
01d70cd
Update EnumToBoolConverter_Tests.cs
TheCodeTraveler Mar 7, 2021
af1fd4f
Update IntToBoolConverter_Tests.cs
TheCodeTraveler Mar 7, 2021
677ff93
Update InvertedBoolConverter_Tests.cs
TheCodeTraveler Mar 7, 2021
256b64e
Update IsNotNullOrEmptyConverter_Tests.cs
TheCodeTraveler Mar 7, 2021
8154db4
Update MultiConverter_Tests.cs
TheCodeTraveler Mar 7, 2021
88eff30
Update NotEqualConverter_Tests.cs
TheCodeTraveler Mar 7, 2021
2cf5d0f
Update TextCaseConverter_Tests.cs
TheCodeTraveler Mar 7, 2021
4bd5e2c
Update MockPlatformServices.cs
TheCodeTraveler Mar 7, 2021
83d7606
Update MockPlatformServices.cs
TheCodeTraveler Mar 7, 2021
c6f084b
Update Namespace_Tests.cs
TheCodeTraveler Mar 7, 2021
7d27f9b
Update ObservableRangeCollection_Tests.cs
TheCodeTraveler Mar 7, 2021
487f2a1
Update ObservableRangeCollection_Tests.cs
TheCodeTraveler Mar 7, 2021
5c13f22
Use `async Task` instead of `async void`
TheCodeTraveler Mar 7, 2021
bd1b59b
Update MultiValidationBehavior.shared.cs
TheCodeTraveler Mar 7, 2021
2432020
Update EnumToBoolConverter.shared.cs
TheCodeTraveler Mar 7, 2021
fa27ca2
Update EnumToBoolConverter.shared.cs
TheCodeTraveler Mar 7, 2021
bdb6b1a
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Converters/NotEq…
TheCodeTraveler Mar 7, 2021
b0ecb6d
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Converters/State…
TheCodeTraveler Mar 7, 2021
de4efec
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Converters/TextC…
TheCodeTraveler Mar 7, 2021
457a623
Update IconTintColorEffectRouter.android.cs
TheCodeTraveler Mar 7, 2021
3efe1e1
Merge branch 'Enable-Nullable' of https://github.com/xamarin/XamarinC…
TheCodeTraveler Mar 7, 2021
9ebe924
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Effects/SelectAl…
TheCodeTraveler Mar 7, 2021
0e318c6
Update SelectAllTextEffect.android.cs
TheCodeTraveler Mar 7, 2021
93d57a8
Update SelectAllTextEffect.ios.cs
TheCodeTraveler Mar 7, 2021
0107491
Update PlatformTouchEffect.ios.cs
TheCodeTraveler Mar 7, 2021
42ca9eb
Update PlatformTouchEffect.uwp.cs
TheCodeTraveler Mar 7, 2021
2f80391
Update PlatformTouchEffect.uwp.cs
TheCodeTraveler Mar 7, 2021
aceb9d3
Update PlatformTouchEffect.macos.cs
TheCodeTraveler Mar 7, 2021
6dd2d63
Update PlatformTouchEffect.uwp.cs
TheCodeTraveler Mar 7, 2021
dd2283b
Update PlatformTouchEffect.uwp.cs
TheCodeTraveler Mar 7, 2021
166c33f
Ensure nullable results from BindableProperties are still resolved
TheCodeTraveler Mar 7, 2021
937c450
Update ImageResourceExtension.shared.cs
TheCodeTraveler Mar 7, 2021
1ba3ef6
Update BaseCommand.android.cs
TheCodeTraveler Mar 7, 2021
b9f1cbd
Use protected private constructor for BaseCommand
TheCodeTraveler Mar 7, 2021
f275d63
Update BadgeView.shared.cs
TheCodeTraveler Mar 7, 2021
ec44038
Update CameraFragment.android.cs
TheCodeTraveler Mar 7, 2021
48fbe2e
Fix Android Media Bugs
TheCodeTraveler Mar 7, 2021
3b7e4ec
Update async/await
TheCodeTraveler Mar 7, 2021
ddc53a0
Update CameraView_Tests.cs
TheCodeTraveler Mar 7, 2021
20a599c
Update CameraView
TheCodeTraveler Mar 7, 2021
009ff80
Update UriTypeConverter.shared.cs
TheCodeTraveler Mar 7, 2021
a6e124d
Update PopupRenderer.uwp.cs
TheCodeTraveler Mar 7, 2021
d6df6db
Update PopoverArrowDirection.shared.cs
TheCodeTraveler Mar 7, 2021
e148598
Update PopoverArrowDirection.shared.cs
TheCodeTraveler Mar 7, 2021
51b2677
Update TabView.shared.cs
TheCodeTraveler Mar 7, 2021
fc35780
Improve AsyncCommand Tests
TheCodeTraveler Mar 7, 2021
e568686
Ensure Context is non nullable
TheCodeTraveler Mar 7, 2021
e9a4170
Remove Missing Translations
TheCodeTraveler Mar 8, 2021
a78b3f3
Fix async/await in TouchEffect.shared.cs
TheCodeTraveler Mar 9, 2021
b630f8f
Make Easing Nullable
TheCodeTraveler Mar 9, 2021
c842053
Update Samples
TheCodeTraveler Mar 9, 2021
18cccee
Fix Null Exception
TheCodeTraveler Mar 9, 2021
c0b6a1f
Resolve NullReferenceExceptions
TheCodeTraveler Mar 9, 2021
33aae0e
Make IBadgeAnimation Nullable
TheCodeTraveler Mar 9, 2021
3be195b
Add ShutterCommandValueCreator null check
TheCodeTraveler Mar 9, 2021
47c0fb1
Add Timeout to prevent race conditions from stalling tests
TheCodeTraveler Mar 9, 2021
32af4a3
Unsubscribe Event Handlers for AsyncCommand Tests
TheCodeTraveler Mar 9, 2021
f8db5a9
Update azure-pipelines.yml
TheCodeTraveler Mar 9, 2021
8cd4065
For WPF, Use Cross-Platform Implementation for `BaseCommand.IsMainThr…
TheCodeTraveler Feb 23, 2021
f373aad
Fix Null Reference
TheCodeTraveler Mar 9, 2021
9c020ca
Update ICommand_AsyncValueCommand_Tests.cs
TheCodeTraveler Mar 9, 2021
3b45f42
Add volatile keyword
TheCodeTraveler Mar 9, 2021
aced451
Update AsyncValueCommand_Tests.cs
TheCodeTraveler Mar 9, 2021
1894f0d
Remove Timeouts
TheCodeTraveler Mar 9, 2021
d80742e
Fix Event Unsubscription
TheCodeTraveler Mar 9, 2021
9ec6812
Add .ConfigureAwait(false);
TheCodeTraveler Mar 9, 2021
53cb61b
Run dotnet test serially
TheCodeTraveler Mar 9, 2021
219b877
Use SemaphoreSlim to prevent Race Conditions
TheCodeTraveler Mar 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,9 @@ csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true

# SA1011: Closing square brackets should be spaced correctly
dotnet_diagnostic.SA1011.severity = none

# CS4014: Because this call is not awaited, execution of the current method continues before the call is completed
dotnet_diagnostic.CS4014.severity = error
4 changes: 3 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<LangVersion>8.0</LangVersion>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
</PropertyGroup>


Expand Down
1 change: 0 additions & 1 deletion Xamarin.CommunityToolkit.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<Rule Id="SA1008" Action="Warning" />
<Rule Id="SA1009" Action="Warning" />
<Rule Id="SA1010" Action="Warning" />
<Rule Id="SA1011" Action="Warning" />
<Rule Id="SA1012" Action="Warning" />
<Rule Id="SA1013" Action="Warning" />
<Rule Id="SA1014" Action="Warning" />
Expand Down
54 changes: 35 additions & 19 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ variables:
#MONO_VERSION: 6_4_0
#XCODE_VERSION: 11.4
NETCORE_VERSION: '5.0.x'
NETCORE_TEST_VERSION: '5.0.x'
NETCORE_TEST_VERSION_3_1: '3.1.x'
NETCORE_TEST_VERSION_2_1: '2.1.x'
RunPoliCheck: 'false'
PathToCsproj: 'src/CommunityToolkit/Xamarin.CommunityToolkit/Xamarin.CommunityToolkit.csproj'
PathToMarkupCsproj: 'src/Markup/Xamarin.CommunityToolkit.Markup/Xamarin.CommunityToolkit.Markup.csproj'
PathToUnitTestCsproj: 'src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/Xamarin.CommunityToolkit.UnitTests.csproj'
PathToSln: 'samples/XCT.Sample.sln'

resources:
Expand Down Expand Up @@ -68,6 +70,21 @@ jobs:
pool:
vmImage: windows-2019
steps:
- task: UseDotNet@2
displayName: 'Install .NET SDK'
inputs:
version: $(NETCORE_VERSION)
includePreviewVersions: false
- task: UseDotNet@2
displayName: 'Install .NET 3.1 Test SDK'
inputs:
version: $(NETCORE_TEST_VERSION_3_1)
includePreviewVersions: false
- task: UseDotNet@2
displayName: 'Install .NET 2.1 Test SDK'
inputs:
version: $(NETCORE_TEST_VERSION_2_1)
includePreviewVersions: false
# if this is a tagged build, then update the version number
- powershell: |
$buildSourceBranch = "$(Build.SourceBranch)"
Expand Down Expand Up @@ -112,12 +129,10 @@ jobs:
# command: 'custom'
# custom: 'nuget'
# arguments: 'push --source https://nuget.pkg.github.com/xamarin/index.json --api-key $(GitHub.NuGet.Token) "$(Build.ArtifactStagingDirectory)\nuget\*.nupkg"'
- task: DotNetCoreCLI@2
displayName: Run Tests
- task: CmdLine@2
displayName: 'Run Unit Tests'
inputs:
command: test
projects: '**/*.UnitTests.csproj'
arguments: '--configuration Release --collect "Code coverage"'
script: dotnet test $(PathToUnitTestCsproj) -c Release --collect "Code coverage" -p:BuildInParallel=false
# publish the packages
- task: PublishBuildArtifacts@1
displayName: 'Publish Unsigned NuGets'
Expand Down Expand Up @@ -161,27 +176,28 @@ jobs:
# displayName: Switch to the latest Xcode
# restore, build and pack the packages
- task: UseDotNet@2
displayName: 'Use .Net Core sdk'
displayName: 'Install .NET SDK'
inputs:
version: $(NETCORE_VERSION)
includePreviewVersions: false
- task: UseDotNet@2
displayName: 'Use .Net Core sdk'
displayName: 'Install .NET 3.1 Test SDK'
inputs:
version: $(NETCORE_TEST_VERSION)
version: $(NETCORE_TEST_VERSION_3_1)
includePreviewVersions: false
- task: MSBuild@1
displayName: Build Solution
- task: UseDotNet@2
displayName: 'Install .NET 2.1 Test SDK'
inputs:
solution: $(PathToCsproj)
configuration: Release
msbuildArguments: '/restore /t:Build /p:ContinuousIntegrationBuild=true /p:Deterministic=false'
- task: MSBuild@1
displayName: Pack NuGets
version: $(NETCORE_TEST_VERSION_2_1)
includePreviewVersions: false
- task: CmdLine@2
displayName: 'Build Solution'
inputs:
solution: $(PathToCsproj)
configuration: Release
msbuildArguments: '/t:Pack /p:PackageVersion=$(NugetPackageVersion) /p:PackageOutputPath="$(Build.ArtifactStagingDirectory)/nuget"'
script: 'mono /Applications/Visual\ studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/MSBuild.dll $(PathToCsproj) /p:Configuration=Release /restore /t:Build /p:ContinuousIntegrationBuild=true /p:Deterministic=false'
- task: CmdLine@2
displayName: 'Pack NuGets'
inputs:
script: 'mono /Applications/Visual\ studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/MSBuild.dll $(PathToCsproj) /p:Configuration=Release /t:Pack /p:PackageVersion=$(NugetPackageVersion) /p:PackageOutputPath="$(Build.ArtifactStagingDirectory)/nuget"'

- ${{ if eq(variables['System.TeamProject'], 'devdiv') }}:
- template: sign-artifacts/jobs/v2.yml@internal-templates
Expand Down
2 changes: 1 addition & 1 deletion samples/XCT.Sample.Android/SplashActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Xamarin.CommunityToolkit.Sample.Droid
[Activity(Label = "XamarinCommunityToolkitSample", Icon = "@mipmap/icon", Theme = "@style/SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class SplashActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
var intent = new Intent(this, typeof(MainActivity));
Expand Down
4 changes: 2 additions & 2 deletions samples/XCT.Sample.UWP/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
void OnNavigationFailed(object? sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
Expand All @@ -97,7 +97,7 @@ void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
void OnSuspending(object sender, SuspendingEventArgs e)
void OnSuspending(object? sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();

Expand Down
7 changes: 5 additions & 2 deletions samples/XCT.Sample.iOS/Renderers/NoLineNavigationRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ public override void ViewWillAppear(bool animated)
// Newest iOS version fix - trycatch isn't optimal
try
{
NavigationBar.ScrollEdgeAppearance.ShadowImage = new UIKit.UIImage();
NavigationBar.ScrollEdgeAppearance.ShadowColor = null;
if (NavigationBar.ScrollEdgeAppearance != null)
{
NavigationBar.ScrollEdgeAppearance.ShadowImage = new UIKit.UIImage();
NavigationBar.ScrollEdgeAppearance.ShadowColor = null;
}
}
catch (Exception)
{
Expand Down
9 changes: 6 additions & 3 deletions samples/XCT.Sample.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.CommunityToolkit.Sa
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F695F5E8-420F-475F-A4CF-F5BB3FA6E818}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Directory.Build.props = Directory.Build.props
Xamarin.CommunityToolkit.ruleset = Xamarin.CommunityToolkit.ruleset
..\.editorconfig = ..\.editorconfig
..\Directory.Build.props = ..\Directory.Build.props
..\Xamarin.CommunityToolkit.ruleset = ..\Xamarin.CommunityToolkit.ruleset
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 Expand Up @@ -62,6 +62,7 @@ Global
{8B80BFA6-7B19-4DE7-BD97-7D84194AD0C2}.Debug|x86.Build.0 = Debug|Any CPU
{8B80BFA6-7B19-4DE7-BD97-7D84194AD0C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B80BFA6-7B19-4DE7-BD97-7D84194AD0C2}.Release|Any CPU.Build.0 = Release|Any CPU
{8B80BFA6-7B19-4DE7-BD97-7D84194AD0C2}.Release|Any CPU.Deploy.0 = Release|Any CPU
{8B80BFA6-7B19-4DE7-BD97-7D84194AD0C2}.Release|ARM.ActiveCfg = Release|Any CPU
{8B80BFA6-7B19-4DE7-BD97-7D84194AD0C2}.Release|ARM.Build.0 = Release|Any CPU
{8B80BFA6-7B19-4DE7-BD97-7D84194AD0C2}.Release|iPhone.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -191,6 +192,8 @@ Global
{91C748B4-E9ED-4543-880A-26747B03DE3A}.Debug|x86.Build.0 = Debug|x86
{91C748B4-E9ED-4543-880A-26747B03DE3A}.Debug|x86.Deploy.0 = Debug|x86
{91C748B4-E9ED-4543-880A-26747B03DE3A}.Release|Any CPU.ActiveCfg = Release|x86
{91C748B4-E9ED-4543-880A-26747B03DE3A}.Release|Any CPU.Build.0 = Release|x86
{91C748B4-E9ED-4543-880A-26747B03DE3A}.Release|Any CPU.Deploy.0 = Release|x86
{91C748B4-E9ED-4543-880A-26747B03DE3A}.Release|ARM.ActiveCfg = Release|ARM
{91C748B4-E9ED-4543-880A-26747B03DE3A}.Release|ARM.Build.0 = Release|ARM
{91C748B4-E9ED-4543-880A-26747B03DE3A}.Release|ARM.Deploy.0 = Release|ARM
Expand Down
4 changes: 3 additions & 1 deletion samples/XCT.Sample/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Xamarin.CommunityToolkit.Helpers;
using System.Globalization;
using Xamarin.CommunityToolkit.Helpers;
using Xamarin.CommunityToolkit.Sample.Pages;
using Xamarin.CommunityToolkit.Sample.Resx;
using Xamarin.Forms.PlatformConfiguration;
Expand All @@ -14,6 +15,7 @@ public App()

LocalizationResourceManager.Current.PropertyChanged += (sender, e) => AppResources.Culture = LocalizationResourceManager.Current.CurrentCulture;
LocalizationResourceManager.Current.Init(AppResources.ResourceManager);
LocalizationResourceManager.Current.CurrentCulture = new CultureInfo("en");

InitializeComponent();
MainPage = new BaseNavigationPage(new WelcomePage());
Expand Down
84 changes: 38 additions & 46 deletions samples/XCT.Sample/Helpers/RelayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,21 @@ namespace Xamarin.CommunityToolkit.Sample
{
public class RelayCommand : ICommand
{
readonly Action execute;
readonly Func<Task> asyncExecute;
readonly Action? execute;
readonly Func<Task>? asyncExecute;
readonly Func<bool>? canExecute;

Func<bool> canExecute;
int executingCount;

public RelayCommand(Action execute, Func<bool> canExecute = null)
public RelayCommand(Action execute, Func<bool>? canExecute = null)
{
if (execute == null)
throw new ArgumentNullException(nameof(execute));
this.execute = execute;
this.execute = execute ?? throw new ArgumentNullException(nameof(execute));
this.canExecute = canExecute;
}

protected RelayCommand(Func<Task> execute, Func<bool> canExecute = null) // This ctor is protected here and public in a derived class, to allow simple initialization like new RelayCommand(MyMethod) without errors due to ambiguity
protected RelayCommand(Func<Task> execute, Func<bool>? canExecute = null) // This ctor is protected here and public in a derived class, to allow simple initialization like new RelayCommand(MyMethod) without errors due to ambiguity
{
if (execute == null)
throw new ArgumentNullException(nameof(execute));
asyncExecute = execute;
asyncExecute = execute ?? throw new ArgumentNullException(nameof(execute));
this.canExecute = canExecute;
}

Expand All @@ -34,7 +30,7 @@ public RelayCommand(Action execute, Func<bool> canExecute = null)
/// </summary>
/// <param name="parameter">Ignored; this is the paremeterless command class</param>
/// <returns></returns>
public bool CanExecute(object parameter = null)
public bool CanExecute(object? parameter = null)
{
try
{
Expand All @@ -47,15 +43,12 @@ public bool CanExecute(object parameter = null)
}
}

public event EventHandler CanExecuteChanged;
public event EventHandler? CanExecuteChanged;

public void RaiseCanExecuteChanged()
{
CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
public void RaiseCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);

// Asynchronous command handling based on http://stackoverflow.com/a/31595509/6043538
public async void Execute(object parameter = null)
public async void Execute(object? parameter = null)
{
var couldExecuteBeforeExecute = CanExecute();
if (!couldExecuteBeforeExecute)
Expand All @@ -70,8 +63,10 @@ public async void Execute(object parameter = null)
{
if (execute != null)
execute();
else
else if (asyncExecute != null)
await asyncExecute();
else
throw new Exception("Execute is null");
}
catch (Exception ex)
{
Expand All @@ -89,31 +84,30 @@ public async void Execute(object parameter = null)

public class RelayCommandAsync : RelayCommand
{
public RelayCommandAsync(Func<Task> execute, Func<bool> canExecute = null)
: base(execute, canExecute) { } // This ctor is public here and protected in the base class, to allow simple initialization like new RelayCommandAsync(MyMethod) without errors due to ambiguity
public RelayCommandAsync(Func<Task> execute, Func<bool>? canExecute = null)
: base(execute, canExecute)
{
// This ctor is public here and protected in the base class, to allow simple initialization like new RelayCommandAsync(MyMethod) without errors due to ambiguity
}
}

public class RelayCommand<TParameter> : ICommand
{
readonly Action<TParameter> execute;
readonly Func<TParameter, Task> asyncExecute;
readonly Action<TParameter>? execute;
readonly Func<TParameter, Task>? asyncExecute;
readonly Func<TParameter?, bool>? canExecute;

Func<TParameter, bool> canExecute;
int executingCount;

public RelayCommand(Action<TParameter> execute, Func<TParameter, bool> canExecute = null)
public RelayCommand(Action<TParameter> execute, Func<TParameter?, bool>? canExecute = null)
{
if (execute == null)
throw new ArgumentNullException(nameof(execute));
this.execute = execute;
this.execute = execute ?? throw new ArgumentNullException(nameof(execute));
this.canExecute = canExecute;
}

protected RelayCommand(Func<TParameter, Task> execute, Func<TParameter, bool> canExecute = null) // This ctor is protected here and public in a derived class, to allow simple initialization like new RelayCommand(MyMethod) without errors due to ambiguity
protected RelayCommand(Func<TParameter, Task> execute, Func<TParameter?, bool>? canExecute = null) // This ctor is protected here and public in a derived class, to allow simple initialization like new RelayCommand(MyMethod) without errors due to ambiguity
{
if (execute == null)
throw new ArgumentNullException(nameof(execute));
asyncExecute = execute;
asyncExecute = execute ?? throw new ArgumentNullException(nameof(execute));
this.canExecute = canExecute;
}

Expand All @@ -122,11 +116,11 @@ public RelayCommand(Action<TParameter> execute, Func<TParameter, bool> canExecut
/// </summary>
/// <param name="parameter"></param>
/// <returns></returns>
public bool CanExecute(object parameter = null)
public bool CanExecute(object? parameter = null)
{
try
{
return canExecute != null ? canExecute((TParameter)parameter) : executingCount == 0;
return canExecute != null ? canExecute((TParameter?)parameter) : executingCount == 0;
}
catch (Exception ex)
{
Expand All @@ -135,12 +129,9 @@ public bool CanExecute(object parameter = null)
}
}

public event EventHandler CanExecuteChanged;
public event EventHandler? CanExecuteChanged;

public void RaiseCanExecuteChanged()
{
CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
public void RaiseCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);

// Asynchronous command handling based on http://stackoverflow.com/a/31595509/6043538
public async void Execute(object parameterAsObject)
Expand All @@ -159,13 +150,11 @@ public async void Execute(object parameterAsObject)
var parameter = (TParameter)parameterAsObject;

if (execute != null)
{
execute(parameter);
}
else
{
else if (asyncExecute != null)
await asyncExecute(parameter);
}
else
throw new Exception("Execute is null");
}
catch (Exception ex)
{
Expand All @@ -183,7 +172,10 @@ public async void Execute(object parameterAsObject)

public class RelayCommandAsync<TParameter> : RelayCommand<TParameter>
{
public RelayCommandAsync(Func<TParameter, Task> execute, Func<TParameter, bool> canExecute = null)
: base(execute, canExecute) { } // This ctor is public here and protected in the base class, to allow simple initialization like new RelayCommandAsync(MyMethod) without errors due to ambiguity
public RelayCommandAsync(Func<TParameter, Task> execute, Func<TParameter?, bool>? canExecute = null)
: base(execute, canExecute)
{
// This ctor is public here and protected in the base class, to allow simple initialization like new RelayCommandAsync(MyMethod) without errors due to ambiguity
}
}
}
Loading