From 983f12b1a94b96bc61fa8763fa0946c121925c13 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 14 Jan 2026 08:50:40 +0100 Subject: [PATCH 01/13] Make XAML Source Generator (XSF) the default inflator for .NET 11 - Change default MauiXamlInflator from Runtime/XamlC to SourceGen - Remove explicit MauiXamlInflator from all templates (now uses default) - Deprecate [XamlCompilation] attribute with error (use MSBuild metadata instead) - Remove _MAUIXAML_SOURCEGEN_BACKCOMPAT flag and all conditional code - Add MAUI1001 warning when using deprecated Runtime/XamlC inflators - Document breaking changes in FeatureSwitches.md --- Directory.Build.props | 10 ---- docs/design/FeatureSwitches.md | 33 +++++++++++++ src/Controls/src/Build.Tasks/XamlCTask.cs | 47 ------------------- .../Microsoft.Maui.Controls.targets | 22 +++------ .../src/SourceGen/CodeBehindCodeWriter.cs | 34 -------------- .../src/Xaml/XamlCompilationAttribute.cs | 24 ---------- .../MauiApp.1/MauiApp.1.csproj | 8 ---- .../templates/maui-blazor/MauiApp.1.csproj | 8 ---- .../src/templates/maui-lib/MauiLib1.csproj | 8 ---- .../templates/maui-mobile/MauiApp.1.csproj | 7 --- .../MauiApp.1.Droid/MauiApp.1.Droid.csproj | 7 --- .../MauiApp.1.Mac/MauiApp.1.Mac.csproj | 7 --- .../MauiApp.1.WinUI/MauiApp.1.WinUI.csproj | 8 ---- .../MauiApp.1.iOS/MauiApp.1.iOS.csproj | 7 --- .../MauiApp.1/MauiApp.1.csproj | 7 --- 15 files changed, 40 insertions(+), 197 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 414092597b6b..950c5863ff4c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,16 +2,6 @@ - - - - <_MauiXamlSourceGenBackCompat>true - $(DefineConstants);_MAUIXAML_SOURCEGEN_BACKCOMPAT - - true diff --git a/docs/design/FeatureSwitches.md b/docs/design/FeatureSwitches.md index d90f10718d52..de53db08ebd2 100644 --- a/docs/design/FeatureSwitches.md +++ b/docs/design/FeatureSwitches.md @@ -6,6 +6,7 @@ The following switches are toggled for applications running on Mono for `TrimMod | MSBuild Property Name | AppContext Setting | Description | |-|-|-| +| MauiXamlInflator | N/A | Controls how XAML files are processed. See [XAML Inflator](#mauixamlinflator) section below. | | MauiEnableIVisualAssemblyScanning | Microsoft.Maui.RuntimeFeature.IsIVisualAssemblyScanningEnabled | When enabled, MAUI will scan assemblies for types implementing `IVisual` and for `[assembly: Visual(...)]` attributes and register these types. | | MauiShellSearchResultsRendererDisplayMemberNameSupported | Microsoft.Maui.RuntimeFeature.IsShellSearchResultsRendererDisplayMemberNameSupported | When disabled, it is necessary to always set `ItemTemplate` of any `SearchHandler`. Displaying search results through `DisplayMemberName` will not work. | | MauiQueryPropertyAttributeSupport | Microsoft.Maui.RuntimeFeature.IsQueryPropertyAttributeSupported | When disabled, the `[QueryProperty(...)]` attributes won't be used to set values to properties when navigating. | @@ -18,6 +19,38 @@ The following switches are toggled for applications running on Mono for `TrimMod | EnableMauiDiagnostics | Microsoft.Maui.RuntimeFeature.EnableMauiDiagnostics | Enables MAUI specific diagnostics, like VisualDiagnostics and BindingDiagnostics. Defaults to EnableDiagnostics | | _EnableMauiAspire | Microsoft.Maui.RuntimeFeature.EnableMauiAspire | When enabled, MAUI Aspire integration features are available. **Warning**: Using Aspire outside of Debug configuration may introduce performance and security risks in production. | +## MauiXamlInflator + +Controls how XAML files are processed and compiled. Starting with .NET 11, the default value is `SourceGen`. + +**Available Values:** +- `SourceGen` (default) - XAML is compiled to C# at build time using a source generator. This provides the best performance and debugging experience, including full XAML Hot Reload support. +- `Runtime` - XAML is inflated at runtime. This has negative performance impact and is deprecated. +- `XamlC` - XAML is compiled using the XamlC IL weaver after compilation. This prevents some debugging capabilities like XAML Hot Reload and is deprecated. + +**Example:** +```xml + + + + + + Runtime + +``` + +**Per-file override:** +You can override the inflator for individual XAML files using item metadata: +```xml + + + +``` + +**Breaking Change in .NET 11:** +- The `[XamlCompilation]` attribute is now obsolete with `error: true`. Use MSBuild properties or item metadata instead. +- The default inflator changed from configuration-based (Runtime in Debug, XamlC in Release) to `SourceGen` for all configurations. + ## MauiEnableIVisualAssemblyScanning When this feature is not enabled, custom and third party `IVisual` types will not be automatically discovered and registered. diff --git a/src/Controls/src/Build.Tasks/XamlCTask.cs b/src/Controls/src/Build.Tasks/XamlCTask.cs index d4e7084e5379..167719971084 100644 --- a/src/Controls/src/Build.Tasks/XamlCTask.cs +++ b/src/Controls/src/Build.Tasks/XamlCTask.cs @@ -202,43 +202,11 @@ public override bool Execute(out IList thrownExceptions) using (var assemblyDefinition = AssemblyDefinition.ReadAssembly(IOPath.GetFullPath(Assembly), readerParameters)) { -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT - CustomAttribute xamlcAttr = null; - if (assemblyDefinition.HasCustomAttributes && - (xamlcAttr = - assemblyDefinition.CustomAttributes.FirstOrDefault( - ca => ca.AttributeType.FullName == "Microsoft.Maui.Controls.Xaml.XamlCompilationAttribute")) != null) - { - var options = (XamlCompilationOptions)xamlcAttr.ConstructorArguments[0].Value; - if ((options & XamlCompilationOptions.Skip) == XamlCompilationOptions.Skip) - skipassembly = true; - if ((options & XamlCompilationOptions.Compile) == XamlCompilationOptions.Compile) - skipassembly = false; - } - - xamlcAttr = null; -#endif - foreach (var module in assemblyDefinition.Modules) { var skipmodule = skipassembly; (bool, XamlInflator)? moduleInflatorOptions = assemblyInflatorOptions; -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT - if (module.HasCustomAttributes && - (xamlcAttr = - module.CustomAttributes.FirstOrDefault( - ca => ca.AttributeType.FullName == "Microsoft.Maui.Controls.Xaml.XamlCompilationAttribute")) != null) - { - var options = (XamlCompilationOptions)xamlcAttr.ConstructorArguments[0].Value; - if ((options & XamlCompilationOptions.Skip) == XamlCompilationOptions.Skip) - skipmodule = true; - if ((options & XamlCompilationOptions.Compile) == XamlCompilationOptions.Compile) - skipmodule = false; - } - xamlcAttr = null; -#endif - LoggingHelper.LogMessage(Low, $"{new string(' ', 2)}Module: {module.Name}"); var resourcesToPrune = new List(); foreach (var resource in module.Resources.OfType()) @@ -262,21 +230,6 @@ public override bool Execute(out IList thrownExceptions) var skiptype = skipmodule; (bool, XamlInflator)? typeInflatorOptions = moduleInflatorOptions; -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT - if (typeDef.HasCustomAttributes && - (xamlcAttr = - typeDef.CustomAttributes.FirstOrDefault( - ca => ca.AttributeType.FullName == "Microsoft.Maui.Controls.Xaml.XamlCompilationAttribute")) != null) - { - var options = (XamlCompilationOptions)xamlcAttr.ConstructorArguments[0].Value; - if ((options & XamlCompilationOptions.Skip) == XamlCompilationOptions.Skip) - skiptype = true; - if ((options & XamlCompilationOptions.Compile) == XamlCompilationOptions.Compile) - skiptype = false; - } - xamlcAttr = null; -#endif - if (Type != null) skiptype = !(Type == classname); diff --git a/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets b/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets index 6eee58090437..f14701f5c2f9 100644 --- a/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets +++ b/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets @@ -8,8 +8,7 @@ True <_MauiXamlInflator Condition="' $(MauiXamlInflator)' != '' ">$(MauiXamlInflator) - <_MauiXamlInflator Condition=" '$(MauiXamlInflator)' == '' And '$(Configuration)' == 'Debug' ">Runtime - <_MauiXamlInflator Condition=" '$(MauiXamlInflator)' == '' And '$(Configuration)' != 'Debug' ">XamlC + <_MauiXamlInflator Condition=" '$(MauiXamlInflator)' == '' ">SourceGen $(EnableMauiDiagnostics) $(EnableDiagnostics) @@ -86,13 +85,12 @@ - - <_MauiXamlDefaultInflator Condition=" '$(Configuration)' == 'Debug' " Include="Runtime" /> - <_MauiXamlDefaultInflator Condition=" '$(Configuration)' != 'Debug' " Include="XamlC" /> + + <_MauiXamlDefaultInflator Include="SourceGen" /> - + @@ -107,17 +105,11 @@ <_MauiXaml_AsEmbeddedResource Include="@(_MauiXaml_XC)" KeepDuplicates="false" /> - - - - + + Text="MauiXamlInflator is set to '$(MauiXamlInflator)'. The 'Runtime' and 'XamlC' inflators are deprecated. Consider using 'SourceGen' for optimal performance and debugging experience." + Condition="'$(MauiXamlInflator)' != '' And !$([System.String]::new('$(MauiXamlInflator)').ToLowerInvariant().Contains('sourcegen'))" /> diff --git a/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs b/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs index 505eca34ff2a..3d4d8cf06a10 100644 --- a/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs +++ b/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs @@ -107,10 +107,6 @@ public static string GenerateXamlCodeBehind(XamlProjectItemForCB? xamlItem, Comp sb.AppendLine("{"); sb.AppendLine($"\t[global::Microsoft.Maui.Controls.Xaml.XamlFilePath(\"{projItem.RelativePath?.Replace("\\", "\\\\")}\")]"); -#if !_MAUIXAML_SOURCEGEN_BACKCOMPAT - if (addXamlCompilationAttribute && !alreadyHasXamlCompilationAttribute) - sb.AppendLine($"\t[global::Microsoft.Maui.Controls.Xaml.XamlCompilation(global::Microsoft.Maui.Controls.Xaml.XamlCompilationOptions.Compile)]"); -#endif if (!addXamlCompilationAttribute && (xamlInflators & XamlInflator.XamlC) == 0 && !alreadyHasXamlCompilationAttribute) sb.AppendLine($"\t[global::Microsoft.Maui.Controls.Xaml.XamlCompilation(global::Microsoft.Maui.Controls.Xaml.XamlCompilationOptions.Skip)]"); @@ -325,15 +321,6 @@ public static bool TryParseXaml(XamlProjectItemForCB parseResult, string uid, Co return false; } -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT - // if the following xml processing instruction is present - // - // - // - // we will generate a xaml.g.cs file with the default ctor calling InitializeComponent, and a XamlCompilation attribute - var hasXamlCompilationProcessingInstruction = GetXamlCompilationProcessingInstruction(root.OwnerDocument); -#endif - var rootClass = root.Attributes["Class", XamlParser.X2006Uri] ?? root.Attributes["Class", XamlParser.X2009Uri]; @@ -341,12 +328,7 @@ public static bool TryParseXaml(XamlProjectItemForCB parseResult, string uid, Co { XmlnsHelper.ParseXmlns(rootClass.Value, out rootType, out rootClrNamespace, out _, out _); } -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT - else if (hasXamlCompilationProcessingInstruction - && (root.NamespaceURI == XamlParser.MauiUri || root.NamespaceURI == XamlParser.MauiGlobalUri)) -#else else if (root.NamespaceURI == XamlParser.MauiUri || root.NamespaceURI == XamlParser.MauiGlobalUri) -#endif { //make sure the base type can be resolved. if not, don't consider this as xaml, and move away var typeArgs = GetAttributeValue(root, "TypeArguments", XamlParser.X2006Uri, XamlParser.X2009Uri); @@ -387,22 +369,6 @@ public static bool TryParseXaml(XamlProjectItemForCB parseResult, string uid, Co return true; } -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT - //true, unless explicitely false - static bool GetXamlCompilationProcessingInstruction(XmlDocument xmlDoc) - { - if (xmlDoc.SelectSingleNode("processing-instruction('xaml-comp')") is not XmlProcessingInstruction instruction) - return true; - - var parts = instruction.Data.Split(' ', '='); - var indexOfCompile = Array.IndexOf(parts, "compile"); - if (indexOfCompile != -1) - return !parts[indexOfCompile + 1].Trim('"', '\'').Equals("false", StringComparison.OrdinalIgnoreCase); - - return true; - } -#endif - internal static string GetWarningDisable(XmlDocument xmlDoc) { var warnings = new List(); diff --git a/src/Controls/src/Xaml/XamlCompilationAttribute.cs b/src/Controls/src/Xaml/XamlCompilationAttribute.cs index 6bfec7586c52..2f4cfbc00bac 100644 --- a/src/Controls/src/Xaml/XamlCompilationAttribute.cs +++ b/src/Controls/src/Xaml/XamlCompilationAttribute.cs @@ -4,9 +4,7 @@ namespace Microsoft.Maui.Controls.Xaml { -#if !_MAUIXAML_SOURCEGEN_BACKCOMPAT [Obsolete("Specify xaml inflator and other options using msbuild metadata on MauiXaml items in your .csproj: ", error: true)] -#endif [Flags] public enum XamlCompilationOptions { @@ -14,9 +12,7 @@ public enum XamlCompilationOptions Compile = XamlInflator.XamlC, } -#if !_MAUIXAML_SOURCEGEN_BACKCOMPAT [Obsolete("Specify xaml inflator and other options using msbuild metadata on MauiXaml items in your .csproj: ", error: true)] -#endif [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class, Inherited = false)] public sealed class XamlCompilationAttribute : Attribute { @@ -27,24 +23,4 @@ public XamlCompilationAttribute(XamlCompilationOptions xamlCompilationOptions) public XamlCompilationOptions XamlCompilationOptions { get; set; } } - -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT - static class XamlCExtensions - { - public static bool IsCompiled(this Type type) - { - var attr = type.GetCustomAttribute(); - if (attr != null) - return attr.XamlCompilationOptions == XamlCompilationOptions.Compile; - attr = type.Module.GetCustomAttribute(); - if (attr != null) - return attr.XamlCompilationOptions == XamlCompilationOptions.Compile; - attr = type.Assembly.GetCustomAttribute(); - if (attr != null) - return attr.XamlCompilationOptions == XamlCompilationOptions.Compile; - - return false; - } - } -#endif } \ No newline at end of file diff --git a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1/MauiApp.1.csproj b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1/MauiApp.1.csproj index ff32af17a382..9c16c07ddc72 100644 --- a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1/MauiApp.1.csproj +++ b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1/MauiApp.1.csproj @@ -20,14 +20,6 @@ false enable - - SourceGen - XmlEncodedAppName diff --git a/src/Templates/src/templates/maui-blazor/MauiApp.1.csproj b/src/Templates/src/templates/maui-blazor/MauiApp.1.csproj index 02d3301b4195..de6a567b1ea0 100644 --- a/src/Templates/src/templates/maui-blazor/MauiApp.1.csproj +++ b/src/Templates/src/templates/maui-blazor/MauiApp.1.csproj @@ -20,14 +20,6 @@ false enable - - SourceGen - XmlEncodedAppName diff --git a/src/Templates/src/templates/maui-lib/MauiLib1.csproj b/src/Templates/src/templates/maui-lib/MauiLib1.csproj index e9515cf35cf9..c40cad86012d 100644 --- a/src/Templates/src/templates/maui-lib/MauiLib1.csproj +++ b/src/Templates/src/templates/maui-lib/MauiLib1.csproj @@ -11,14 +11,6 @@ enable enable - - SourceGen - 15.0 17.0 21.0 diff --git a/src/Templates/src/templates/maui-mobile/MauiApp.1.csproj b/src/Templates/src/templates/maui-mobile/MauiApp.1.csproj index 608395224ffc..a3d265b031f2 100644 --- a/src/Templates/src/templates/maui-mobile/MauiApp.1.csproj +++ b/src/Templates/src/templates/maui-mobile/MauiApp.1.csproj @@ -19,13 +19,6 @@ enable enable - - SourceGen true diff --git a/src/Templates/src/templates/maui-multiproject/MauiApp.1.Droid/MauiApp.1.Droid.csproj b/src/Templates/src/templates/maui-multiproject/MauiApp.1.Droid/MauiApp.1.Droid.csproj index 91e848cd9437..2bd3c8c1eee9 100644 --- a/src/Templates/src/templates/maui-multiproject/MauiApp.1.Droid/MauiApp.1.Droid.csproj +++ b/src/Templates/src/templates/maui-multiproject/MauiApp.1.Droid/MauiApp.1.Droid.csproj @@ -9,13 +9,6 @@ enable true - - SourceGen diff --git a/src/Templates/src/templates/maui-multiproject/MauiApp.1.Mac/MauiApp.1.Mac.csproj b/src/Templates/src/templates/maui-multiproject/MauiApp.1.Mac/MauiApp.1.Mac.csproj index 24078d3c7749..1c84cd373b07 100644 --- a/src/Templates/src/templates/maui-multiproject/MauiApp.1.Mac/MauiApp.1.Mac.csproj +++ b/src/Templates/src/templates/maui-multiproject/MauiApp.1.Mac/MauiApp.1.Mac.csproj @@ -9,13 +9,6 @@ enable true - - SourceGen diff --git a/src/Templates/src/templates/maui-multiproject/MauiApp.1.WinUI/MauiApp.1.WinUI.csproj b/src/Templates/src/templates/maui-multiproject/MauiApp.1.WinUI/MauiApp.1.WinUI.csproj index d90332fa05d1..b927827fd2aa 100644 --- a/src/Templates/src/templates/maui-multiproject/MauiApp.1.WinUI/MauiApp.1.WinUI.csproj +++ b/src/Templates/src/templates/maui-multiproject/MauiApp.1.WinUI/MauiApp.1.WinUI.csproj @@ -15,14 +15,6 @@ enable true - - SourceGen - false diff --git a/src/Templates/src/templates/maui-multiproject/MauiApp.1.iOS/MauiApp.1.iOS.csproj b/src/Templates/src/templates/maui-multiproject/MauiApp.1.iOS/MauiApp.1.iOS.csproj index 2fffeab4b16d..643eb8ea418a 100644 --- a/src/Templates/src/templates/maui-multiproject/MauiApp.1.iOS/MauiApp.1.iOS.csproj +++ b/src/Templates/src/templates/maui-multiproject/MauiApp.1.iOS/MauiApp.1.iOS.csproj @@ -9,13 +9,6 @@ enable true - - SourceGen diff --git a/src/Templates/src/templates/maui-multiproject/MauiApp.1/MauiApp.1.csproj b/src/Templates/src/templates/maui-multiproject/MauiApp.1/MauiApp.1.csproj index ff480646a720..877372816737 100644 --- a/src/Templates/src/templates/maui-multiproject/MauiApp.1/MauiApp.1.csproj +++ b/src/Templates/src/templates/maui-multiproject/MauiApp.1/MauiApp.1.csproj @@ -8,13 +8,6 @@ true enable - - SourceGen From 8e7a2eb5682f266bd96908b821db4ea9ddcbd7bf Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 14 Jan 2026 08:59:40 +0100 Subject: [PATCH 02/13] Remove unused _MauiXamlDefaultInflator and Default inflator value --- .../netstandard2.0/Microsoft.Maui.Controls.targets | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets b/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets index f14701f5c2f9..c118007cb6aa 100644 --- a/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets +++ b/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets @@ -85,13 +85,8 @@ - - <_MauiXamlDefaultInflator Include="SourceGen" /> - - + - - From db990e45a577af051b985a4febccf6cb95596504 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 14 Jan 2026 09:02:22 +0100 Subject: [PATCH 03/13] Update MAUI1001 warning message to suggest removing the property --- .../netstandard2.0/Microsoft.Maui.Controls.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets b/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets index c118007cb6aa..1b2b4cd2a881 100644 --- a/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets +++ b/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets @@ -103,7 +103,7 @@ From 0eb18de27f279ebb5301f1e7b78cd187d56c7748 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 14 Jan 2026 09:10:34 +0100 Subject: [PATCH 04/13] Keep backcompat for [XamlCompilation] in .NET 11, deprecate in .NET 12 - Restore _MAUIXAML_SOURCEGEN_BACKCOMPAT flag (will be removed in .NET 12) - Backcompat code now uses #if _MAUIXAML_SOURCEGEN_BACKCOMPAT - [XamlCompilation] attribute remains usable in .NET 11 - Deprecation with error will happen in .NET 12 (NET12_0_OR_GREATER) --- Directory.Build.props | 9 ++++ docs/design/FeatureSwitches.md | 7 ++- src/Controls/src/Build.Tasks/XamlCTask.cs | 47 +++++++++++++++++++ .../src/SourceGen/CodeBehindCodeWriter.cs | 34 ++++++++++++++ .../src/Xaml/XamlCompilationAttribute.cs | 24 ++++++++++ 5 files changed, 119 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 950c5863ff4c..2f75923fef5c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,6 +2,15 @@ + + + <_MauiXamlSourceGenBackCompat>true + $(DefineConstants);_MAUIXAML_SOURCEGEN_BACKCOMPAT + + true diff --git a/docs/design/FeatureSwitches.md b/docs/design/FeatureSwitches.md index de53db08ebd2..6c66d0d9aa4d 100644 --- a/docs/design/FeatureSwitches.md +++ b/docs/design/FeatureSwitches.md @@ -47,9 +47,12 @@ You can override the inflator for individual XAML files using item metadata: ``` -**Breaking Change in .NET 11:** -- The `[XamlCompilation]` attribute is now obsolete with `error: true`. Use MSBuild properties or item metadata instead. +**Changes in .NET 11:** - The default inflator changed from configuration-based (Runtime in Debug, XamlC in Release) to `SourceGen` for all configurations. +- The `[XamlCompilation]` attribute is still supported but will be deprecated in .NET 12. + +**Breaking Change in .NET 12:** +- The `[XamlCompilation]` attribute will be obsolete with `error: true`. Use MSBuild properties or item metadata instead. ## MauiEnableIVisualAssemblyScanning diff --git a/src/Controls/src/Build.Tasks/XamlCTask.cs b/src/Controls/src/Build.Tasks/XamlCTask.cs index 167719971084..d4e7084e5379 100644 --- a/src/Controls/src/Build.Tasks/XamlCTask.cs +++ b/src/Controls/src/Build.Tasks/XamlCTask.cs @@ -202,11 +202,43 @@ public override bool Execute(out IList thrownExceptions) using (var assemblyDefinition = AssemblyDefinition.ReadAssembly(IOPath.GetFullPath(Assembly), readerParameters)) { +#if _MAUIXAML_SOURCEGEN_BACKCOMPAT + CustomAttribute xamlcAttr = null; + if (assemblyDefinition.HasCustomAttributes && + (xamlcAttr = + assemblyDefinition.CustomAttributes.FirstOrDefault( + ca => ca.AttributeType.FullName == "Microsoft.Maui.Controls.Xaml.XamlCompilationAttribute")) != null) + { + var options = (XamlCompilationOptions)xamlcAttr.ConstructorArguments[0].Value; + if ((options & XamlCompilationOptions.Skip) == XamlCompilationOptions.Skip) + skipassembly = true; + if ((options & XamlCompilationOptions.Compile) == XamlCompilationOptions.Compile) + skipassembly = false; + } + + xamlcAttr = null; +#endif + foreach (var module in assemblyDefinition.Modules) { var skipmodule = skipassembly; (bool, XamlInflator)? moduleInflatorOptions = assemblyInflatorOptions; +#if _MAUIXAML_SOURCEGEN_BACKCOMPAT + if (module.HasCustomAttributes && + (xamlcAttr = + module.CustomAttributes.FirstOrDefault( + ca => ca.AttributeType.FullName == "Microsoft.Maui.Controls.Xaml.XamlCompilationAttribute")) != null) + { + var options = (XamlCompilationOptions)xamlcAttr.ConstructorArguments[0].Value; + if ((options & XamlCompilationOptions.Skip) == XamlCompilationOptions.Skip) + skipmodule = true; + if ((options & XamlCompilationOptions.Compile) == XamlCompilationOptions.Compile) + skipmodule = false; + } + xamlcAttr = null; +#endif + LoggingHelper.LogMessage(Low, $"{new string(' ', 2)}Module: {module.Name}"); var resourcesToPrune = new List(); foreach (var resource in module.Resources.OfType()) @@ -230,6 +262,21 @@ public override bool Execute(out IList thrownExceptions) var skiptype = skipmodule; (bool, XamlInflator)? typeInflatorOptions = moduleInflatorOptions; +#if _MAUIXAML_SOURCEGEN_BACKCOMPAT + if (typeDef.HasCustomAttributes && + (xamlcAttr = + typeDef.CustomAttributes.FirstOrDefault( + ca => ca.AttributeType.FullName == "Microsoft.Maui.Controls.Xaml.XamlCompilationAttribute")) != null) + { + var options = (XamlCompilationOptions)xamlcAttr.ConstructorArguments[0].Value; + if ((options & XamlCompilationOptions.Skip) == XamlCompilationOptions.Skip) + skiptype = true; + if ((options & XamlCompilationOptions.Compile) == XamlCompilationOptions.Compile) + skiptype = false; + } + xamlcAttr = null; +#endif + if (Type != null) skiptype = !(Type == classname); diff --git a/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs b/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs index 3d4d8cf06a10..505eca34ff2a 100644 --- a/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs +++ b/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs @@ -107,6 +107,10 @@ public static string GenerateXamlCodeBehind(XamlProjectItemForCB? xamlItem, Comp sb.AppendLine("{"); sb.AppendLine($"\t[global::Microsoft.Maui.Controls.Xaml.XamlFilePath(\"{projItem.RelativePath?.Replace("\\", "\\\\")}\")]"); +#if !_MAUIXAML_SOURCEGEN_BACKCOMPAT + if (addXamlCompilationAttribute && !alreadyHasXamlCompilationAttribute) + sb.AppendLine($"\t[global::Microsoft.Maui.Controls.Xaml.XamlCompilation(global::Microsoft.Maui.Controls.Xaml.XamlCompilationOptions.Compile)]"); +#endif if (!addXamlCompilationAttribute && (xamlInflators & XamlInflator.XamlC) == 0 && !alreadyHasXamlCompilationAttribute) sb.AppendLine($"\t[global::Microsoft.Maui.Controls.Xaml.XamlCompilation(global::Microsoft.Maui.Controls.Xaml.XamlCompilationOptions.Skip)]"); @@ -321,6 +325,15 @@ public static bool TryParseXaml(XamlProjectItemForCB parseResult, string uid, Co return false; } +#if _MAUIXAML_SOURCEGEN_BACKCOMPAT + // if the following xml processing instruction is present + // + // + // + // we will generate a xaml.g.cs file with the default ctor calling InitializeComponent, and a XamlCompilation attribute + var hasXamlCompilationProcessingInstruction = GetXamlCompilationProcessingInstruction(root.OwnerDocument); +#endif + var rootClass = root.Attributes["Class", XamlParser.X2006Uri] ?? root.Attributes["Class", XamlParser.X2009Uri]; @@ -328,7 +341,12 @@ public static bool TryParseXaml(XamlProjectItemForCB parseResult, string uid, Co { XmlnsHelper.ParseXmlns(rootClass.Value, out rootType, out rootClrNamespace, out _, out _); } +#if _MAUIXAML_SOURCEGEN_BACKCOMPAT + else if (hasXamlCompilationProcessingInstruction + && (root.NamespaceURI == XamlParser.MauiUri || root.NamespaceURI == XamlParser.MauiGlobalUri)) +#else else if (root.NamespaceURI == XamlParser.MauiUri || root.NamespaceURI == XamlParser.MauiGlobalUri) +#endif { //make sure the base type can be resolved. if not, don't consider this as xaml, and move away var typeArgs = GetAttributeValue(root, "TypeArguments", XamlParser.X2006Uri, XamlParser.X2009Uri); @@ -369,6 +387,22 @@ public static bool TryParseXaml(XamlProjectItemForCB parseResult, string uid, Co return true; } +#if _MAUIXAML_SOURCEGEN_BACKCOMPAT + //true, unless explicitely false + static bool GetXamlCompilationProcessingInstruction(XmlDocument xmlDoc) + { + if (xmlDoc.SelectSingleNode("processing-instruction('xaml-comp')") is not XmlProcessingInstruction instruction) + return true; + + var parts = instruction.Data.Split(' ', '='); + var indexOfCompile = Array.IndexOf(parts, "compile"); + if (indexOfCompile != -1) + return !parts[indexOfCompile + 1].Trim('"', '\'').Equals("false", StringComparison.OrdinalIgnoreCase); + + return true; + } +#endif + internal static string GetWarningDisable(XmlDocument xmlDoc) { var warnings = new List(); diff --git a/src/Controls/src/Xaml/XamlCompilationAttribute.cs b/src/Controls/src/Xaml/XamlCompilationAttribute.cs index 2f4cfbc00bac..6bfec7586c52 100644 --- a/src/Controls/src/Xaml/XamlCompilationAttribute.cs +++ b/src/Controls/src/Xaml/XamlCompilationAttribute.cs @@ -4,7 +4,9 @@ namespace Microsoft.Maui.Controls.Xaml { +#if !_MAUIXAML_SOURCEGEN_BACKCOMPAT [Obsolete("Specify xaml inflator and other options using msbuild metadata on MauiXaml items in your .csproj: ", error: true)] +#endif [Flags] public enum XamlCompilationOptions { @@ -12,7 +14,9 @@ public enum XamlCompilationOptions Compile = XamlInflator.XamlC, } +#if !_MAUIXAML_SOURCEGEN_BACKCOMPAT [Obsolete("Specify xaml inflator and other options using msbuild metadata on MauiXaml items in your .csproj: ", error: true)] +#endif [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class, Inherited = false)] public sealed class XamlCompilationAttribute : Attribute { @@ -23,4 +27,24 @@ public XamlCompilationAttribute(XamlCompilationOptions xamlCompilationOptions) public XamlCompilationOptions XamlCompilationOptions { get; set; } } + +#if _MAUIXAML_SOURCEGEN_BACKCOMPAT + static class XamlCExtensions + { + public static bool IsCompiled(this Type type) + { + var attr = type.GetCustomAttribute(); + if (attr != null) + return attr.XamlCompilationOptions == XamlCompilationOptions.Compile; + attr = type.Module.GetCustomAttribute(); + if (attr != null) + return attr.XamlCompilationOptions == XamlCompilationOptions.Compile; + attr = type.Assembly.GetCustomAttribute(); + if (attr != null) + return attr.XamlCompilationOptions == XamlCompilationOptions.Compile; + + return false; + } + } +#endif } \ No newline at end of file From b6073ea3ba5aea17c69c9aa00a990991cb3b45c3 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 14 Jan 2026 09:36:53 +0100 Subject: [PATCH 05/13] Deprecate [XamlCompilation] with warning in NET11, no-op in NET12 - NET11: [XamlCompilation] produces Obsolete warning but still works - NET12: [XamlCompilation] produces Obsolete error and becomes no-op - XamlCompilationAttribute.cs uses NET11_0/NET12_0_OR_GREATER for Obsolete attrs - SourceGen/Build.Tasks use _MAUIXAML_SOURCEGEN_BACKCOMPAT (netstandard2.0) --- Directory.Build.props | 3 ++- docs/design/FeatureSwitches.md | 6 +++--- src/Controls/src/Xaml/XamlCompilationAttribute.cs | 14 +++++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 2f75923fef5c..18f260f23e2e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,7 +5,8 @@ <_MauiXamlSourceGenBackCompat>true $(DefineConstants);_MAUIXAML_SOURCEGEN_BACKCOMPAT diff --git a/docs/design/FeatureSwitches.md b/docs/design/FeatureSwitches.md index 6c66d0d9aa4d..8f39e6c2caee 100644 --- a/docs/design/FeatureSwitches.md +++ b/docs/design/FeatureSwitches.md @@ -49,10 +49,10 @@ You can override the inflator for individual XAML files using item metadata: **Changes in .NET 11:** - The default inflator changed from configuration-based (Runtime in Debug, XamlC in Release) to `SourceGen` for all configurations. -- The `[XamlCompilation]` attribute is still supported but will be deprecated in .NET 12. +- The `[XamlCompilation]` attribute is deprecated (produces warning) but still functional. -**Breaking Change in .NET 12:** -- The `[XamlCompilation]` attribute will be obsolete with `error: true`. Use MSBuild properties or item metadata instead. +**Changes in .NET 12:** +- The `[XamlCompilation]` attribute will be obsolete with `error: true` and becomes a no-op. Use MSBuild properties or item metadata instead. ## MauiEnableIVisualAssemblyScanning diff --git a/src/Controls/src/Xaml/XamlCompilationAttribute.cs b/src/Controls/src/Xaml/XamlCompilationAttribute.cs index 6bfec7586c52..b0873c037599 100644 --- a/src/Controls/src/Xaml/XamlCompilationAttribute.cs +++ b/src/Controls/src/Xaml/XamlCompilationAttribute.cs @@ -4,8 +4,10 @@ namespace Microsoft.Maui.Controls.Xaml { -#if !_MAUIXAML_SOURCEGEN_BACKCOMPAT - [Obsolete("Specify xaml inflator and other options using msbuild metadata on MauiXaml items in your .csproj: ", error: true)] +#if NET12_0_OR_GREATER + [Obsolete("XamlCompilationOptions is no longer used. Specify xaml inflator using msbuild metadata on MauiXaml items in your .csproj: ", error: true)] +#elif NET11_0_OR_GREATER + [Obsolete("XamlCompilationOptions is deprecated. Specify xaml inflator using msbuild metadata on MauiXaml items in your .csproj: ")] #endif [Flags] public enum XamlCompilationOptions @@ -14,8 +16,10 @@ public enum XamlCompilationOptions Compile = XamlInflator.XamlC, } -#if !_MAUIXAML_SOURCEGEN_BACKCOMPAT - [Obsolete("Specify xaml inflator and other options using msbuild metadata on MauiXaml items in your .csproj: ", error: true)] +#if NET12_0_OR_GREATER + [Obsolete("XamlCompilationAttribute is no longer used. Specify xaml inflator using msbuild metadata on MauiXaml items in your .csproj: ", error: true)] +#elif NET11_0_OR_GREATER + [Obsolete("XamlCompilationAttribute is deprecated. Specify xaml inflator using msbuild metadata on MauiXaml items in your .csproj: ")] #endif [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class, Inherited = false)] public sealed class XamlCompilationAttribute : Attribute @@ -28,7 +32,7 @@ public XamlCompilationAttribute(XamlCompilationOptions xamlCompilationOptions) public XamlCompilationOptions XamlCompilationOptions { get; set; } } -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT +#if !NET12_0_OR_GREATER static class XamlCExtensions { public static bool IsCompiled(this Type type) From 2cb6315f399c85c85565bca9b63cf269286432c2 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 14 Jan 2026 09:48:22 +0100 Subject: [PATCH 06/13] Remove _MAUIXAML_SOURCEGEN_BACKCOMPAT flag, simplify deprecation - [XamlCompilation] is deprecated (warning) in NET11, no-op (error) in NET12 - Remove backcompat flag from Directory.Build.props - Use #if !NET12_0_OR_GREATER for backcompat code - Add #pragma disable CS0618 for internal usage of deprecated types --- Directory.Build.props | 10 ---------- src/Controls/src/Build.Tasks/XamlCTask.cs | 10 ++++------ src/Controls/src/SourceGen/CodeBehindCodeWriter.cs | 12 ------------ src/Controls/src/Xaml/XamlCompilationAttribute.cs | 6 ++++-- 4 files changed, 8 insertions(+), 30 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 18f260f23e2e..950c5863ff4c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,16 +2,6 @@ - - - <_MauiXamlSourceGenBackCompat>true - $(DefineConstants);_MAUIXAML_SOURCEGEN_BACKCOMPAT - - true diff --git a/src/Controls/src/Build.Tasks/XamlCTask.cs b/src/Controls/src/Build.Tasks/XamlCTask.cs index d4e7084e5379..28e57eb9f367 100644 --- a/src/Controls/src/Build.Tasks/XamlCTask.cs +++ b/src/Controls/src/Build.Tasks/XamlCTask.cs @@ -202,7 +202,7 @@ public override bool Execute(out IList thrownExceptions) using (var assemblyDefinition = AssemblyDefinition.ReadAssembly(IOPath.GetFullPath(Assembly), readerParameters)) { -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT +#pragma warning disable CS0618 // Type or member is obsolete - backcompat for [XamlCompilation] CustomAttribute xamlcAttr = null; if (assemblyDefinition.HasCustomAttributes && (xamlcAttr = @@ -217,14 +217,12 @@ public override bool Execute(out IList thrownExceptions) } xamlcAttr = null; -#endif foreach (var module in assemblyDefinition.Modules) { var skipmodule = skipassembly; (bool, XamlInflator)? moduleInflatorOptions = assemblyInflatorOptions; -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT if (module.HasCustomAttributes && (xamlcAttr = module.CustomAttributes.FirstOrDefault( @@ -237,7 +235,7 @@ public override bool Execute(out IList thrownExceptions) skipmodule = false; } xamlcAttr = null; -#endif +#pragma warning restore CS0618 LoggingHelper.LogMessage(Low, $"{new string(' ', 2)}Module: {module.Name}"); var resourcesToPrune = new List(); @@ -262,7 +260,7 @@ public override bool Execute(out IList thrownExceptions) var skiptype = skipmodule; (bool, XamlInflator)? typeInflatorOptions = moduleInflatorOptions; -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT +#pragma warning disable CS0618 // Type or member is obsolete - backcompat for [XamlCompilation] if (typeDef.HasCustomAttributes && (xamlcAttr = typeDef.CustomAttributes.FirstOrDefault( @@ -275,7 +273,7 @@ public override bool Execute(out IList thrownExceptions) skiptype = false; } xamlcAttr = null; -#endif +#pragma warning restore CS0618 if (Type != null) skiptype = !(Type == classname); diff --git a/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs b/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs index 505eca34ff2a..0b897ed8603c 100644 --- a/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs +++ b/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs @@ -107,10 +107,6 @@ public static string GenerateXamlCodeBehind(XamlProjectItemForCB? xamlItem, Comp sb.AppendLine("{"); sb.AppendLine($"\t[global::Microsoft.Maui.Controls.Xaml.XamlFilePath(\"{projItem.RelativePath?.Replace("\\", "\\\\")}\")]"); -#if !_MAUIXAML_SOURCEGEN_BACKCOMPAT - if (addXamlCompilationAttribute && !alreadyHasXamlCompilationAttribute) - sb.AppendLine($"\t[global::Microsoft.Maui.Controls.Xaml.XamlCompilation(global::Microsoft.Maui.Controls.Xaml.XamlCompilationOptions.Compile)]"); -#endif if (!addXamlCompilationAttribute && (xamlInflators & XamlInflator.XamlC) == 0 && !alreadyHasXamlCompilationAttribute) sb.AppendLine($"\t[global::Microsoft.Maui.Controls.Xaml.XamlCompilation(global::Microsoft.Maui.Controls.Xaml.XamlCompilationOptions.Skip)]"); @@ -325,14 +321,12 @@ public static bool TryParseXaml(XamlProjectItemForCB parseResult, string uid, Co return false; } -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT // if the following xml processing instruction is present // // // // we will generate a xaml.g.cs file with the default ctor calling InitializeComponent, and a XamlCompilation attribute var hasXamlCompilationProcessingInstruction = GetXamlCompilationProcessingInstruction(root.OwnerDocument); -#endif var rootClass = root.Attributes["Class", XamlParser.X2006Uri] ?? root.Attributes["Class", XamlParser.X2009Uri]; @@ -341,12 +335,8 @@ public static bool TryParseXaml(XamlProjectItemForCB parseResult, string uid, Co { XmlnsHelper.ParseXmlns(rootClass.Value, out rootType, out rootClrNamespace, out _, out _); } -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT else if (hasXamlCompilationProcessingInstruction && (root.NamespaceURI == XamlParser.MauiUri || root.NamespaceURI == XamlParser.MauiGlobalUri)) -#else - else if (root.NamespaceURI == XamlParser.MauiUri || root.NamespaceURI == XamlParser.MauiGlobalUri) -#endif { //make sure the base type can be resolved. if not, don't consider this as xaml, and move away var typeArgs = GetAttributeValue(root, "TypeArguments", XamlParser.X2006Uri, XamlParser.X2009Uri); @@ -387,7 +377,6 @@ public static bool TryParseXaml(XamlProjectItemForCB parseResult, string uid, Co return true; } -#if _MAUIXAML_SOURCEGEN_BACKCOMPAT //true, unless explicitely false static bool GetXamlCompilationProcessingInstruction(XmlDocument xmlDoc) { @@ -401,7 +390,6 @@ static bool GetXamlCompilationProcessingInstruction(XmlDocument xmlDoc) return true; } -#endif internal static string GetWarningDisable(XmlDocument xmlDoc) { diff --git a/src/Controls/src/Xaml/XamlCompilationAttribute.cs b/src/Controls/src/Xaml/XamlCompilationAttribute.cs index b0873c037599..4a04f4488514 100644 --- a/src/Controls/src/Xaml/XamlCompilationAttribute.cs +++ b/src/Controls/src/Xaml/XamlCompilationAttribute.cs @@ -6,7 +6,7 @@ namespace Microsoft.Maui.Controls.Xaml { #if NET12_0_OR_GREATER [Obsolete("XamlCompilationOptions is no longer used. Specify xaml inflator using msbuild metadata on MauiXaml items in your .csproj: ", error: true)] -#elif NET11_0_OR_GREATER +#else [Obsolete("XamlCompilationOptions is deprecated. Specify xaml inflator using msbuild metadata on MauiXaml items in your .csproj: ")] #endif [Flags] @@ -18,7 +18,7 @@ public enum XamlCompilationOptions #if NET12_0_OR_GREATER [Obsolete("XamlCompilationAttribute is no longer used. Specify xaml inflator using msbuild metadata on MauiXaml items in your .csproj: ", error: true)] -#elif NET11_0_OR_GREATER +#else [Obsolete("XamlCompilationAttribute is deprecated. Specify xaml inflator using msbuild metadata on MauiXaml items in your .csproj: ")] #endif [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class, Inherited = false)] @@ -33,6 +33,7 @@ public XamlCompilationAttribute(XamlCompilationOptions xamlCompilationOptions) } #if !NET12_0_OR_GREATER +#pragma warning disable CS0618 // Type or member is obsolete - internal backcompat code static class XamlCExtensions { public static bool IsCompiled(this Type type) @@ -50,5 +51,6 @@ public static bool IsCompiled(this Type type) return false; } } +#pragma warning restore CS0618 #endif } \ No newline at end of file From b6bef8e2c3639d6b7a4fb5b28785935ff57b1f38 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 14 Jan 2026 09:59:40 +0100 Subject: [PATCH 07/13] Wrap backcompat code with #if !NET12_0_OR_GREATER - SourceGen: xaml-comp processing instruction honored in NET11, ignored in NET12 - XamlCTask: [XamlCompilation] scanning active in NET11, removed in NET12 --- src/Controls/src/Build.Tasks/XamlCTask.cs | 6 ++++++ src/Controls/src/SourceGen/CodeBehindCodeWriter.cs | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Controls/src/Build.Tasks/XamlCTask.cs b/src/Controls/src/Build.Tasks/XamlCTask.cs index 28e57eb9f367..1bf98a5579b8 100644 --- a/src/Controls/src/Build.Tasks/XamlCTask.cs +++ b/src/Controls/src/Build.Tasks/XamlCTask.cs @@ -202,6 +202,7 @@ public override bool Execute(out IList thrownExceptions) using (var assemblyDefinition = AssemblyDefinition.ReadAssembly(IOPath.GetFullPath(Assembly), readerParameters)) { +#if !NET12_0_OR_GREATER #pragma warning disable CS0618 // Type or member is obsolete - backcompat for [XamlCompilation] CustomAttribute xamlcAttr = null; if (assemblyDefinition.HasCustomAttributes && @@ -217,12 +218,14 @@ public override bool Execute(out IList thrownExceptions) } xamlcAttr = null; +#endif foreach (var module in assemblyDefinition.Modules) { var skipmodule = skipassembly; (bool, XamlInflator)? moduleInflatorOptions = assemblyInflatorOptions; +#if !NET12_0_OR_GREATER if (module.HasCustomAttributes && (xamlcAttr = module.CustomAttributes.FirstOrDefault( @@ -236,6 +239,7 @@ public override bool Execute(out IList thrownExceptions) } xamlcAttr = null; #pragma warning restore CS0618 +#endif LoggingHelper.LogMessage(Low, $"{new string(' ', 2)}Module: {module.Name}"); var resourcesToPrune = new List(); @@ -260,6 +264,7 @@ public override bool Execute(out IList thrownExceptions) var skiptype = skipmodule; (bool, XamlInflator)? typeInflatorOptions = moduleInflatorOptions; +#if !NET12_0_OR_GREATER #pragma warning disable CS0618 // Type or member is obsolete - backcompat for [XamlCompilation] if (typeDef.HasCustomAttributes && (xamlcAttr = @@ -274,6 +279,7 @@ public override bool Execute(out IList thrownExceptions) } xamlcAttr = null; #pragma warning restore CS0618 +#endif if (Type != null) skiptype = !(Type == classname); diff --git a/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs b/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs index 0b897ed8603c..cf8c6fcd597c 100644 --- a/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs +++ b/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs @@ -321,12 +321,14 @@ public static bool TryParseXaml(XamlProjectItemForCB parseResult, string uid, Co return false; } +#if !NET12_0_OR_GREATER // if the following xml processing instruction is present // // // // we will generate a xaml.g.cs file with the default ctor calling InitializeComponent, and a XamlCompilation attribute var hasXamlCompilationProcessingInstruction = GetXamlCompilationProcessingInstruction(root.OwnerDocument); +#endif var rootClass = root.Attributes["Class", XamlParser.X2006Uri] ?? root.Attributes["Class", XamlParser.X2009Uri]; @@ -335,8 +337,12 @@ public static bool TryParseXaml(XamlProjectItemForCB parseResult, string uid, Co { XmlnsHelper.ParseXmlns(rootClass.Value, out rootType, out rootClrNamespace, out _, out _); } +#if !NET12_0_OR_GREATER else if (hasXamlCompilationProcessingInstruction && (root.NamespaceURI == XamlParser.MauiUri || root.NamespaceURI == XamlParser.MauiGlobalUri)) +#else + else if (root.NamespaceURI == XamlParser.MauiUri || root.NamespaceURI == XamlParser.MauiGlobalUri) +#endif { //make sure the base type can be resolved. if not, don't consider this as xaml, and move away var typeArgs = GetAttributeValue(root, "TypeArguments", XamlParser.X2006Uri, XamlParser.X2009Uri); @@ -377,6 +383,7 @@ public static bool TryParseXaml(XamlProjectItemForCB parseResult, string uid, Co return true; } +#if !NET12_0_OR_GREATER //true, unless explicitely false static bool GetXamlCompilationProcessingInstruction(XmlDocument xmlDoc) { @@ -390,6 +397,7 @@ static bool GetXamlCompilationProcessingInstruction(XmlDocument xmlDoc) return true; } +#endif internal static string GetWarningDisable(XmlDocument xmlDoc) { From 3cdca6d023060a99a549501737cf7ade3392858e Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 14 Jan 2026 10:14:25 +0100 Subject: [PATCH 08/13] Fix tests for SourceGen as default inflator - Suppress CS0618 warning in test's AssemblyInfo.cs for deprecated [XamlCompilation] - Add pragma to SourceGen when emitting [XamlCompilation(Skip)] - Update ValidateOnly test: XAML no longer embedded with SourceGen default --- .../src/SourceGen/CodeBehindCodeWriter.cs | 4 +++- .../tests/Xaml.UnitTests/MSBuild/MSBuildTests.cs | 16 ++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs b/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs index cf8c6fcd597c..80eaa8942381 100644 --- a/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs +++ b/src/Controls/src/SourceGen/CodeBehindCodeWriter.cs @@ -107,8 +107,10 @@ public static string GenerateXamlCodeBehind(XamlProjectItemForCB? xamlItem, Comp sb.AppendLine("{"); sb.AppendLine($"\t[global::Microsoft.Maui.Controls.Xaml.XamlFilePath(\"{projItem.RelativePath?.Replace("\\", "\\\\")}\")]"); +#pragma warning disable CS0618 // XamlCompilation is deprecated but still generated for backcompat if (!addXamlCompilationAttribute && (xamlInflators & XamlInflator.XamlC) == 0 && !alreadyHasXamlCompilationAttribute) - sb.AppendLine($"\t[global::Microsoft.Maui.Controls.Xaml.XamlCompilation(global::Microsoft.Maui.Controls.Xaml.XamlCompilationOptions.Skip)]"); + sb.AppendLine($"\t#pragma warning disable CS0618\n\t[global::Microsoft.Maui.Controls.Xaml.XamlCompilation(global::Microsoft.Maui.Controls.Xaml.XamlCompilationOptions.Skip)]\n\t#pragma warning restore CS0618"); +#pragma warning restore CS0618 if (hideFromIntellisense) { diff --git a/src/Controls/tests/Xaml.UnitTests/MSBuild/MSBuildTests.cs b/src/Controls/tests/Xaml.UnitTests/MSBuild/MSBuildTests.cs index 4597f4027213..d7b213067ecf 100644 --- a/src/Controls/tests/Xaml.UnitTests/MSBuild/MSBuildTests.cs +++ b/src/Controls/tests/Xaml.UnitTests/MSBuild/MSBuildTests.cs @@ -156,7 +156,7 @@ XElement NewProject() project.Add(itemGroup); //Let's enable XamlC assembly-wide - project.Add(AddFile("AssemblyInfo.cs", "Compile", "[assembly: Microsoft.Maui.Controls.Xaml.XamlCompilation (Microsoft.Maui.Controls.Xaml.XamlCompilationOptions.Compile)]")); + project.Add(AddFile("AssemblyInfo.cs", "Compile", "#pragma warning disable CS0618\n[assembly: Microsoft.Maui.Controls.Xaml.XamlCompilation (Microsoft.Maui.Controls.Xaml.XamlCompilationOptions.Compile)]")); //Add a single CSS file project.Add(AddFile("Foo.css", "MauiCss", Css.Foo)); @@ -299,7 +299,7 @@ public void HotReloadSupportForXSG(string configuration) } - // Tests the MauiXamlCValidateOnly=True MSBuild property + // Tests the default build behavior with SourceGen inflator [Theory] [InlineData("Debug")] [InlineData("Release")] @@ -318,16 +318,8 @@ public void ValidateOnly(string configuration) AssertExists(testDll, nonEmpty: true); using var assembly = AssemblyDefinition.ReadAssembly(testDll); var resources = assembly.MainModule.Resources.OfType().Select(e => e.Name).ToArray(); - if (configuration == "Debug") - { - // XAML files should remain as EmbeddedResource - Assert.Contains("test.MainPage.xaml", resources); - } - else - { - // XAML files should *not* remain as EmbeddedResource - Assert.DoesNotContain("test.MainPage.xaml", resources); - } + // With SourceGen as default inflator, XAML files are not embedded as resources + Assert.DoesNotContain("test.MainPage.xaml", resources); } [Fact(Skip = "source gen changes")] From 9959935031c11fdc2d6334dec13c2f7d238e0df9 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 14 Jan 2026 10:40:08 +0100 Subject: [PATCH 09/13] Set Controls.Sample to use Runtime inflator for deprecated API demos --- .../samples/Controls.Sample/Maui.Controls.Sample.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj b/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj index bb37513157c2..305a7cd407d1 100644 --- a/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj +++ b/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj @@ -12,6 +12,8 @@ false $(NoWarn);CA1416;CS0618;XC0618;XC0022 enable + + Runtime maccatalyst-x64 maccatalyst-arm64 @@ -92,4 +94,5 @@ + From 2ee5cc6ab8647f6b343e3db6f3f78cdf6a18f624 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 14 Jan 2026 10:58:52 +0100 Subject: [PATCH 10/13] Fix sample projects to use Runtime inflator for deprecated APIs - Controls.Sample: Already fixed (uses Runtime inflator) - Controls.Sample.Embedding: Set Runtime inflator (nullability issues) - Controls.Sample.Profiling: Set Runtime inflator + pragma for XamlCompilation - Essentials.Sample: Set Runtime inflator + pragma for XamlCompilation - DeviceTests.Runners: Set Runtime inflator (deprecated Frame) - DeviceRunner: Add pragma for deprecated XamlCompilation --- .../Maui.Controls.Sample.Embedding.csproj | 2 ++ .../Maui.Controls.Sample.Profiling.csproj | 2 ++ src/Controls/samples/Controls.Sample.Profiling/Startup.cs | 2 ++ src/Essentials/samples/Samples/App.xaml.cs | 2 ++ src/Essentials/samples/Samples/Essentials.Sample.csproj | 2 ++ .../DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj | 2 ++ .../src/DeviceTests.Runners/VisualRunner/DeviceRunner.cs | 2 ++ 7 files changed, 14 insertions(+) diff --git a/src/Controls/samples/Controls.Sample.Embedding/Maui.Controls.Sample.Embedding.csproj b/src/Controls/samples/Controls.Sample.Embedding/Maui.Controls.Sample.Embedding.csproj index 7847f7a76453..de71433a8836 100644 --- a/src/Controls/samples/Controls.Sample.Embedding/Maui.Controls.Sample.Embedding.csproj +++ b/src/Controls/samples/Controls.Sample.Embedding/Maui.Controls.Sample.Embedding.csproj @@ -10,6 +10,8 @@ enable true $(NoWarn);XC0022 + + Runtime .NET MAUI Embedding diff --git a/src/Controls/samples/Controls.Sample.Profiling/Maui.Controls.Sample.Profiling.csproj b/src/Controls/samples/Controls.Sample.Profiling/Maui.Controls.Sample.Profiling.csproj index c924967ed64d..9ce724666a0c 100644 --- a/src/Controls/samples/Controls.Sample.Profiling/Maui.Controls.Sample.Profiling.csproj +++ b/src/Controls/samples/Controls.Sample.Profiling/Maui.Controls.Sample.Profiling.csproj @@ -12,6 +12,8 @@ false true $(NoWarn);XC0022 + + Runtime maccatalyst-x64 maccatalyst-arm64 diff --git a/src/Controls/samples/Controls.Sample.Profiling/Startup.cs b/src/Controls/samples/Controls.Sample.Profiling/Startup.cs index c309ae512252..395587463043 100644 --- a/src/Controls/samples/Controls.Sample.Profiling/Startup.cs +++ b/src/Controls/samples/Controls.Sample.Profiling/Startup.cs @@ -3,7 +3,9 @@ using Microsoft.Maui.Controls.Xaml; using Microsoft.Maui.Hosting; +#pragma warning disable CS0618 // XamlCompilationAttribute is deprecated, remove this in .NET 12 [assembly: XamlCompilation(XamlCompilationOptions.Compile)] +#pragma warning restore CS0618 namespace Maui.Controls.Sample.Profiling { diff --git a/src/Essentials/samples/Samples/App.xaml.cs b/src/Essentials/samples/Samples/App.xaml.cs index fe621f9cf5cb..5cb7011e30dd 100644 --- a/src/Essentials/samples/Samples/App.xaml.cs +++ b/src/Essentials/samples/Samples/App.xaml.cs @@ -7,7 +7,9 @@ using Samples.View; using Device = Microsoft.Maui.Controls.Device; +#pragma warning disable CS0618 // XamlCompilationAttribute is deprecated, remove this in .NET 12 [assembly: XamlCompilation(XamlCompilationOptions.Compile)] +#pragma warning restore CS0618 namespace Samples { diff --git a/src/Essentials/samples/Samples/Essentials.Sample.csproj b/src/Essentials/samples/Samples/Essentials.Sample.csproj index bba1e8e89bab..ca4145d34abf 100644 --- a/src/Essentials/samples/Samples/Essentials.Sample.csproj +++ b/src/Essentials/samples/Samples/Essentials.Sample.csproj @@ -10,6 +10,8 @@ true false $(NoWarn);CA1416;XC0022 + + Runtime maccatalyst-x64 maccatalyst-arm64 diff --git a/src/TestUtils/src/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj b/src/TestUtils/src/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj index 0ee7399634a9..a92eddcc5998 100644 --- a/src/TestUtils/src/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj +++ b/src/TestUtils/src/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj @@ -11,6 +11,8 @@ true true true + + Runtime diff --git a/src/TestUtils/src/DeviceTests.Runners/VisualRunner/DeviceRunner.cs b/src/TestUtils/src/DeviceTests.Runners/VisualRunner/DeviceRunner.cs index 477bedb5dde8..6f3874a53176 100644 --- a/src/TestUtils/src/DeviceTests.Runners/VisualRunner/DeviceRunner.cs +++ b/src/TestUtils/src/DeviceTests.Runners/VisualRunner/DeviceRunner.cs @@ -11,7 +11,9 @@ using Microsoft.Maui.Storage; using Xunit; +#pragma warning disable CS0618 // XamlCompilation is obsolete [assembly: XamlCompilation(XamlCompilationOptions.Compile)] +#pragma warning restore CS0618 namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.VisualRunner { From abf7f9f864f0d2a8f0b174fff2e374fcaf51638e Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 14 Jan 2026 13:28:50 +0100 Subject: [PATCH 11/13] Fix Controls.Sample build with XSG default - Add per-file NoWarn for CS0612 on XAML files using obsolete APIs (Device, NamedSize) - Fix CS8622 nullability mismatches on event handlers (object -> object?) - Fix CS8600/CS8602 nullability issues with sender casts (add null-forgiving) - Add ButtonPage.xaml to Runtime inflator list (XSG NaN bug) --- .../Controls.Sample.Profiling/Startup.cs | 5 -- .../Maui.Controls.Sample.csproj | 49 ++++++++++++++++++- .../Controls.Sample/Pages/AppShell.xaml.cs | 2 +- .../ListViewContextActions.xaml.cs | 8 +-- .../TabbedPageGalleryMainPage.xaml.cs | 20 ++++---- .../Pages/Controls/ButtonPage.xaml.cs | 16 +++--- .../Pages/Controls/CheckBoxPage.xaml.cs | 2 +- .../CarouselViewPage.xaml.cs | 2 +- ...iedSizeDataTemplateSelectorGallery.xaml.cs | 6 +-- .../EmptyViewRTLGallery.xaml.cs | 2 +- .../ExampleTemplates.cs | 2 +- .../HeaderFooterGrid.xaml.cs | 6 +-- .../HeaderFooterGridHorizontal.xaml.cs | 6 +-- .../ItemsUpdatingScrollModeGallery.xaml.cs | 2 +- .../ScrollModeTestGallery.xaml.cs | 8 +-- .../MultipleBoundSelection.xaml.cs | 6 +-- .../SelectionSynchronization.xaml.cs | 2 +- .../SingleBoundSelection.xaml.cs | 4 +- .../Pages/Controls/DatePickerPage.xaml.cs | 16 +++--- .../Pages/Controls/EditorPage.xaml.cs | 16 +++--- .../Pages/Controls/EntryPage.xaml.cs | 30 ++++++------ .../Pages/Controls/HybridWebViewPage.xaml.cs | 12 ++--- .../Pages/Controls/ImageButtonPage.xaml.cs | 10 ++-- .../Pages/Controls/ImagePage.xaml.cs | 4 +- .../Pages/Controls/LabelPage.xaml.cs | 14 +++--- .../MapsGalleries/MapPinsGallery.xaml.cs | 8 +-- .../MapsGalleries/MapTypeGallery.xaml.cs | 8 +-- .../PinItemsSourceGallery.xaml.cs | 2 +- .../MapsGalleries/PolygonsGallery.xaml.cs | 2 +- .../Pages/Controls/PickerPage.xaml.cs | 26 +++++----- .../Pages/Controls/ProgressBarPage.xaml.cs | 2 +- .../RadioButtonGroupBindingGallery.xaml.cs | 4 +- .../Pages/Controls/RefreshViewPage.xaml.cs | 8 +-- .../Pages/Controls/SearchBarPage.xaml.cs | 12 ++--- .../ClipCornerRadiusGallery.xaml.cs | 2 +- .../UpdatePathDataGallery.xaml.cs | 2 +- .../Pages/Controls/ShapesPage.xaml.cs | 2 +- .../Pages/Controls/SliderPage.xaml.cs | 10 ++-- .../Pages/Controls/StepperPage.xaml.cs | 4 +- .../BasicSwipeGallery.xaml.cs | 2 +- .../CustomSizeSwipeViewGallery.xaml.cs | 6 +-- .../HorizontalSwipeThresholdGallery.xaml.cs | 4 +- .../SwipeItemPositionGallery.xaml.cs | 2 +- .../SwipeItemSizeGallery.xaml.cs | 2 +- .../SwipeItemViewPositionGallery.xaml.cs | 2 +- .../SwipeListViewGallery.xaml.cs | 2 +- .../SwipeViewNoLayoutGallery.xaml.cs | 2 +- .../VerticalSwipeThresholdGallery.xaml.cs | 4 +- .../Pages/Controls/TimePickerPage.xaml.cs | 12 ++--- .../Pages/Controls/TitleBarPage.xaml.cs | 20 ++++---- .../WebViewGalleries/WebViewGallery.xaml.cs | 26 +++++----- .../Pages/Core/AlertsPage.xaml.cs | 12 ++--- .../Pages/Core/ApplicationControlPage.xaml.cs | 2 +- .../BorderClipPlayground.xaml.cs | 8 +-- .../BorderGalleries/BorderPlayground.xaml.cs | 22 ++++----- .../Core/BorderGalleries/BorderStyles.xaml.cs | 4 +- .../Pages/Core/BrushesPage.xaml.cs | 12 ++--- .../Pages/Core/ContextFlyoutPage.xaml.cs | 32 ++++++------ .../Pages/Core/DispatcherPage.xaml.cs | 10 ++-- .../Core/DragAndDropBetweenLayouts.xaml.cs | 20 ++++---- .../Pages/Core/FlyoutPageGallery.xaml.cs | 6 +-- .../Pages/Core/FocusPage.xaml.cs | 6 +-- .../Pages/Core/InputTransparentPage.xaml.cs | 4 +- .../Controls.Sample/Pages/Core/MenuBarPage.cs | 4 +- .../Pages/Core/ModalPage.xaml.cs | 10 ++-- .../Pages/Core/MultiWindowPage.xaml.cs | 22 ++++----- .../Pages/Core/NavigationGallery.xaml.cs | 18 +++---- .../PanGestureEventsGallery.xaml.cs | 2 +- .../Core/PointerGestureGalleryPage.xaml.cs | 20 ++++---- .../Pages/Core/SemanticsPage.xaml.cs | 2 +- .../InvalidateShadowHostPage.xaml.cs | 6 +-- .../ShadowPlaygroundPage.xaml.cs | 6 +-- .../Core/ShellGalleries/ShellChromeGallery.cs | 26 +++++----- .../Controls.Sample/Pages/Core/ToolbarPage.cs | 14 +++--- .../Pages/Core/WindowTitleBar.xaml.cs | 2 +- .../Pages/HitTestingPage.xaml.cs | 6 +-- .../Pages/Layouts/LayoutIsEnabledPage.xaml.cs | 8 +-- .../ScrollViewPages/ScrollToEndPage.xaml.cs | 4 +- .../ScrollViewOrientationPage.xaml.cs | 2 +- .../ScrollViewTemplatePage.xaml.cs | 2 +- .../Pages/Others/GraphicsViewPage.xaml.cs | 22 ++++----- .../Pages/Others/RenderViewPage.xaml.cs | 6 +-- .../Pages/Others/TemplatePage.xaml.cs | 2 +- .../Controls.Sample/Pages/OthersPage.xaml.cs | 8 +-- .../Android/AndroidEntryPage.xaml.cs | 2 +- .../AndroidListViewFastScrollPage.xaml.cs | 2 +- .../AndroidSoftInputModeAdjustPage.xaml.cs | 4 +- ...AndroidSwipeViewTransitionModePage.xaml.cs | 6 +-- .../AndroidTabbedPageSwipePage.xaml.cs | 6 +-- .../Android/AndroidTitleViewPage.xaml.cs | 2 +- .../Windows/ContentPageTwo.xaml.cs | 2 +- .../WindowsAddRemoveToolbarItemsPage.xaml.cs | 6 +-- .../WindowsCollapseStyleChangerPage.xaml.cs | 2 +- .../WindowsCollapseWidthAdjusterPage.xaml.cs | 2 +- .../WindowsDragAndDropCustomization.xaml.cs | 2 +- .../Windows/WindowsListViewPage.xaml.cs | 6 +-- .../Windows/WindowsReadingOrderPage.xaml.cs | 2 +- .../Windows/WindowsRefreshViewPage.xaml.cs | 2 +- .../Windows/WindowsSearchBarPage.xaml.cs | 2 +- .../Windows/WindowsTileBarPage.xaml.cs | 14 +++--- ...WindowsToolbarPlacementChangerPage.xaml.cs | 2 +- ...WindowsVisualElementAccessKeysPage.xaml.cs | 2 +- .../Windows/WindowsWebViewPage.xaml.cs | 6 +-- .../iOS/iOSBlurEffectPage.xaml.cs | 8 +-- .../iOS/iOSDatePickerPage.xaml.cs | 2 +- .../iOS/iOSDragAndDropRequestFullSize.xaml.cs | 16 +++--- .../iOS/iOSEntryPage.xaml.cs | 2 +- .../iOS/iOSFlyoutPage.xaml.cs | 4 +- .../iOS/iOSHideHomeIndicatorPage.xaml.cs | 8 +-- .../iOS/iOSLargeTitlePage.xaml.cs | 4 +- .../iOS/iOSModalPagePresentationStyle.xaml.cs | 8 +-- .../iOS/iOSPanGestureRecognizerPage.xaml.cs | 4 +- .../iOS/iOSPickerPage.xaml.cs | 2 +- .../iOS/iOSSafeAreaPage.xaml.cs | 2 +- .../iOS/iOSScrollViewPage.xaml.cs | 4 +- .../iOS/iOSSearchBarPage.xaml.cs | 4 +- .../iOS/iOSSliderUpdateOnTapPage.xaml.cs | 2 +- .../iOS/iOSStatusBarPage.xaml.cs | 4 +- .../iOSSwipeViewTransitionModePage.xaml.cs | 4 +- .../iOS/iOSTimePickerPage.xaml.cs | 2 +- .../iOS/iOSTitleViewPage.xaml.cs | 2 +- .../iOSTranslucentNavigationBarPage.xaml.cs | 4 +- .../iOS/iOSTranslucentTabbedPage.xaml.cs | 4 +- .../Pages/SettingsPage.xaml.cs | 4 +- .../Pages/UserInterface/AnimationPage.xaml.cs | 6 +-- 125 files changed, 484 insertions(+), 444 deletions(-) diff --git a/src/Controls/samples/Controls.Sample.Profiling/Startup.cs b/src/Controls/samples/Controls.Sample.Profiling/Startup.cs index 395587463043..4c0d5f1cbdc5 100644 --- a/src/Controls/samples/Controls.Sample.Profiling/Startup.cs +++ b/src/Controls/samples/Controls.Sample.Profiling/Startup.cs @@ -1,12 +1,7 @@ using Microsoft.Maui; using Microsoft.Maui.Controls.Hosting; -using Microsoft.Maui.Controls.Xaml; using Microsoft.Maui.Hosting; -#pragma warning disable CS0618 // XamlCompilationAttribute is deprecated, remove this in .NET 12 -[assembly: XamlCompilation(XamlCompilationOptions.Compile)] -#pragma warning restore CS0618 - namespace Maui.Controls.Sample.Profiling { public static class MauiProgram diff --git a/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj b/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj index 305a7cd407d1..589dee412a63 100644 --- a/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj +++ b/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj @@ -12,8 +12,6 @@ false $(NoWarn);CA1416;CS0618;XC0618;XC0022 enable - - Runtime maccatalyst-x64 maccatalyst-arm64 @@ -94,5 +92,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Controls/samples/Controls.Sample/Pages/AppShell.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/AppShell.xaml.cs index dc3cc36018c9..643433974db6 100644 --- a/src/Controls/samples/Controls.Sample/Pages/AppShell.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/AppShell.xaml.cs @@ -18,7 +18,7 @@ public AppShell() public string ShellTitle { get; set; } = "Welcome to Shell"; - void OnChangeTabBarBackgroundColor(object sender, EventArgs e) + void OnChangeTabBarBackgroundColor(object? sender, EventArgs e) { var random = new Random(); diff --git a/src/Controls/samples/Controls.Sample/Pages/Compatibility/ListViewGalleries/ListViewContextActions.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Compatibility/ListViewGalleries/ListViewContextActions.xaml.cs index a31333a7dee5..7d2c34270e3f 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Compatibility/ListViewGalleries/ListViewContextActions.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Compatibility/ListViewGalleries/ListViewContextActions.xaml.cs @@ -17,15 +17,15 @@ public ListViewContextActions() .ToList(); } - private void OnDetailClicked(object sender, EventArgs e) + private void OnDetailClicked(object? sender, EventArgs e) { - var mi = ((MenuItem)sender); + var mi = ((MenuItem)sender!); DisplayAlertAsync("Detail Action", $"Details for item {mi.CommandParameter}", "OK"); } - private void OnDeleteClicked(object sender, EventArgs e) + private void OnDeleteClicked(object? sender, EventArgs e) { - var mi = ((MenuItem)sender); + var mi = ((MenuItem)sender!); DisplayAlertAsync("Delete Action", $"Deleting item {mi.CommandParameter}!", "OK"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Compatibility/TabbedPageGalleryMainPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Compatibility/TabbedPageGalleryMainPage.xaml.cs index db7b21c96343..fa9957ced561 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Compatibility/TabbedPageGalleryMainPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Compatibility/TabbedPageGalleryMainPage.xaml.cs @@ -22,7 +22,7 @@ void SetNewMainPage(Page page) Application.Current!.Windows[0].Page = page; } - void OnTabbedPageAsRoot(object sender, EventArgs e) + void OnTabbedPageAsRoot(object? sender, EventArgs e) { var topTabs = new TabbedPage() @@ -37,7 +37,7 @@ void OnTabbedPageAsRoot(object sender, EventArgs e) SetNewMainPage(topTabs); } - void OnSetToBottomTabs(object sender, EventArgs e) + void OnSetToBottomTabs(object? sender, EventArgs e) { var bottomTabs = new TabbedPage() { @@ -53,12 +53,12 @@ void OnSetToBottomTabs(object sender, EventArgs e) this.Window!.Page = bottomTabs; } - void OnChangeTabIndex(object sender, EventArgs e) + void OnChangeTabIndex(object? sender, EventArgs e) { GetTabbedPage().CurrentPage = GetTabbedPage().Children[1]; } - void OnToggleTabBar(object sender, EventArgs e) + void OnToggleTabBar(object? sender, EventArgs e) { if ((GetTabbedPage().BarBackground as SolidColorBrush)?.Color == SolidColorBrush.Purple.Color) GetTabbedPage().BarBackground = null; @@ -66,7 +66,7 @@ void OnToggleTabBar(object sender, EventArgs e) GetTabbedPage().BarBackground = SolidColorBrush.Purple; } - void OnToggleTabBarTextColor(object sender, EventArgs e) + void OnToggleTabBarTextColor(object? sender, EventArgs e) { if (GetTabbedPage().BarTextColor == Colors.Green) GetTabbedPage().BarTextColor = null; @@ -74,7 +74,7 @@ void OnToggleTabBarTextColor(object sender, EventArgs e) GetTabbedPage().BarTextColor = Colors.Green; } - void OnToggleTabItemUnSelectedColor(object sender, EventArgs e) + void OnToggleTabItemUnSelectedColor(object? sender, EventArgs e) { if (GetTabbedPage().UnselectedTabColor == Colors.Blue) GetTabbedPage().UnselectedTabColor = null; @@ -82,7 +82,7 @@ void OnToggleTabItemUnSelectedColor(object sender, EventArgs e) GetTabbedPage().UnselectedTabColor = Colors.Blue; } - void OnToggleTabItemSelectedColor(object sender, EventArgs e) + void OnToggleTabItemSelectedColor(object? sender, EventArgs e) { if (GetTabbedPage().SelectedTabColor == Colors.Pink) GetTabbedPage().SelectedTabColor = null; @@ -90,7 +90,7 @@ void OnToggleTabItemSelectedColor(object sender, EventArgs e) GetTabbedPage().SelectedTabColor = Colors.Pink; } - void OnRemoveTab(object sender, EventArgs e) + void OnRemoveTab(object? sender, EventArgs e) { if (GetTabbedPage().Children.LastOrDefault() is TabbedPageGalleryMainPage mainPage) { @@ -98,7 +98,7 @@ void OnRemoveTab(object sender, EventArgs e) } } - void OnRemoveAllTabs(object sender, EventArgs e) + void OnRemoveAllTabs(object? sender, EventArgs e) { while (GetTabbedPage().Children.LastOrDefault() is TabbedPageGalleryMainPage mainPage) { @@ -106,7 +106,7 @@ void OnRemoveAllTabs(object sender, EventArgs e) } } - void OnAddTab(object sender, EventArgs e) + void OnAddTab(object? sender, EventArgs e) { GetTabbedPage() .Children diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/ButtonPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/ButtonPage.xaml.cs index 44a441ace70c..7f787d06107c 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/ButtonPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/ButtonPage.xaml.cs @@ -19,12 +19,12 @@ public ButtonPage() BindingContext = new ButtonPageViewModel(); } - void OnButtonClicked(object sender, System.EventArgs e) + void OnButtonClicked(object? sender, System.EventArgs e) { Debug.WriteLine("Clicked"); } - void Button_Clicked(System.Object sender, System.EventArgs e) + void Button_Clicked(System.Object? sender, System.EventArgs e) { if (ImageSourceButton.ImageSource is null) { @@ -36,7 +36,7 @@ void Button_Clicked(System.Object sender, System.EventArgs e) } } - void OnPositionChange(object sender, System.EventArgs e) + void OnPositionChange(object? sender, System.EventArgs e) { var newPosition = ((int)positionChange.ContentLayout.Position) + 1; @@ -48,21 +48,21 @@ void OnPositionChange(object sender, System.EventArgs e) positionChange.ContentLayout.Spacing); } - void OnDecreaseSpacing(object sender, System.EventArgs e) + void OnDecreaseSpacing(object? sender, System.EventArgs e) { positionChange.ContentLayout = new Button.ButtonContentLayout(positionChange.ContentLayout.Position, positionChange.ContentLayout.Spacing - 1); } - void OnIncreasingSpacing(object sender, System.EventArgs e) + void OnIncreasingSpacing(object? sender, System.EventArgs e) { positionChange.ContentLayout = new Button.ButtonContentLayout(positionChange.ContentLayout.Position, positionChange.ContentLayout.Spacing + 1); } - void OnLineBreakModeButtonClicked(object sender, System.EventArgs e) + void OnLineBreakModeButtonClicked(object? sender, System.EventArgs e) { LineBreakModeButton.LineBreakMode = ImageLineBreakModeButton.LineBreakMode = SelectLineBreakMode(); } @@ -90,13 +90,13 @@ LineBreakMode SelectLineBreakMode() int _backgroundCount; - void OnBackgroundButtonClicked(object sender, System.EventArgs e) + void OnBackgroundButtonClicked(object? sender, System.EventArgs e) { BackgroundButton.Text = $"Background tapped {_backgroundCount} times"; _backgroundCount++; } - void OnChangeBrushButtonClicked(System.Object sender, System.EventArgs e) + void OnChangeBrushButtonClicked(System.Object? sender, System.EventArgs e) { UpdateButtonBrush(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CheckBoxPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CheckBoxPage.xaml.cs index f7a2925fb4e3..3fbccb1f3d0a 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CheckBoxPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CheckBoxPage.xaml.cs @@ -13,7 +13,7 @@ public CheckBoxPage() UpdateControls(); } - void OnChangeIsCheckedButtonClicked(object sender, EventArgs e) + void OnChangeIsCheckedButtonClicked(object? sender, EventArgs e) { _isGreen = !_isGreen; UpdateControls(); diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/CarouselViewGalleries/CarouselViewPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/CarouselViewGalleries/CarouselViewPage.xaml.cs index 86948e3cec35..229b32d7a20d 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/CarouselViewGalleries/CarouselViewPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/CarouselViewGalleries/CarouselViewPage.xaml.cs @@ -9,7 +9,7 @@ public CarouselViewPage() InitializeComponent(); } - async void TapGestureRecognizer_Tapped(object sender, EventArgs e) + async void TapGestureRecognizer_Tapped(object? sender, EventArgs e) { await DisplayAlertAsync("Item", "Tapped", "Successfully"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/DataTemplateSelectorGalleries/VariedSizeDataTemplateSelectorGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/DataTemplateSelectorGalleries/VariedSizeDataTemplateSelectorGallery.xaml.cs index 6f5f101ce360..d251b1108b65 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/DataTemplateSelectorGalleries/VariedSizeDataTemplateSelectorGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/DataTemplateSelectorGalleries/VariedSizeDataTemplateSelectorGallery.xaml.cs @@ -64,7 +64,7 @@ public bool ShouldTriggerReset set => SetValue(ref _shouldTriggerReset, value); } - void Insert_OnClicked(object sender, EventArgs e) + void Insert_OnClicked(object? sender, EventArgs e) { if (!IsValid(out var index)) return; @@ -72,7 +72,7 @@ void Insert_OnClicked(object sender, EventArgs e) Items.Insert(index, CreateDrink()); } - void Add_OnClicked(object sender, EventArgs e) + void Add_OnClicked(object? sender, EventArgs e) { if (!IsValid(out var _)) return; @@ -89,7 +89,7 @@ void SetValue(ref T backingField, in T value, [CallerMemberName] string calle OnPropertyChanged(callerName); } - void Remove_OnClicked(object sender, EventArgs e) + void Remove_OnClicked(object? sender, EventArgs e) { if (!IsValid(out var index)) return; diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/EmptyViewGalleries/EmptyViewRTLGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/EmptyViewGalleries/EmptyViewRTLGallery.xaml.cs index ecf5577b8b17..d422760a26a2 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/EmptyViewGalleries/EmptyViewRTLGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/EmptyViewGalleries/EmptyViewRTLGallery.xaml.cs @@ -22,7 +22,7 @@ public EmptyViewRTLGallery() SearchBar.SearchCommand = new Command(() => _demoFilteredItemSource.FilterItems(SearchBar.Text)); } - void OnPickerSelectedIndexChanged(object sender, EventArgs e) + void OnPickerSelectedIndexChanged(object? sender, EventArgs e) { switch (Picker.SelectedIndex) { diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ExampleTemplates.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ExampleTemplates.cs index 27f503dbdf12..26f860650ba0 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ExampleTemplates.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ExampleTemplates.cs @@ -539,7 +539,7 @@ public static DataTemplate GroupFooterTemplate() }); } - static void More_Clicked(object sender, EventArgs e) + static void More_Clicked(object? sender, EventArgs e) { throw new NotImplementedException(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/HeaderFooterGalleries/HeaderFooterGrid.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/HeaderFooterGalleries/HeaderFooterGrid.xaml.cs index 20b93de34af3..9a472564b10b 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/HeaderFooterGalleries/HeaderFooterGrid.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/HeaderFooterGalleries/HeaderFooterGrid.xaml.cs @@ -20,13 +20,13 @@ public HeaderFooterGrid() CollectionView.ItemsSource = _demoFilteredItemSource.Items; } - void AddContentClicked(object sender, System.EventArgs e) + void AddContentClicked(object? sender, System.EventArgs e) { if (sender is VisualElement ve && ve.Parent is StackLayout sl) sl.Children.Add(new Label() { Text = "Grow" }); } - void ToggleHeader(object sender, System.EventArgs e) + void ToggleHeader(object? sender, System.EventArgs e) { header = CollectionView.Header ?? header; @@ -36,7 +36,7 @@ void ToggleHeader(object sender, System.EventArgs e) CollectionView.Header = null; } - void ToggleFooter(object sender, System.EventArgs e) + void ToggleFooter(object? sender, System.EventArgs e) { footer = CollectionView.Footer ?? footer; diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/HeaderFooterGalleries/HeaderFooterGridHorizontal.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/HeaderFooterGalleries/HeaderFooterGridHorizontal.xaml.cs index 097682a1a70d..544bfff3f7ce 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/HeaderFooterGalleries/HeaderFooterGridHorizontal.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/HeaderFooterGalleries/HeaderFooterGridHorizontal.xaml.cs @@ -26,13 +26,13 @@ public HeaderFooterGridHorizontal() - void AddContentClicked(object sender, System.EventArgs e) + void AddContentClicked(object? sender, System.EventArgs e) { if (sender is VisualElement ve && ve.Parent is StackLayout sl) sl.Children.Add(new Label() { Text = "Grow" }); } - void ToggleHeader(object sender, System.EventArgs e) + void ToggleHeader(object? sender, System.EventArgs e) { header = CollectionView.Header ?? header; @@ -42,7 +42,7 @@ void ToggleHeader(object sender, System.EventArgs e) CollectionView.Header = null; } - void ToggleFooter(object sender, System.EventArgs e) + void ToggleFooter(object? sender, System.EventArgs e) { footer = CollectionView.Footer ?? footer; diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ScrollModeGalleries/ItemsUpdatingScrollModeGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ScrollModeGalleries/ItemsUpdatingScrollModeGallery.xaml.cs index 480066cfa8e0..d6d77fdeab2d 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ScrollModeGalleries/ItemsUpdatingScrollModeGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ScrollModeGalleries/ItemsUpdatingScrollModeGallery.xaml.cs @@ -48,7 +48,7 @@ protected override async void OnAppearing() await _viewModel.LoadItemsAsync(); } - void OnItemsUpdatingScrollModeChanged(object sender, EventArgs e) + void OnItemsUpdatingScrollModeChanged(object? sender, EventArgs e) { CollectionView.ItemsUpdatingScrollMode = (ItemsUpdatingScrollMode)((EnumPicker)sender!).SelectedItem; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ScrollModeGalleries/ScrollModeTestGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ScrollModeGalleries/ScrollModeTestGallery.xaml.cs index d6692ba26d9f..db677bb7c20c 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ScrollModeGalleries/ScrollModeTestGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ScrollModeGalleries/ScrollModeTestGallery.xaml.cs @@ -30,12 +30,12 @@ public ScrollModeTestGallery(IItemsLayout? itemsLayout = null, Func { @@ -33,7 +33,7 @@ private void ResetClicked(object sender, EventArgs e) }; } - private void DirectUpdateClicked(object sender, EventArgs e) + private void DirectUpdateClicked(object? sender, EventArgs e) { CollectionView.SelectedItems.Clear(); CollectionView.SelectedItems.Add(_vm.Items![0]); diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/SelectionGalleries/SelectionSynchronization.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/SelectionGalleries/SelectionSynchronization.xaml.cs index 771417c106b7..365824a3d103 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/SelectionGalleries/SelectionSynchronization.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/SelectionGalleries/SelectionSynchronization.xaml.cs @@ -20,7 +20,7 @@ public SelectionSynchronization() BindingContext = new SelectionSyncModel(); } - void SwitchSourceClicked(object sender, EventArgs e) + void SwitchSourceClicked(object? sender, EventArgs e) { var newSource = new List { "Item -1", "Item 0", "Item 1", "Item 3", "Item 4", "Item 5" }; CVSwitchSource.ItemsSource = newSource; diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/SelectionGalleries/SingleBoundSelection.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/SelectionGalleries/SingleBoundSelection.xaml.cs index fd9dba9c27c3..cdbed6ac4a81 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/SelectionGalleries/SingleBoundSelection.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/SelectionGalleries/SingleBoundSelection.xaml.cs @@ -16,12 +16,12 @@ public SingleBoundSelection() BindingContext = _vm; } - private void ResetClicked(object sender, EventArgs e) + private void ResetClicked(object? sender, EventArgs e) { _vm.SelectedItem = _vm.Items![0]; } - private void ClearClicked(object sender, EventArgs e) + private void ClearClicked(object? sender, EventArgs e) { _vm.SelectedItem = null; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml.cs index 399a0f205316..5ae2154e26e9 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml.cs @@ -30,12 +30,12 @@ protected override void OnDisappearing() IsOpenDatePicker.Closed -= IsOpenDatePickerClosed; } - void OnUpdateBackgroundButtonClicked(object sender, EventArgs e) + void OnUpdateBackgroundButtonClicked(object? sender, EventArgs e) { UpdateDatePickerBackground(); } - void OnClearBackgroundButtonClicked(object sender, EventArgs e) + void OnClearBackgroundButtonClicked(object? sender, EventArgs e) { BackgroundDatePicker.Background = null; } @@ -57,32 +57,32 @@ void UpdateDatePickerBackground() }; } - void OnFocusDatePickerFocused(object sender, FocusEventArgs e) + void OnFocusDatePickerFocused(object? sender, FocusEventArgs e) { Debug.WriteLine("Focused"); } - void OnFocusDatePickerUnfocused(object sender, FocusEventArgs e) + void OnFocusDatePickerUnfocused(object? sender, FocusEventArgs e) { Debug.WriteLine("Unfocused"); } - void SetDatePickerToNull(object sender, EventArgs e) + void SetDatePickerToNull(object? sender, EventArgs e) { NullDatePicker.Date = null; } - void SetDatePickerToToday(object sender, EventArgs e) + void SetDatePickerToToday(object? sender, EventArgs e) { NullDatePicker.Date = DateTime.Now; } - void OnOpenClicked(object sender, EventArgs e) + void OnOpenClicked(object? sender, EventArgs e) { IsOpenDatePicker.IsOpen = true; } - void OnCloseClicked(object sender, EventArgs e) + void OnCloseClicked(object? sender, EventArgs e) { IsOpenDatePicker.IsOpen = false; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/EditorPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/EditorPage.xaml.cs index 252b76ff9b22..e12aa5e97c1c 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/EditorPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/EditorPage.xaml.cs @@ -13,30 +13,30 @@ public EditorPage() UpdateEditorBackground(); } - void OnEditorCompleted(object sender, EventArgs e) + void OnEditorCompleted(object? sender, EventArgs e) { - var text = ((Editor)sender).Text; + var text = ((Editor)sender!).Text; DisplayAlertAsync("Completed", text, "Ok"); } - void OnEditorFocused(object sender, FocusEventArgs e) + void OnEditorFocused(object? sender, FocusEventArgs e) { - var text = ((Editor)sender).Text; + var text = ((Editor)sender!).Text; DisplayAlertAsync("Focused", text, "Ok"); } - void OnEditorUnfocused(object sender, FocusEventArgs e) + void OnEditorUnfocused(object? sender, FocusEventArgs e) { - var text = ((Editor)sender).Text; + var text = ((Editor)sender!).Text; DisplayAlertAsync("Unfocused", text, "Ok"); } - void OnUpdateBackgroundButtonClicked(object sender, System.EventArgs e) + void OnUpdateBackgroundButtonClicked(object? sender, System.EventArgs e) { UpdateEditorBackground(); } - void OnClearBackgroundButtonClicked(object sender, System.EventArgs e) + void OnClearBackgroundButtonClicked(object? sender, System.EventArgs e) { BackgroundEditor.Background = null; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/EntryPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/EntryPage.xaml.cs index a4d6afd8a0d5..a9c660fd25fc 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/EntryPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/EntryPage.xaml.cs @@ -35,12 +35,12 @@ public EntryPage() UpdateEntryBackgroundColor(); } - void OnSlideCursorPositionValueChanged(object sender, ValueChangedEventArgs e) + void OnSlideCursorPositionValueChanged(object? sender, ValueChangedEventArgs e) { entryCursor.CursorPosition = (int)e.NewValue; } - void OnSlideSelectionValueChanged(object sender, ValueChangedEventArgs e) + void OnSlideSelectionValueChanged(object? sender, ValueChangedEventArgs e) { entrySelection.SelectionLength = (int)e.NewValue; } @@ -61,40 +61,40 @@ void OnEntrySelectionPropertyChanged(object? sender, System.ComponentModel.Prope sldSelection.Maximum = ((Entry)sender!).Text.Length; } - void OnEntryCompleted(object sender, EventArgs e) + void OnEntryCompleted(object? sender, EventArgs e) { - var text = ((Microsoft.Maui.Controls.Entry)sender).Text; + var text = ((Microsoft.Maui.Controls.Entry)sender!).Text; DisplayAlertAsync("Completed", text, "Ok"); } - void OnEntryFocused(object sender, FocusEventArgs e) + void OnEntryFocused(object? sender, FocusEventArgs e) { - var text = ((Microsoft.Maui.Controls.Entry)sender).Text; + var text = ((Microsoft.Maui.Controls.Entry)sender!).Text; DisplayAlertAsync("Focused", text, "Ok"); } - void OnEntryUnfocused(object sender, FocusEventArgs e) + void OnEntryUnfocused(object? sender, FocusEventArgs e) { - var text = ((Entry)sender).Text; + var text = ((Entry)sender!).Text; DisplayAlertAsync("Unfocused", text, "Ok"); } - void OnUpdateBackgroundColorButtonClicked(object sender, System.EventArgs e) + void OnUpdateBackgroundColorButtonClicked(object? sender, System.EventArgs e) { UpdateEntryBackgroundColor(); } - void OnClearBackgroundColorButtonClicked(object sender, System.EventArgs e) + void OnClearBackgroundColorButtonClicked(object? sender, System.EventArgs e) { BackgroundColorEntry.BackgroundColor = null; } - void OnUpdateBackgroundButtonClicked(object sender, System.EventArgs e) + void OnUpdateBackgroundButtonClicked(object? sender, System.EventArgs e) { UpdateEntryBackground(); } - void OnClearBackgroundButtonClicked(object sender, System.EventArgs e) + void OnClearBackgroundButtonClicked(object? sender, System.EventArgs e) { BackgroundEntry.Background = null; } @@ -123,17 +123,17 @@ void UpdateEntryBackground() }; } - void ShowSoftInputAsyncButton_Clicked(object sender, EventArgs e) + void ShowSoftInputAsyncButton_Clicked(object? sender, EventArgs e) { PlaceholderEntryItem.ShowSoftInputAsync(System.Threading.CancellationToken.None); } - void HideSoftInputAsyncButton_Clicked(object sender, EventArgs e) + void HideSoftInputAsyncButton_Clicked(object? sender, EventArgs e) { PlaceholderEntryItem.HideSoftInputAsync(System.Threading.CancellationToken.None); } - void OnReturnTypeEntryTextChanged(object sender, TextChangedEventArgs e) + void OnReturnTypeEntryTextChanged(object? sender, TextChangedEventArgs e) { Random rnd = new Random(); var returnTypeCount = Enum.GetNames(typeof(ReturnType)).Length; diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/HybridWebViewPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/HybridWebViewPage.xaml.cs index fa51446810f2..673296d2b3c5 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/HybridWebViewPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/HybridWebViewPage.xaml.cs @@ -18,12 +18,12 @@ public HybridWebViewPage() } int count; - private void SendMessageButton_Clicked(object sender, EventArgs e) + private void SendMessageButton_Clicked(object? sender, EventArgs e) { hwv.SendRawMessage($"Hello from C#! #{count++}"); } - private async void InvokeJSMethodButton_Clicked(object sender, EventArgs e) + private async void InvokeJSMethodButton_Clicked(object? sender, EventArgs e) { var statusResult = ""; @@ -47,7 +47,7 @@ private async void InvokeJSMethodButton_Clicked(object sender, EventArgs e) Dispatcher.Dispatch(() => statusText.Text += statusResult); } - private async void InvokeAsyncJSMethodButton_Clicked(object sender, EventArgs e) + private async void InvokeAsyncJSMethodButton_Clicked(object? sender, EventArgs e) { var statusResult = ""; @@ -69,12 +69,12 @@ private async void InvokeAsyncJSMethodButton_Clicked(object sender, EventArgs e) Dispatcher.Dispatch(() => statusText.Text += statusResult); } - private void hwv_RawMessageReceived(object sender, HybridWebViewRawMessageReceivedEventArgs e) + private void hwv_RawMessageReceived(object? sender, HybridWebViewRawMessageReceivedEventArgs e) { Dispatcher.Dispatch(() => statusText.Text += Environment.NewLine + e.Message); } - private async void InvokeJSExceptionButton_Clicked(object sender, EventArgs e) + private async void InvokeJSExceptionButton_Clicked(object? sender, EventArgs e) { var statusResult = ""; @@ -97,7 +97,7 @@ private async void InvokeJSExceptionButton_Clicked(object sender, EventArgs e) Dispatcher.Dispatch(() => statusText.Text += statusResult); } - private async void InvokeJSAsyncExceptionButton_Clicked(object sender, EventArgs e) + private async void InvokeJSAsyncExceptionButton_Clicked(object? sender, EventArgs e) { var statusResult = ""; diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/ImageButtonPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/ImageButtonPage.xaml.cs index 604b6482eeae..2c0b39564159 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/ImageButtonPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/ImageButtonPage.xaml.cs @@ -25,30 +25,30 @@ public ImageButtonPage() UpdateImageButtonBackground(); } - void OnImageButtonClicked(object sender, EventArgs e) + void OnImageButtonClicked(object? sender, EventArgs e) { _clickTotal += 1; InfoLabel.Text = $"{_clickTotal} ImageButton click{(_clickTotal == 1 ? "" : "s")}"; } - void OnResizeImageButtonClicked(object sender, EventArgs e) + void OnResizeImageButtonClicked(object? sender, EventArgs e) { ResizeImageButton.HeightRequest = 100; ResizeImageButton.WidthRequest = 100; } - void UseOnlineSource_Clicked(object sender, EventArgs e) + void UseOnlineSource_Clicked(object? sender, EventArgs e) { AnimatedGifImage.Source = ImageSource.FromUri(new Uri("https://raw.githubusercontent.com/dotnet/maui/126f47aaf9d5c01224f54fe1c6bfb1c8299cc2fe/src/Compatibility/ControlGallery/src/iOS/GifTwo.gif")); } - void OnUpdateBackgroundButtonClicked(object sender, EventArgs e) + void OnUpdateBackgroundButtonClicked(object? sender, EventArgs e) { UpdateImageButtonBackground(); } - void OnRemoveBackgroundButtonClicked(object sender, EventArgs e) + void OnRemoveBackgroundButtonClicked(object? sender, EventArgs e) { BackgroundImageButton.Background = null; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/ImagePage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/ImagePage.xaml.cs index 19395cdd3627..a1784c6b5ebf 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/ImagePage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/ImagePage.xaml.cs @@ -20,12 +20,12 @@ protected override void OnAppearing() StreamSourceImage.Source = ImageSource.FromStream(() => new MemoryStream(imageBytes)); } - void AnimationStartStop_Clicked(object sender, EventArgs e) + void AnimationStartStop_Clicked(object? sender, EventArgs e) { AnimatedGifImage.IsAnimationPlaying = !AnimatedGifImage.IsAnimationPlaying; } - void UseOnlineSource_Clicked(object sender, EventArgs e) + void UseOnlineSource_Clicked(object? sender, EventArgs e) { AnimatedGifImage.Source = ImageSource.FromUri(new Uri("https://raw.githubusercontent.com/dotnet/maui/126f47aaf9d5c01224f54fe1c6bfb1c8299cc2fe/src/Compatibility/ControlGallery/src/iOS/GifTwo.gif")); diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/LabelPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/LabelPage.xaml.cs index f7751ad46c61..1979dceaf199 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/LabelPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/LabelPage.xaml.cs @@ -17,12 +17,12 @@ public LabelPage() BindingContext = new LabelViewModel(); } - void TapGestureRecognizer_Tapped(object sender, EventArgs e) + void TapGestureRecognizer_Tapped(object? sender, EventArgs e) { SetRandomBackgroundColor(GestureSpan); } - void ChangeFormattedString_Clicked(object sender, EventArgs e) + void ChangeFormattedString_Clicked(object? sender, EventArgs e) { labelFormattedString.FormattedText = new FormattedString { @@ -41,26 +41,26 @@ void ChangeFormattedString_Clicked(object sender, EventArgs e) }; } - void OnLink1Tapped(object sender, EventArgs e) + void OnLink1Tapped(object? sender, EventArgs e) { SetRandomBackgroundColor(Link1); } - void OnLink2Tapped(object sender, EventArgs e) + void OnLink2Tapped(object? sender, EventArgs e) { SetRandomBackgroundColor(Link2); } - void OnLink3Tapped(object sender, EventArgs e) + void OnLink3Tapped(object? sender, EventArgs e) { SetRandomBackgroundColor(Link3); } - void OnLink4Tapped(object sender, EventArgs e) + void OnLink4Tapped(object? sender, EventArgs e) { SetRandomBackgroundColor(Link4); } - void OnLink5Tapped(object sender, EventArgs e) + void OnLink5Tapped(object? sender, EventArgs e) { SetRandomBackgroundColor(Link5); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapPinsGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapPinsGallery.xaml.cs index bcb88b18abbf..cdba8eeb4c49 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapPinsGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapPinsGallery.xaml.cs @@ -76,12 +76,12 @@ public MapPinsGallery() pinsMap.Pins.Add(microsoftPin); } - void OnAddPinClicked(object sender, EventArgs e) + void OnAddPinClicked(object? sender, EventArgs e) { AddPin(); } - void OnRemovePinClicked(object sender, EventArgs e) + void OnRemovePinClicked(object? sender, EventArgs e) { if (pinsMap.Pins.Count > 0) { @@ -90,7 +90,7 @@ void OnRemovePinClicked(object sender, EventArgs e) } } - void OnAdd10PinsClicked(object sender, EventArgs e) + void OnAdd10PinsClicked(object? sender, EventArgs e) { for (int i = 0; i <= 10; i++) { @@ -107,7 +107,7 @@ void AddPin() }); } - void OnMapClicked(object sender, MapClickedEventArgs e) + void OnMapClicked(object? sender, MapClickedEventArgs e) { DisplayAlertAsync("Map", $"Map {e.Location.Latitude}, {e.Location.Longitude} clicked.", "Ok"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapTypeGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapTypeGallery.xaml.cs index ddaa0c248211..b815c8609b28 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapTypeGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapTypeGallery.xaml.cs @@ -13,11 +13,11 @@ public MapTypeGallery() InitializeComponent(); } - void MapTypePicker_SelectedIndexChanged(object sender, System.EventArgs e) + void MapTypePicker_SelectedIndexChanged(object? sender, System.EventArgs e) { - var picker = (Picker)sender; + var picker = (Picker)sender!; - switch (picker.SelectedItem.ToString()) + switch (picker.SelectedItem!.ToString()) { default: case "Street": @@ -32,7 +32,7 @@ void MapTypePicker_SelectedIndexChanged(object sender, System.EventArgs e) } } - void OnSliderValueChanged(object sender, ValueChangedEventArgs e) + void OnSliderValueChanged(object? sender, ValueChangedEventArgs e) { double zoomLevel = e.NewValue; double latlongDegrees = 360 / (Math.Pow(2, zoomLevel)); diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/PinItemsSourceGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/PinItemsSourceGallery.xaml.cs index ebf6a6a4d7ce..1f6ced678171 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/PinItemsSourceGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/PinItemsSourceGallery.xaml.cs @@ -20,7 +20,7 @@ public PinItemsSourceGallery() map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(39.8283459, -98.5794797), Distance.FromMiles(1500))); } - void OnMapClicked(object sender, MapClickedEventArgs e) + void OnMapClicked(object? sender, MapClickedEventArgs e) { System.Diagnostics.Debug.WriteLine($"MapClick: {e.Location.Latitude}, {e.Location.Longitude}"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/PolygonsGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/PolygonsGallery.xaml.cs index 6884973a5fac..163f1df4e995 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/PolygonsGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/PolygonsGallery.xaml.cs @@ -10,7 +10,7 @@ public PolygonsGallery() InitializeComponent(); } - void OnClearMapElementsClicked(object sender, EventArgs args) + void OnClearMapElementsClicked(object? sender, EventArgs args) { MapElementsMap.MapElements.Clear(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/PickerPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/PickerPage.xaml.cs index af56141d2376..4ea8189a20cc 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/PickerPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/PickerPage.xaml.cs @@ -46,9 +46,9 @@ protected override void OnDisappearing() IsOpenPicker.Closed -= IsOpenPickerClosed; } - void OnSelectedIndexChanged(object sender, EventArgs e) + void OnSelectedIndexChanged(object? sender, EventArgs e) { - string selectedCountry = (string)((Picker)sender).SelectedItem; + string selectedCountry = (string)((Picker)sender!).SelectedItem; DisplayAlertAsync("SelectedIndexChanged", selectedCountry, "Ok"); } @@ -61,12 +61,12 @@ void OnSelectedIndexChanged(object sender, EventArgs e) public string[] MorePickerItems { get; } = Enumerable.Range(1, 20).Select(i => $"Item {i}").ToArray(); - void OnUpdateBackgroundButtonClicked(object sender, System.EventArgs e) + void OnUpdateBackgroundButtonClicked(object? sender, System.EventArgs e) { UpdatePickerBackground(); } - void OnClearBackgroundButtonClicked(object sender, System.EventArgs e) + void OnClearBackgroundButtonClicked(object? sender, System.EventArgs e) { BackgroundPicker.Background = null; } @@ -88,19 +88,19 @@ void UpdatePickerBackground() }; } - void OnClearItemsButtonClicked(object sender, EventArgs e) + void OnClearItemsButtonClicked(object? sender, EventArgs e) { DynamicItemsPicker.Items.Clear(); } - void OnAddItemsButtonClicked(object sender, EventArgs e) + void OnAddItemsButtonClicked(object? sender, EventArgs e) { DynamicItemsPicker.Items.Add("New Item 1"); DynamicItemsPicker.Items.Add("New Item 2"); DynamicItemsPicker.Items.Add("New Item 3"); } - void OnReplaceItemsButtonClicked(object sender, EventArgs e) + void OnReplaceItemsButtonClicked(object? sender, EventArgs e) { DynamicItemsPicker.Items.Clear(); @@ -109,12 +109,12 @@ void OnReplaceItemsButtonClicked(object sender, EventArgs e) DynamicItemsPicker.Items.Add("Item Three"); } - void OnSetBindingContextClicked(object sender, EventArgs e) + void OnSetBindingContextClicked(object? sender, EventArgs e) { UpdatePickerBindingContext(); } - void OnRemoveBindingContextClicked(object sender, EventArgs e) + void OnRemoveBindingContextClicked(object? sender, EventArgs e) { BindingContextLayout.BindingContext = null; } @@ -134,13 +134,13 @@ void UpdatePickerBindingContext() }; } - void OnUpdateHorizontalOptionsClicked(object sender, EventArgs e) + void OnUpdateHorizontalOptionsClicked(object? sender, EventArgs e) { AlignmentPicker.HorizontalOptions = GetLayoutOptions(_horizontalOptionsIndex); UpdateIndex(ref _horizontalOptionsIndex); } - void OnUpdateVerticalOptionsClicked(object sender, EventArgs e) + void OnUpdateVerticalOptionsClicked(object? sender, EventArgs e) { AlignmentPicker.VerticalOptions = GetLayoutOptions(_verticalOptionsIndex); UpdateIndex(ref _verticalOptionsIndex); @@ -169,12 +169,12 @@ LayoutOptions GetLayoutOptions(int index) } } - void OnOpenClicked(object sender, EventArgs e) + void OnOpenClicked(object? sender, EventArgs e) { IsOpenPicker.IsOpen = true; } - void OnCloseClicked(object sender, EventArgs e) + void OnCloseClicked(object? sender, EventArgs e) { IsOpenPicker.IsOpen = false; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/ProgressBarPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/ProgressBarPage.xaml.cs index 3c258fdf8bab..415a26e77ab4 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/ProgressBarPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/ProgressBarPage.xaml.cs @@ -10,7 +10,7 @@ public ProgressBarPage() InitializeComponent(); } - void OnProgressToClicked(object sender, EventArgs args) + void OnProgressToClicked(object? sender, EventArgs args) { ProgressToBar.ProgressTo(1.0, 1000, Easing.Linear); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/RadioButtonGalleries/RadioButtonGroupBindingGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/RadioButtonGalleries/RadioButtonGroupBindingGallery.xaml.cs index b5dd7ae8fd20..1819f773fdd6 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/RadioButtonGalleries/RadioButtonGroupBindingGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/RadioButtonGalleries/RadioButtonGroupBindingGallery.xaml.cs @@ -15,12 +15,12 @@ public RadioButtonGroupBindingGallery() BindingContext = _viewModel; } - private void Set_Button_Clicked(object sender, System.EventArgs e) + private void Set_Button_Clicked(object? sender, System.EventArgs e) { _viewModel.Selection = "B"; } - private void Clear_Button_Clicked(object sender, System.EventArgs e) + private void Clear_Button_Clicked(object? sender, System.EventArgs e) { _viewModel.Selection = null; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/RefreshViewPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/RefreshViewPage.xaml.cs index 1f6e9c5bc4ad..c7c86279d6e0 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/RefreshViewPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/RefreshViewPage.xaml.cs @@ -10,7 +10,7 @@ public RefreshViewPage() InitializeComponent(); } - private void OnToggleRefreshColorClicked(object sender, System.EventArgs e) + private void OnToggleRefreshColorClicked(object? sender, System.EventArgs e) { if (refreshView.RefreshColor == Colors.Red) { @@ -22,7 +22,7 @@ private void OnToggleRefreshColorClicked(object sender, System.EventArgs e) } } - private void OnToggleRefreshBackgroundColorClicked(object sender, System.EventArgs e) + private void OnToggleRefreshBackgroundColorClicked(object? sender, System.EventArgs e) { if (refreshView.Background == SolidColorBrush.Yellow) { @@ -34,10 +34,10 @@ private void OnToggleRefreshBackgroundColorClicked(object sender, System.EventAr } } - private void OnTriggerRefreshClicked(object sender, System.EventArgs e) => + private void OnTriggerRefreshClicked(object? sender, System.EventArgs e) => refreshView.IsRefreshing = !refreshView.IsRefreshing; - private void OnToggleEnabledClicked(object sender, System.EventArgs e) => + private void OnToggleEnabledClicked(object? sender, System.EventArgs e) => refreshView.IsEnabled = !refreshView.IsEnabled; } } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SearchBarPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SearchBarPage.xaml.cs index 6c0284664281..6cd674ecda8d 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SearchBarPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SearchBarPage.xaml.cs @@ -10,21 +10,21 @@ public SearchBarPage() InitializeComponent(); } - void OnSearchBarFocused(object sender, FocusEventArgs e) + void OnSearchBarFocused(object? sender, FocusEventArgs e) { - var text = ((SearchBar)sender).Text; + var text = ((SearchBar)sender!).Text; DisplayAlertAsync("Focused", text, "Ok"); } - void OnSearchBarUnfocused(object sender, FocusEventArgs e) + void OnSearchBarUnfocused(object? sender, FocusEventArgs e) { - var text = ((SearchBar)sender).Text; + var text = ((SearchBar)sender!).Text; DisplayAlertAsync("Unfocused", text, "Ok"); } - void OnSearchBarTextChanged(object sender, TextChangedEventArgs args) + void OnSearchBarTextChanged(object? sender, TextChangedEventArgs args) { - var text = ((SearchBar)sender).Text; + var text = ((SearchBar)sender!).Text; Debug.WriteLine($"SearchBar Text changed: {text}"); } } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/ShapesGalleries/ClipCornerRadiusGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/ShapesGalleries/ClipCornerRadiusGallery.xaml.cs index 94546ee8eb08..a9e34dc70cde 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/ShapesGalleries/ClipCornerRadiusGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/ShapesGalleries/ClipCornerRadiusGallery.xaml.cs @@ -10,7 +10,7 @@ public ClipCornerRadiusGallery() InitializeComponent(); } - void OnCornerChanged(object sender, ValueChangedEventArgs e) + void OnCornerChanged(object? sender, ValueChangedEventArgs e) { RoundRectangleGeometry.CornerRadius = new CornerRadius( TopLeftCorner.Value, diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/ShapesGalleries/UpdatePathDataGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/ShapesGalleries/UpdatePathDataGallery.xaml.cs index d08c66381fdc..fbba8d3cd2ee 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/ShapesGalleries/UpdatePathDataGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/ShapesGalleries/UpdatePathDataGallery.xaml.cs @@ -16,7 +16,7 @@ public UpdatePathDataGallery() _pathFigureCollectionConverter = new PathFigureCollectionConverter(); } - void OnUpdatePathDataButtonClicked(object sender, EventArgs args) + void OnUpdatePathDataButtonClicked(object? sender, EventArgs args) { _counter += 10; string pathData = $"M 10,100 C 10,{300 + _counter} {300 + _counter},-200 {300 + _counter},100"; diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/ShapesPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/ShapesPage.xaml.cs index 8eb6ba6abc43..9b162ee3c535 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/ShapesPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/ShapesPage.xaml.cs @@ -9,7 +9,7 @@ public ShapesPage() InitializeComponent(); } - void OnMoreSamplesClicked(object sender, EventArgs args) + void OnMoreSamplesClicked(object? sender, EventArgs args) { Navigation.PushAsync(new Pages.ShapesGalleries.ShapesGallery()); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SliderPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SliderPage.xaml.cs index 92d2f029a265..857f48624614 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SliderPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SliderPage.xaml.cs @@ -14,12 +14,12 @@ public SliderPage() UpdateInfo(); } - void OnValueChanged(object sender, ValueChangedEventArgs args) + void OnValueChanged(object? sender, ValueChangedEventArgs args) { Debug.WriteLine($"Slider Value: {args.NewValue}"); } - private void ToggleImageSource(object sender, System.EventArgs e) + private void ToggleImageSource(object? sender, System.EventArgs e) { if (_imageSource is null) { @@ -33,18 +33,18 @@ private void ToggleImageSource(object sender, System.EventArgs e) } } - void OnDynamicValueChanged(object sender, ValueChangedEventArgs args) + void OnDynamicValueChanged(object? sender, ValueChangedEventArgs args) { UpdateInfo(); } - void OnUpdateMinimumButtonClicked(object sender, System.EventArgs e) + void OnUpdateMinimumButtonClicked(object? sender, System.EventArgs e) { DynamicSlider.Minimum = 4; UpdateInfo(); } - void OnUpdateMaximumButtonClicked(object sender, System.EventArgs e) + void OnUpdateMaximumButtonClicked(object? sender, System.EventArgs e) { DynamicSlider.Maximum = 8; UpdateInfo(); diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/StepperPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/StepperPage.xaml.cs index 45c591425731..ae95d2e7befe 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/StepperPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/StepperPage.xaml.cs @@ -10,12 +10,12 @@ public StepperPage() InitializeComponent(); } - void OnValueChanged(object sender, ValueChangedEventArgs args) + void OnValueChanged(object? sender, ValueChangedEventArgs args) { Debug.WriteLine($"Stepper Value: {args.NewValue}"); } - void OnEnableButtonClicked(object sender, System.EventArgs e) + void OnEnableButtonClicked(object? sender, System.EventArgs e) { if (EnableStepper.IsEnabled) { diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/BasicSwipeGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/BasicSwipeGallery.xaml.cs index c4fb7f58feff..fb512bb45072 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/BasicSwipeGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/BasicSwipeGallery.xaml.cs @@ -13,7 +13,7 @@ public BasicSwipeGallery() InitializeComponent(); } - async void OnInvoked(object sender, EventArgs e) + async void OnInvoked(object? sender, EventArgs e) { await DisplayAlertAsync("SwipeView", "Delete Invoked", "OK"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/CustomSizeSwipeViewGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/CustomSizeSwipeViewGallery.xaml.cs index 31d2a0e905b4..e71923cfb490 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/CustomSizeSwipeViewGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/CustomSizeSwipeViewGallery.xaml.cs @@ -11,17 +11,17 @@ public CustomSizeSwipeViewGallery() InitializeComponent(); } - void OnContentClicked(object sender, EventArgs args) + void OnContentClicked(object? sender, EventArgs args) { DisplayAlertAsync("OnClicked", "The Content Button has been clicked.", "Ok"); } - void OnRightItemsClicked(object sender, EventArgs args) + void OnRightItemsClicked(object? sender, EventArgs args) { DisplayAlertAsync("OnClicked", "The RightItems Button has been clicked.", "Ok"); } - void OnButtonClicked(object sender, EventArgs e) + void OnButtonClicked(object? sender, EventArgs e) { DisplayAlertAsync("Custom SwipeItem", "Button Clicked!", "Ok"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/HorizontalSwipeThresholdGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/HorizontalSwipeThresholdGallery.xaml.cs index 22a3887e5d86..e1fbda5a63d3 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/HorizontalSwipeThresholdGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/HorizontalSwipeThresholdGallery.xaml.cs @@ -12,12 +12,12 @@ public HorizontalSwipeThresholdGallery() InitializeComponent(); } - void OnThresholdRevealSliderChanged(object sender, ValueChangedEventArgs args) + void OnThresholdRevealSliderChanged(object? sender, ValueChangedEventArgs args) { RevealThresholdSwipeView.Close(); } - void OnThresholdExecuteSliderChanged(object sender, ValueChangedEventArgs args) + void OnThresholdExecuteSliderChanged(object? sender, ValueChangedEventArgs args) { ExecuteThresholdSwipeView.Close(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemPositionGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemPositionGallery.xaml.cs index e6dd90dba5d1..94105e63c02f 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemPositionGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemPositionGallery.xaml.cs @@ -13,7 +13,7 @@ public SwipeItemPositionGallery() ModePicker.SelectedIndex = 0; } - void OnModePickerSelectedIndexChanged(object sender, EventArgs e) + void OnModePickerSelectedIndexChanged(object? sender, EventArgs e) { LeftSwipeItems.Mode = TopSwipeItems.Mode = RightSwipeItems.Mode = BottomSwipeItems.Mode = ModePicker.SelectedIndex == 0 ? SwipeMode.Reveal : SwipeMode.Execute; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemSizeGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemSizeGallery.xaml.cs index 4ca29f2eb3d2..36fa14e7c80b 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemSizeGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemSizeGallery.xaml.cs @@ -9,7 +9,7 @@ public SwipeItemSizeGallery() InitializeComponent(); } - void OnSwipeItemInvoked(object sender, EventArgs e) + void OnSwipeItemInvoked(object? sender, EventArgs e) { DisplayAlertAsync("SwipeItemSizeGallery", "Delete SwipeItem Invoked", "Ok"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemViewPositionGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemViewPositionGallery.xaml.cs index 6ce17bd7c86e..8c69ceb80557 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemViewPositionGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemViewPositionGallery.xaml.cs @@ -12,7 +12,7 @@ public SwipeItemViewPositionGallery() ModePicker.SelectedIndex = 0; } - void OnModePickerSelectedIndexChanged(object sender, EventArgs e) + void OnModePickerSelectedIndexChanged(object? sender, EventArgs e) { LeftSwipeItems.Mode = TopSwipeItems.Mode = RightSwipeItems.Mode = BottomSwipeItems.Mode = ModePicker.SelectedIndex == 0 ? SwipeMode.Reveal : SwipeMode.Execute; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeListViewGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeListViewGallery.xaml.cs index 8b1583fb8ba4..e60f4370fcde 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeListViewGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeListViewGallery.xaml.cs @@ -18,7 +18,7 @@ public SwipeListViewGallery() WeakReferenceMessenger.Default.Register(this, "delete", (_, sender) => { DisplayAlertAsync("SwipeView", "Delete", "Ok"); }); } - async void OnSwipeListViewItemTapped(object sender, ItemTappedEventArgs args) + async void OnSwipeListViewItemTapped(object? sender, ItemTappedEventArgs args) { await DisplayAlertAsync("OnSwipeListViewItemTapped", "You have tapped a ListView item", "Ok"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeViewNoLayoutGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeViewNoLayoutGallery.xaml.cs index 3055453cf996..cf159f91adf1 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeViewNoLayoutGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeViewNoLayoutGallery.xaml.cs @@ -13,7 +13,7 @@ public SwipeViewNoLayoutGallery() InitializeComponent(); } - async void OnInvoked(object sender, EventArgs e) + async void OnInvoked(object? sender, EventArgs e) { await DisplayAlertAsync("SwipeView", "SwipeItem Invoked", "OK"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/VerticalSwipeThresholdGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/VerticalSwipeThresholdGallery.xaml.cs index 15380d24549a..895fda0a420d 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/VerticalSwipeThresholdGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/VerticalSwipeThresholdGallery.xaml.cs @@ -11,12 +11,12 @@ public VerticalSwipeThresholdGallery() InitializeComponent(); } - void OnThresholdRevealSliderChanged(object sender, ValueChangedEventArgs args) + void OnThresholdRevealSliderChanged(object? sender, ValueChangedEventArgs args) { RevealThresholdSwipeView.Close(); } - void OnThresholdExecuteSliderChanged(object sender, ValueChangedEventArgs args) + void OnThresholdExecuteSliderChanged(object? sender, ValueChangedEventArgs args) { ExecuteThresholdSwipeView.Close(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/TimePickerPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/TimePickerPage.xaml.cs index f0248fb820f2..8fde39f1e6d5 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/TimePickerPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/TimePickerPage.xaml.cs @@ -29,12 +29,12 @@ protected override void OnDisappearing() IsOpenTimePicker.Closed -= IsOpenTimePickerClosed; } - void OnUpdateBackgroundButtonClicked(object sender, EventArgs e) + void OnUpdateBackgroundButtonClicked(object? sender, EventArgs e) { UpdateTimePickerBackground(); } - void OnClearBackgroundButtonClicked(object sender, EventArgs e) + void OnClearBackgroundButtonClicked(object? sender, EventArgs e) { BackgroundTimePicker.Background = null; } @@ -56,22 +56,22 @@ void UpdateTimePickerBackground() }; } - void SetTimePickerToNull(object sender, EventArgs e) + void SetTimePickerToNull(object? sender, EventArgs e) { NullTimePicker.Time = null; } - void SetTimePickerToNow(object sender, EventArgs e) + void SetTimePickerToNow(object? sender, EventArgs e) { NullTimePicker.Time = DateTime.Now.TimeOfDay; } - void OnOpenClicked(object sender, EventArgs e) + void OnOpenClicked(object? sender, EventArgs e) { IsOpenTimePicker.IsOpen = true; } - void OnCloseClicked(object sender, EventArgs e) + void OnCloseClicked(object? sender, EventArgs e) { IsOpenTimePicker.IsOpen = false; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/TitleBarPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/TitleBarPage.xaml.cs index 7aa4c69f517c..4a8e2a036320 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/TitleBarPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/TitleBarPage.xaml.cs @@ -39,7 +39,7 @@ protected override void OnAppearing() Application.Current!.Windows[0].TitleBar = _customTitleBar; } - private void SetIconCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) + private void SetIconCheckBox_CheckedChanged(object? sender, CheckedChangedEventArgs e) { if (e.Value) { @@ -51,7 +51,7 @@ private void SetIconCheckBox_CheckedChanged(object sender, CheckedChangedEventAr } } - private void ColorButton_Clicked(object sender, EventArgs e) + private void ColorButton_Clicked(object? sender, EventArgs e) { if (Microsoft.Maui.Graphics.Color.TryParse(ColorTextBox.Text, out var color)) { @@ -59,7 +59,7 @@ private void ColorButton_Clicked(object sender, EventArgs e) } } - private void ForegroundColorButton_Clicked(object sender, EventArgs e) + private void ForegroundColorButton_Clicked(object? sender, EventArgs e) { if (Microsoft.Maui.Graphics.Color.TryParse(ForegroundColorTextBox.Text, out var color)) { @@ -67,7 +67,7 @@ private void ForegroundColorButton_Clicked(object sender, EventArgs e) } } - private void LeadingCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) + private void LeadingCheckBox_CheckedChanged(object? sender, CheckedChangedEventArgs e) { if (e.Value) { @@ -82,7 +82,7 @@ private void LeadingCheckBox_CheckedChanged(object sender, CheckedChangedEventAr } } - private void ContentCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) + private void ContentCheckBox_CheckedChanged(object? sender, CheckedChangedEventArgs e) { if (e.Value) { @@ -101,12 +101,12 @@ private void ContentCheckBox_CheckedChanged(object sender, CheckedChangedEventAr } - async void PushNewTitleBarPage_Clicked(object sender, EventArgs e) + async void PushNewTitleBarPage_Clicked(object? sender, EventArgs e) { await Navigation.PushAsync(new TitleBarPage()); } - void ToggleTitleBarOnWindow_Clicked(object sender, EventArgs e) + void ToggleTitleBarOnWindow_Clicked(object? sender, EventArgs e) { if (Window.TitleBar is not null) Window.TitleBar = null; @@ -114,7 +114,7 @@ void ToggleTitleBarOnWindow_Clicked(object sender, EventArgs e) Window.TitleBar = _customTitleBar; } - void ToggleHasNavigationBar_Clicked(object sender, EventArgs eventArgs) + void ToggleHasNavigationBar_Clicked(object? sender, EventArgs eventArgs) { if (Shell.GetNavBarIsVisible(this)) { @@ -128,7 +128,7 @@ void ToggleHasNavigationBar_Clicked(object sender, EventArgs eventArgs) } } - private void TrailingCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) + private void TrailingCheckBox_CheckedChanged(object? sender, CheckedChangedEventArgs e) { if (e.Value) { @@ -155,7 +155,7 @@ private void TrailingCheckBox_CheckedChanged(object sender, CheckedChangedEventA } } - private void TallModeCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) + private void TallModeCheckBox_CheckedChanged(object? sender, CheckedChangedEventArgs e) { if (e.Value) { diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/WebViewGalleries/WebViewGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/WebViewGalleries/WebViewGallery.xaml.cs index 1877a4196172..8144fe2296fd 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/WebViewGalleries/WebViewGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/WebViewGalleries/WebViewGallery.xaml.cs @@ -30,7 +30,7 @@ protected override void OnDisappearing() MauiWebView.ProcessTerminated -= OnMauiWebViewProcessTerminated; } - void OnUpdateHtmlSourceClicked(object sender, EventArgs args) + void OnUpdateHtmlSourceClicked(object? sender, EventArgs args) { Random rnd = new(); HtmlWebViewSource htmlWebViewSource = new(); @@ -38,7 +38,7 @@ void OnUpdateHtmlSourceClicked(object sender, EventArgs args) htmlWebViewSource.Html += $"

Updated Content {rnd.Next()}!


"; } - void OnGoBackClicked(object sender, EventArgs args) + void OnGoBackClicked(object? sender, EventArgs args) { Debug.WriteLine($"CanGoBack {MauiWebView.CanGoBack}"); @@ -48,7 +48,7 @@ void OnGoBackClicked(object sender, EventArgs args) } } - void OnGoForwardClicked(object sender, EventArgs args) + void OnGoForwardClicked(object? sender, EventArgs args) { Debug.WriteLine($"CanGoForward {MauiWebView.CanGoForward}"); @@ -58,12 +58,12 @@ void OnGoForwardClicked(object sender, EventArgs args) } } - void OnReloadClicked(object sender, EventArgs args) + void OnReloadClicked(object? sender, EventArgs args) { MauiWebView.Reload(); } - void OnEvalClicked(object sender, EventArgs args) + void OnEvalClicked(object? sender, EventArgs args) { MauiWebView.Eval("alert('text')"); } @@ -91,7 +91,7 @@ void OnMauiWebViewProcessTerminated(object? sender, WebViewProcessTerminatedEven #endif } - async void OnEvalAsyncClicked(object sender, EventArgs args) + async void OnEvalAsyncClicked(object? sender, EventArgs args) { MauiWebView.Eval("alert('text')"); @@ -101,12 +101,12 @@ async void OnEvalAsyncClicked(object sender, EventArgs args) EvalResultLabel.Text = result; } - async void OnLoadHtmlFileClicked(object sender, EventArgs e) + async void OnLoadHtmlFileClicked(object? sender, EventArgs e) { await LoadMauiAsset(); } - async void OnSetUserAgentClicked(object sender, EventArgs e) + async void OnSetUserAgentClicked(object? sender, EventArgs e) { input.Text = "useragent.html"; await LoadMauiAsset(); @@ -121,17 +121,17 @@ async Task LoadMauiAsset() FileWebView.Source = new HtmlWebViewSource { Html = html }; } - void OnAllowMixedContentClicked(object sender, EventArgs e) + void OnAllowMixedContentClicked(object? sender, EventArgs e) { MauiWebView.On().SetMixedContentMode(MixedContentHandling.AlwaysAllow); } - void OnEnableZoomControlsClicked(object sender, EventArgs e) + void OnEnableZoomControlsClicked(object? sender, EventArgs e) { MauiWebView.On().EnableZoomControls(true); } - void OnJavaScriptEnabledClicked(object sender, EventArgs e) + void OnJavaScriptEnabledClicked(object? sender, EventArgs e) { bool isJavaScriptEnabled = MauiWebView.On().IsJavaScriptEnabled(); @@ -147,12 +147,12 @@ void OnJavaScriptEnabledClicked(object sender, EventArgs e) } } - void OnLoadHtml5VideoClicked(object sender, EventArgs e) + void OnLoadHtml5VideoClicked(object? sender, EventArgs e) { MauiWebView.Source = new UrlWebViewSource { Url = "video.html" }; } - void OnLoadHttpBinClicked(object sender, EventArgs e) + void OnLoadHttpBinClicked(object? sender, EventArgs e) { // on httpbin.org find the section where you can load the cookies for the website. // The cookie that is set below should show up for this to succeed. diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/AlertsPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/AlertsPage.xaml.cs index 9d7a6b0ca79c..9c4ba10aa8b9 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/AlertsPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/AlertsPage.xaml.cs @@ -17,30 +17,30 @@ protected override async void OnAppearing() await DisplayAlertAsync("Alert", "Welcome to the Alerts Page", "Hello!"); } - async void OnAlertSimpleClicked(object sender, EventArgs e) + async void OnAlertSimpleClicked(object? sender, EventArgs e) { await DisplayAlertAsync("Alert", "You have been alerted", "OK"); } - async void OnAlertYesNoClicked(object sender, EventArgs e) + async void OnAlertYesNoClicked(object? sender, EventArgs e) { var answer = await DisplayAlertAsync("Question?", "Would you like to play a game", "Yes", "No"); Debug.WriteLine("Answer: " + answer); } - async void OnActionSheetSimpleClicked(object sender, EventArgs e) + async void OnActionSheetSimpleClicked(object? sender, EventArgs e) { var action = await DisplayActionSheetAsync("ActionSheet: Send to?", "Cancel", null, "Email", "Twitter", "Facebook"); Debug.WriteLine("Action: " + action); } - async void OnActionSheetCancelDeleteClicked(object sender, EventArgs e) + async void OnActionSheetCancelDeleteClicked(object? sender, EventArgs e) { var action = await DisplayActionSheetAsync("ActionSheet: SavePhoto?", "Cancel", "Delete", "Photo Roll", "Email"); Debug.WriteLine("Action: " + action); } - async void OnQuestion1ButtonClicked(object sender, EventArgs e) + async void OnQuestion1ButtonClicked(object? sender, EventArgs e) { string result = await DisplayPromptAsync("Question 1", "What's your name?", initialValue: string.Empty); @@ -50,7 +50,7 @@ async void OnQuestion1ButtonClicked(object sender, EventArgs e) } } - async void OnQuestion2ButtonClicked(object sender, EventArgs e) + async void OnQuestion2ButtonClicked(object? sender, EventArgs e) { string result = await DisplayPromptAsync("Question 2", "What's 5 + 5?", initialValue: "10", maxLength: 2, keyboard: Keyboard.Numeric); diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/ApplicationControlPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/ApplicationControlPage.xaml.cs index 26f742b92404..35ecde2c7357 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/ApplicationControlPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/ApplicationControlPage.xaml.cs @@ -10,7 +10,7 @@ public ApplicationControlPage() InitializeComponent(); } - void OnTerminateClicked(object sender, EventArgs e) + void OnTerminateClicked(object? sender, EventArgs e) { Application.Current!.Quit(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/BorderGalleries/BorderClipPlayground.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/BorderGalleries/BorderClipPlayground.xaml.cs index 5a52a31e653e..6a70758f7cda 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/BorderGalleries/BorderClipPlayground.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/BorderGalleries/BorderClipPlayground.xaml.cs @@ -18,22 +18,22 @@ public BorderClipPlayground() UpdateCornerRadius(); } - void OnBorderShapeSelectedIndexChanged(object sender, EventArgs e) + void OnBorderShapeSelectedIndexChanged(object? sender, EventArgs e) { UpdateBorderShape(); } - void OnBorderChanged(object sender, TextChangedEventArgs e) + void OnBorderChanged(object? sender, TextChangedEventArgs e) { UpdateBorder(); } - void OnBorderWidthChanged(object sender, ValueChangedEventArgs e) + void OnBorderWidthChanged(object? sender, ValueChangedEventArgs e) { UpdateBorder(); } - void OnCornerRadiusChanged(object sender, ValueChangedEventArgs e) + void OnCornerRadiusChanged(object? sender, ValueChangedEventArgs e) { UpdateCornerRadius(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/BorderGalleries/BorderPlayground.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/BorderGalleries/BorderPlayground.xaml.cs index e503372881ed..133309df6fe6 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/BorderGalleries/BorderPlayground.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/BorderGalleries/BorderPlayground.xaml.cs @@ -24,58 +24,58 @@ public BorderPlayground() UpdateCornerRadius(); } - void OnBorderContentSelectedIndexChanged(object sender, EventArgs e) + void OnBorderContentSelectedIndexChanged(object? sender, EventArgs e) { UpdateBorderContent(); UpdateBorder(); } - void OnBorderShapeSelectedIndexChanged(object sender, EventArgs e) + void OnBorderShapeSelectedIndexChanged(object? sender, EventArgs e) { UpdateBorderShape(); } - void OnBorderLineJoinSelectedIndexChanged(object sender, EventArgs e) + void OnBorderLineJoinSelectedIndexChanged(object? sender, EventArgs e) { UpdateBorderShape(); } - void OnBorderLineCapSelectedIndexChanged(object sender, EventArgs e) + void OnBorderLineCapSelectedIndexChanged(object? sender, EventArgs e) { UpdateBorderShape(); } - void OnBackgroundChanged(object sender, TextChangedEventArgs e) + void OnBackgroundChanged(object? sender, TextChangedEventArgs e) { UpdateBackground(); } - void OnBorderChanged(object sender, TextChangedEventArgs e) + void OnBorderChanged(object? sender, TextChangedEventArgs e) { UpdateBorder(); } - void OnBorderWidthChanged(object sender, ValueChangedEventArgs e) + void OnBorderWidthChanged(object? sender, ValueChangedEventArgs e) { UpdateBorder(); } - void OnBorderDashArrayChanged(object sender, TextChangedEventArgs e) + void OnBorderDashArrayChanged(object? sender, TextChangedEventArgs e) { UpdateBorder(); } - void OnBorderDashOffsetChanged(object sender, ValueChangedEventArgs e) + void OnBorderDashOffsetChanged(object? sender, ValueChangedEventArgs e) { UpdateBorder(); } - void OnCornerRadiusChanged(object sender, ValueChangedEventArgs e) + void OnCornerRadiusChanged(object? sender, ValueChangedEventArgs e) { UpdateCornerRadius(); } - void OnContentBackgroundCheckBoxChanged(object sender, CheckedChangedEventArgs e) + void OnContentBackgroundCheckBoxChanged(object? sender, CheckedChangedEventArgs e) { UpdateContentBackground(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/BorderGalleries/BorderStyles.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/BorderGalleries/BorderStyles.xaml.cs index c79b73cbb9c2..2ef50f6661f2 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/BorderGalleries/BorderStyles.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/BorderGalleries/BorderStyles.xaml.cs @@ -14,9 +14,9 @@ public BorderStyles() ChangeCornerRadius(0); } - void OnIncreaseCornerRadius(object sender, EventArgs e) => ChangeCornerRadius(10); + void OnIncreaseCornerRadius(object? sender, EventArgs e) => ChangeCornerRadius(10); - void OnDecreaseCornerRadius(object sender, EventArgs e) => ChangeCornerRadius(-10); + void OnDecreaseCornerRadius(object? sender, EventArgs e) => ChangeCornerRadius(-10); void ChangeCornerRadius(double delta) { diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/BrushesPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/BrushesPage.xaml.cs index 6462203963a8..e367f723fc8c 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/BrushesPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/BrushesPage.xaml.cs @@ -20,7 +20,7 @@ public BrushesPage() public Color Start { get; set; } = Colors.Red; public Color Stop { get; set; } = Colors.Orange; - void OnUpdateSolidColorClicked(object sender, EventArgs e) + void OnUpdateSolidColorClicked(object? sender, EventArgs e) { var color = GetRandomColor(); @@ -31,12 +31,12 @@ void OnUpdateSolidColorClicked(object sender, EventArgs e) solidBrushPolygon.Color = color; } - void OnRemovePolygonSolidColorClicked(object sender, EventArgs e) + void OnRemovePolygonSolidColorClicked(object? sender, EventArgs e) { BrushChangesLayout.Children.Remove(SolidBrushPolygon); } - void OnUpdateLinearColorsClicked(object sender, EventArgs e) + void OnUpdateLinearColorsClicked(object? sender, EventArgs e) { var gradientStop = GetRandomGradientStop(); var color = GetRandomColor(); @@ -54,12 +54,12 @@ void UpdateGradientStopColor(GradientBrush? gradientBrush, int index, Color colo randomStop.Color = color; } - void OnRemovePolygonLinearColorsClicked(object sender, EventArgs e) + void OnRemovePolygonLinearColorsClicked(object? sender, EventArgs e) { BrushChangesLayout.Children.Remove(LinearBrushPolygon); } - void OnUpdateRadialColorsClicked(object sender, EventArgs e) + void OnUpdateRadialColorsClicked(object? sender, EventArgs e) { var gradientStop = GetRandomGradientStop(); var color = GetRandomColor(); @@ -68,7 +68,7 @@ void OnUpdateRadialColorsClicked(object sender, EventArgs e) UpdateGradientStopColor(RadialBrushPolygon.Fill as RadialGradientBrush, gradientStop, color); } - void OnRemovePolygonRadialColorsClicked(object sender, EventArgs e) + void OnRemovePolygonRadialColorsClicked(object? sender, EventArgs e) { BrushChangesLayout.Children.Remove(RadialBrushPolygon); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/ContextFlyoutPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/ContextFlyoutPage.xaml.cs index 2f10ee76150d..e6f0f08e7e68 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/ContextFlyoutPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/ContextFlyoutPage.xaml.cs @@ -92,23 +92,23 @@ public bool IsDynamicCommandEnabled int count; private bool _isDynamicCommandEnabled; - void OnIncrementByOneClicked(object sender, EventArgs e) + void OnIncrementByOneClicked(object? sender, EventArgs e) { count++; OnPropertyChanged(nameof(CounterValue)); } - void OnIncrementMenuItemClicked(object sender, EventArgs e) + void OnIncrementMenuItemClicked(object? sender, EventArgs e) { - var menuItem = (MenuFlyoutItem)sender; - var incrementAmount = int.Parse((string)menuItem.CommandParameter); + var menuItem = (MenuFlyoutItem)sender!; + var incrementAmount = int.Parse((string)menuItem.CommandParameter!); count += incrementAmount; OnPropertyChanged(nameof(CounterValue)); } public string CounterValue => count.ToString("N0"); - async void OnEntryShowTextClicked(object sender, EventArgs e) + async void OnEntryShowTextClicked(object? sender, EventArgs e) { await DisplayAlertAsync( title: "Entry", @@ -116,17 +116,17 @@ await DisplayAlertAsync( cancel: "OK"); } - void OnEntryAddTextClicked(object sender, EventArgs e) + void OnEntryAddTextClicked(object? sender, EventArgs e) { EntryWithContextFlyout.Text += " more text!"; } - void OnEntryClearTextClicked(object sender, EventArgs e) + void OnEntryClearTextClicked(object? sender, EventArgs e) { EntryWithContextFlyout.Text = ""; } - async void OnImageContextClicked(object sender, EventArgs e) + async void OnImageContextClicked(object? sender, EventArgs e) { await DisplayAlertAsync( title: "Image", @@ -134,33 +134,33 @@ await DisplayAlertAsync( cancel: "OK"); } - void OnWebViewGoToSiteClicked(object sender, EventArgs e) + void OnWebViewGoToSiteClicked(object? sender, EventArgs e) { ContextMenuWebView.Source = new UrlWebViewSource() { Url = "https://github.com/dotnet/maui", }; } - async void OnWebViewInvokeJSClicked(object sender, EventArgs e) + async void OnWebViewInvokeJSClicked(object? sender, EventArgs e) { await ContextMenuWebView.EvaluateJavaScriptAsync(@"alert('help, i\'m being invoked!');"); } int newMenuItemCount = 0; - void OnAddMenuClicked(object sender, EventArgs e) + void OnAddMenuClicked(object? sender, EventArgs e) { - var contextFlyout = (((MenuFlyoutItem)sender).Parent as MenuFlyout)!; + var contextFlyout = (((MenuFlyoutItem)sender!).Parent as MenuFlyout)!; AddNewMenu(contextFlyout, "top-level"); } - void OnAddSubMenuClicked(object sender, EventArgs e) + void OnAddSubMenuClicked(object? sender, EventArgs e) { - var subMenu = (MenuFlyoutSubItem)((MenuFlyoutItem)sender).Parent; + var subMenu = (MenuFlyoutSubItem)((MenuFlyoutItem)sender!).Parent!; AddNewMenu(subMenu, "sub-menu", subMenu.Count - 2, subMenu.Count % 2 == 0); CheckSubMenu(); } - void OnRemoveSubMenuClicked(object sender, EventArgs e) + void OnRemoveSubMenuClicked(object? sender, EventArgs e) { - var subMenu = (MenuFlyoutSubItem)((MenuFlyoutItem)sender).Parent; + var subMenu = (MenuFlyoutSubItem)((MenuFlyoutItem)sender!).Parent!; subMenu.RemoveAt(subMenu.Count - 3); CheckSubMenu(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/DispatcherPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/DispatcherPage.xaml.cs index 378f0f360db1..9e78558df5a5 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/DispatcherPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/DispatcherPage.xaml.cs @@ -12,7 +12,7 @@ public DispatcherPage() InitializeComponent(); } - async void OnFailAccessClicked(object sender, EventArgs e) + async void OnFailAccessClicked(object? sender, EventArgs e) { try { @@ -27,7 +27,7 @@ await Task.Run(() => } } - async void OnAccessClicked(object sender, EventArgs e) + async void OnAccessClicked(object? sender, EventArgs e) { try { @@ -45,7 +45,7 @@ await happyLabel.Dispatcher.DispatchAsync(() => } } - void OnLaterClicked(object sender, EventArgs e) + void OnLaterClicked(object? sender, EventArgs e) { var now = DateTime.Now; laterLabel.Dispatcher.DispatchDelayed(TimeSpan.FromSeconds(3), () => @@ -58,7 +58,7 @@ void OnLaterClicked(object sender, EventArgs e) IDispatcherTimer? _timer; - void OnTimerClicked(object sender, EventArgs e) + void OnTimerClicked(object? sender, EventArgs e) { if (_timer != null) { @@ -90,7 +90,7 @@ void OnTimerClicked(object sender, EventArgs e) bool keepRunning; [Obsolete] - void OnObsoleteClicked(object sender, EventArgs e) + void OnObsoleteClicked(object? sender, EventArgs e) { if (keepRunning) { diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/DragAndDropBetweenLayouts.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/DragAndDropBetweenLayouts.xaml.cs index 17b409feeb2e..48ec665694ba 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/DragAndDropBetweenLayouts.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/DragAndDropBetweenLayouts.xaml.cs @@ -34,9 +34,9 @@ protected override void OnAppearing() BindingContext = this; } - private void OnDragStarting(object sender, DragStartingEventArgs e) + private void OnDragStarting(object? sender, DragStartingEventArgs e) { - var boxView = (View)((Element)sender)!.Parent; + var boxView = (View)((Element)sender!).Parent!; DragStartingTitle.IsVisible = true; DragStartingPositionLabel.Text = $"- Self X:{(int)e.GetPosition(boxView)!.Value.X}, Y:{(int)e.GetPosition(boxView)!.Value.Y}"; DragStartingScreenPositionLabel.Text = $"- Screen X:{(int)e.GetPosition(null)!.Value.X}, Y:{(int)e.GetPosition(null)!.Value.Y}"; @@ -52,9 +52,9 @@ private void OnDragStarting(object sender, DragStartingEventArgs e) SLAllColors.Background = SolidColorBrush.LightBlue; } - private void OnDropCompleted(object sender, DropCompletedEventArgs e) + private void OnDropCompleted(object? sender, DropCompletedEventArgs e) { - var sl = ((Element)sender).Parent as StackLayout; + var sl = ((Element)sender!).Parent as StackLayout; if (sl == SLAllColors) SLRainbow.Background = SolidColorBrush.White; @@ -63,9 +63,9 @@ private void OnDropCompleted(object sender, DropCompletedEventArgs e) } - private void OnDragOver(object sender, DragEventArgs e) + private void OnDragOver(object? sender, DragEventArgs e) { - var sl = (StackLayout)((Element)sender).Parent; + var sl = (StackLayout)((Element)sender!).Parent!; if (!e.Data.Properties.ContainsKey("Source")) return; @@ -84,9 +84,9 @@ private void OnDragOver(object sender, DragEventArgs e) sl.Background = SolidColorBrush.LightPink; } - private void OnDragLeave(object sender, DragEventArgs e) + private void OnDragLeave(object? sender, DragEventArgs e) { - var sl = (StackLayout)((Element)sender).Parent; + var sl = (StackLayout)((Element)sender!).Parent!; if (!e.Data.Properties.ContainsKey("Source")) return; @@ -105,9 +105,9 @@ private void OnDragLeave(object sender, DragEventArgs e) sl.Background = SolidColorBrush.LightBlue; } - private void OnDrop(object sender, DropEventArgs e) + private void OnDrop(object? sender, DropEventArgs e) { - var sl = ((Element)sender).Parent as StackLayout; + var sl = ((Element)sender!).Parent as StackLayout; if (!e.Data.Properties.ContainsKey("Source")) return; diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/FlyoutPageGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/FlyoutPageGallery.xaml.cs index 34384c66626a..08306a1a6806 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/FlyoutPageGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/FlyoutPageGallery.xaml.cs @@ -15,7 +15,7 @@ public FlyoutPageGallery() flyoutBehaviorPicker.SelectedIndexChanged += OnFlyoutBehaviorPickerSelectedIndexChanged; } - void OnGestureEnabledCheckChanged(object sender, CheckedChangedEventArgs e) + void OnGestureEnabledCheckChanged(object? sender, CheckedChangedEventArgs e) { if (FlyoutPage == null) return; @@ -62,14 +62,14 @@ void OnFlyoutBehaviorPickerSelectedIndexChanged(object? sender, EventArgs e) FlyoutPage.FlyoutLayoutBehavior = (FlyoutLayoutBehavior)behavior; } - void ShowFlyout(object sender, EventArgs e) + void ShowFlyout(object? sender, EventArgs e) { if (FlyoutPage == null) return; FlyoutPage.IsPresented = true; } - void CloseFlyout(object sender, EventArgs e) + void CloseFlyout(object? sender, EventArgs e) { if (FlyoutPage == null) return; diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/FocusPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/FocusPage.xaml.cs index 311f4176dfd2..dfac001c38a5 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/FocusPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/FocusPage.xaml.cs @@ -9,17 +9,17 @@ public FocusPage() InitializeComponent(); } - void OnFocusClicked(object sender, EventArgs e) + void OnFocusClicked(object? sender, EventArgs e) { FocusEntry.Focus(); } - void OnUnfocusClicked(object sender, EventArgs e) + void OnUnfocusClicked(object? sender, EventArgs e) { FocusEntry.Unfocus(); } - void OnFocusEntryFocusChanged(object sender, Microsoft.Maui.Controls.FocusEventArgs e) + void OnFocusEntryFocusChanged(object? sender, Microsoft.Maui.Controls.FocusEventArgs e) { InfoLabel.Text += e.IsFocused ? "Focused" + Environment.NewLine : "Unfocused" + Environment.NewLine; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/InputTransparentPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/InputTransparentPage.xaml.cs index cdaa77cabade..e12202786192 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/InputTransparentPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/InputTransparentPage.xaml.cs @@ -11,13 +11,13 @@ public InputTransparentPage() InitializeComponent(); } - void ClickFail(object sender, EventArgs e) + void ClickFail(object? sender, EventArgs e) { Debug.WriteLine("Failure; You shouldn't have been able to interact with that."); DisplayAlertAsync("Failure", "You shouldn't have been able to interact with that.", "OK"); } - void ClickSuccess(object sender, EventArgs e) + void ClickSuccess(object? sender, EventArgs e) { Debug.WriteLine("Success; That should have worked, and it did!"); DisplayAlertAsync("Success", "That should have worked, and it did!", "OK"); diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/MenuBarPage.cs b/src/Controls/samples/Controls.Sample/Pages/Core/MenuBarPage.cs index 3d20e09be2e3..4f90dacd629b 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/MenuBarPage.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/MenuBarPage.cs @@ -27,7 +27,7 @@ public MenuBarPage() ); } - void ItemClicked(object sender, EventArgs e) + void ItemClicked(object? sender, EventArgs e) { if (sender is MenuFlyoutItem mfi) { @@ -35,7 +35,7 @@ void ItemClicked(object sender, EventArgs e) } } - void OnToggleMenuBarItem(object sender, EventArgs e) + void OnToggleMenuBarItem(object? sender, EventArgs e) { var barItem = MenuBarItems.FirstOrDefault(x => x.Text == "Added Menu"); diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/ModalPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/ModalPage.xaml.cs index 12979088ce14..638d8cdd335f 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/ModalPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/ModalPage.xaml.cs @@ -44,7 +44,7 @@ protected override void OnAppearing() PopModal.IsVisible = Navigation.ModalStack.Count > 0; } - async void PushNavigationModalClicked(object sender, EventArgs e) + async void PushNavigationModalClicked(object? sender, EventArgs e) { var modalPage = new ModalPage(); Page pushMe = new NavigationPage(modalPage) @@ -58,7 +58,7 @@ async void PushNavigationModalClicked(object sender, EventArgs e) } - async void PushModalClicked(object sender, EventArgs e) + async void PushModalClicked(object? sender, EventArgs e) { Page pushMe = new ModalPage() { @@ -69,7 +69,7 @@ async void PushModalClicked(object sender, EventArgs e) await Navigation.PushModalAsync(pushMe); } - async void PushClicked(object sender, EventArgs e) + async void PushClicked(object? sender, EventArgs e) { await Navigation.PushAsync(new ModalPage() { @@ -78,12 +78,12 @@ await Navigation.PushAsync(new ModalPage() }); } - async void PopModalClicked(object sender, EventArgs e) + async void PopModalClicked(object? sender, EventArgs e) { await Navigation.PopModalAsync(); } - async void PushFlyoutPageClicked(object sender, EventArgs e) + async void PushFlyoutPageClicked(object? sender, EventArgs e) { var modalPage = new ModalPage(); Page newMainPage = new NavigationPage(modalPage) diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/MultiWindowPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/MultiWindowPage.xaml.cs index 204278127995..eaa2fbfbe084 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/MultiWindowPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/MultiWindowPage.xaml.cs @@ -15,17 +15,17 @@ public MultiWindowPage() BindingContext = this; } - void OnNewWindowClicked(object sender, EventArgs e) + void OnNewWindowClicked(object? sender, EventArgs e) { Application.Current!.OpenWindow(new Window(new MultiWindowPage())); } - void OnCloseWindowClicked(object sender, EventArgs e) + void OnCloseWindowClicked(object? sender, EventArgs e) { Application.Current!.CloseWindow(Window); } - void ActivateWindowClicked(object sender, EventArgs e) + void ActivateWindowClicked(object? sender, EventArgs e) { IReadOnlyList windows = Application.Current!.Windows; @@ -44,24 +44,24 @@ void ActivateWindowClicked(object sender, EventArgs e) Application.Current!.ActivateWindow(windowToActivate); } - async void OnOpenDialogClicked(object sender, EventArgs e) + async void OnOpenDialogClicked(object? sender, EventArgs e) { await DisplayAlertAsync("Information", "The dialog should open by Window.", "Ok"); } - void OnSetMaxSize(object sender, EventArgs e) + void OnSetMaxSize(object? sender, EventArgs e) { Window.MaximumWidth = 800; Window.MaximumHeight = 600; } - void OnSetMinSize(object sender, EventArgs e) + void OnSetMinSize(object? sender, EventArgs e) { Window.MinimumWidth = 640; Window.MinimumHeight = 480; } - void OnSetFreeSize(object sender, EventArgs e) + void OnSetFreeSize(object? sender, EventArgs e) { Window.MaximumWidth = double.PositiveInfinity; Window.MaximumHeight = double.PositiveInfinity; @@ -70,13 +70,13 @@ void OnSetFreeSize(object sender, EventArgs e) Window.MinimumHeight = -1d; } - void OnSetCustomSize(object sender, EventArgs e) + void OnSetCustomSize(object? sender, EventArgs e) { Window.Width = 700; Window.Height = 500; } - void OnCenterWindow(object sender, EventArgs e) + void OnCenterWindow(object? sender, EventArgs e) { var disp = DeviceDisplay.MainDisplayInfo; @@ -84,12 +84,12 @@ void OnCenterWindow(object sender, EventArgs e) Window.Y = (disp.Height / disp.Density - Window.Height) / 2; } - void isMinimizableSwitch_Toggled(object sender, ToggledEventArgs e) + void isMinimizableSwitch_Toggled(object? sender, ToggledEventArgs e) { Window.IsMinimizable = e.Value; } - void isMaximizableSwitch_Toggled(object sender, ToggledEventArgs e) + void isMaximizableSwitch_Toggled(object? sender, ToggledEventArgs e) { Window.IsMaximizable = e.Value; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/NavigationGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/NavigationGallery.xaml.cs index 1ddc5c9aee02..332bb147fac1 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/NavigationGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/NavigationGallery.xaml.cs @@ -22,43 +22,43 @@ public NavigationGallery() this.Title = $"PAGE NUMBER {pageCount}"; } - void InsertPage(object sender, EventArgs e) + void InsertPage(object? sender, EventArgs e) { Navigation.InsertPageBefore(new NavigationGallery(), Navigation.NavigationStack.Last()); } - async void PopPage(object sender, EventArgs e) + async void PopPage(object? sender, EventArgs e) { await Navigation.PopAsync(true); } - async void PushPage(object sender, EventArgs e) + async void PushPage(object? sender, EventArgs e) { await Navigation.PushAsync(new NavigationGallery(), true); } - async void PopToRoot(object sender, EventArgs e) + async void PopToRoot(object? sender, EventArgs e) { await Navigation.PopToRootAsync(true); } - void RemovePage(object sender, EventArgs e) + void RemovePage(object? sender, EventArgs e) { if (Navigation.NavigationStack.Count >= 2) Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]); } - void ToggleNavigationBar(object sender, EventArgs e) + void ToggleNavigationBar(object? sender, EventArgs e) { NavigationPage.SetHasNavigationBar(this, !NavigationPage.GetHasNavigationBar(this)); } - void ToggleBackButton(object sender, EventArgs e) + void ToggleBackButton(object? sender, EventArgs e) { NavigationPage.SetHasBackButton(this, !NavigationPage.GetHasBackButton(this)); } - void ToggleSecondaryToolbarItem(object sender, EventArgs e) + void ToggleSecondaryToolbarItem(object? sender, EventArgs e) { if (!this.ToolbarItems.Where(x => x.Order == ToolbarItemOrder.Secondary).Any()) { @@ -75,7 +75,7 @@ void ToggleSecondaryToolbarItem(object sender, EventArgs e) } - void SwapRoot(object sender, EventArgs e) + void SwapRoot(object? sender, EventArgs e) { if (_currentNavStack == null) { diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/PanGestureGalleries/PanGestureEventsGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/PanGestureGalleries/PanGestureEventsGallery.xaml.cs index 6ead564a06a2..790003d442ee 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/PanGestureGalleries/PanGestureEventsGallery.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/PanGestureGalleries/PanGestureEventsGallery.xaml.cs @@ -9,7 +9,7 @@ public PanGestureEventsGallery() InitializeComponent(); } - void OnPanGestureRecognizerUpdated(object sender, PanUpdatedEventArgs e) + void OnPanGestureRecognizerUpdated(object? sender, PanUpdatedEventArgs e) { InfoLabel.Text = $"StatusType: {e.StatusType}, TotalX: {e.TotalX}, TotalY: {e.TotalY}"; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/PointerGestureGalleryPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/PointerGestureGalleryPage.xaml.cs index 90bf19b5bbb0..ddcd40eb9df7 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/PointerGestureGalleryPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/PointerGestureGalleryPage.xaml.cs @@ -23,52 +23,52 @@ public PointerGestureGalleryPage() colorfulHoverLabel.GestureRecognizers.Add(colorfulHoverGesture); } - void PointerHoverStarted(object sender, PointerEventArgs e) + void PointerHoverStarted(object? sender, PointerEventArgs e) { pgrLabel.Text = "Thanks for hovering me! Now press me!"; pgrLabel.BackgroundColor = Colors.PaleGreen; } - void PointerHoverEnded(object sender, PointerEventArgs e) + void PointerHoverEnded(object? sender, PointerEventArgs e) { pgrLabel.Text = "Hover me again!"; pgrPositionLabel.Text = "Hover above label to reveal pointer position again"; pgrLabel.BackgroundColor = Colors.Transparent; } - void PointerMoved(object sender, PointerEventArgs e) + void PointerMoved(object? sender, PointerEventArgs e) { - pgrPositionLabel.Text = $"Pointer position is at: {e.GetPosition((View)sender)}"; + pgrPositionLabel.Text = $"Pointer position is at: {e.GetPosition((View)sender!)}"; pgrPositionToWindow.Text = $"Pointer position inside window: {e.GetPosition(null)}"; pgrPositionToThisLabel.Text = $"Pointer position relative to this label: {e.GetPosition(pgrPositionToThisLabel)}"; } - void PointerPressStarted(object sender, PointerEventArgs e) + void PointerPressStarted(object? sender, PointerEventArgs e) { pgrLabel.Text = "Thanks for pressing me! Now release me!"; pgrLabel.BackgroundColor = Colors.SkyBlue; } - void PointerPressEnded(object sender, PointerEventArgs e) + void PointerPressEnded(object? sender, PointerEventArgs e) { pgrLabel.Text = "Thanks for releasing me! Press me again or leave me!"; pgrLabel.BackgroundColor = Colors.Yellow; } - void HoverBegan(object sender, PointerEventArgs e) + void HoverBegan(object? sender, PointerEventArgs e) { hoverLabel.Text = "Thanks for hovering me!"; } - void HoverEnded(object sender, PointerEventArgs e) + void HoverEnded(object? sender, PointerEventArgs e) { hoverLabel.Text = "Hover me again!"; positionLabel.Text = "Hover above label to reveal pointer position again"; } - void HoverMoved(object sender, PointerEventArgs e) + void HoverMoved(object? sender, PointerEventArgs e) { - positionLabel.Text = $"Pointer position is at: {e.GetPosition((View)sender)}"; + positionLabel.Text = $"Pointer position is at: {e.GetPosition((View)sender!)}"; positionToWindow.Text = $"Pointer position inside window: {e.GetPosition(null)}"; positionToThisLabel.Text = $"Pointer position relative to this label: {e.GetPosition(positionToThisLabel)}"; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/SemanticsPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/SemanticsPage.xaml.cs index 193e61556b4e..519235193c15 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/SemanticsPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/SemanticsPage.xaml.cs @@ -33,7 +33,7 @@ private async void PushButton_Clicked(object? sender, System.EventArgs e) await Navigation.PushAsync(new SemanticsPage()); } - private void SetSemanticFocusButton_Clicked(object sender, System.EventArgs e) + private void SetSemanticFocusButton_Clicked(object? sender, System.EventArgs e) { semanticFocusLabel.SetSemanticFocus(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/ShadowGalleries/InvalidateShadowHostPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/ShadowGalleries/InvalidateShadowHostPage.xaml.cs index 2e64829db48b..eed402597986 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/ShadowGalleries/InvalidateShadowHostPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/ShadowGalleries/InvalidateShadowHostPage.xaml.cs @@ -12,18 +12,18 @@ public InvalidateShadowHostPage() UpdateShadowOffset(); } - void OnUpdateHostSizeClicked(object sender, EventArgs args) + void OnUpdateHostSizeClicked(object? sender, EventArgs args) { var random = new Random(); ShadowHost.MinimumHeightRequest = ShadowHost.MinimumWidthRequest = random.Next(100, 300); } - void OnShadowOffsetXChanged(object sender, ValueChangedEventArgs e) + void OnShadowOffsetXChanged(object? sender, ValueChangedEventArgs e) { UpdateShadowOffset(); } - void OnShadowOffsetYChanged(object sender, ValueChangedEventArgs e) + void OnShadowOffsetYChanged(object? sender, ValueChangedEventArgs e) { UpdateShadowOffset(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/ShadowGalleries/ShadowPlaygroundPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/ShadowGalleries/ShadowPlaygroundPage.xaml.cs index 569ca2a639c7..dba8266a81ab 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/ShadowGalleries/ShadowPlaygroundPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/ShadowGalleries/ShadowPlaygroundPage.xaml.cs @@ -12,17 +12,17 @@ public ShadowPlaygroundPage() UpdateShadowOffset(); } - void RemoveShadowClicked(object sender, EventArgs e) + void RemoveShadowClicked(object? sender, EventArgs e) { ClippedShadowView.Shadow = ShadowView.Shadow = ShadowViewGradient.Shadow = LabelShadowView.Shadow = null!; } - void OnShadowOffsetXChanged(object sender, ValueChangedEventArgs e) + void OnShadowOffsetXChanged(object? sender, ValueChangedEventArgs e) { UpdateShadowOffset(); } - void OnShadowOffsetYChanged(object sender, ValueChangedEventArgs e) + void OnShadowOffsetYChanged(object? sender, ValueChangedEventArgs e) { UpdateShadowOffset(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.cs b/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.cs index 1fa5999089b6..4eb33c8d98e4 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.cs @@ -42,18 +42,18 @@ protected override void OnNavigatedTo(NavigatedToEventArgs args) popToRoot.IsVisible = Navigation.NavigationStack.Count > 1; } - async void OnPushPage(object sender, EventArgs e) + async void OnPushPage(object? sender, EventArgs e) { await Navigation.PushAsync(new ShellChromeGallery()); } - async void OnPopPage(object sender, EventArgs e) + async void OnPopPage(object? sender, EventArgs e) { if (Navigation.NavigationStack.Count > 1) await Navigation.PopAsync(); } - async void OnPopToRoot(object sender, EventArgs e) + async void OnPopToRoot(object? sender, EventArgs e) { await Navigation.PopToRootAsync(); } @@ -83,14 +83,14 @@ protected override void OnAppearing() AppShell.FlyoutHeaderBehavior = (FlyoutHeaderBehavior)flyoutHeaderBehavior.SelectedIndex; } - void OnToggleFlyoutIsPresented(object sender, EventArgs e) + void OnToggleFlyoutIsPresented(object? sender, EventArgs e) { if (AppShell is null) return; AppShell.FlyoutIsPresented = !AppShell.FlyoutIsPresented; } - void OnToggleFlyoutBackgroundColor(object sender, EventArgs e) + void OnToggleFlyoutBackgroundColor(object? sender, EventArgs e) { if (AppShell is null) return; @@ -112,24 +112,24 @@ void OnToggleFlyoutBackgroundColor(object sender, EventArgs e) flyoutBackgroundColor.Background = AppShell.FlyoutBackground; } - void OnToggleNavBarHasShadow(object sender, EventArgs e) + void OnToggleNavBarHasShadow(object? sender, EventArgs e) { Shell.SetNavBarHasShadow(this, !Shell.GetNavBarHasShadow(this)); } - void OnToggleNavBarIsVisible(object sender, EventArgs e) + void OnToggleNavBarIsVisible(object? sender, EventArgs e) { Shell.SetNavBarIsVisible(this, !Shell.GetNavBarIsVisible(this)); } - void OnToggleBackButtonIsVisible(object sender, EventArgs e) + void OnToggleBackButtonIsVisible(object? sender, EventArgs e) { var backButtonBehavior = Shell.GetBackButtonBehavior(this) ?? new BackButtonBehavior(); backButtonBehavior.IsVisible = !backButtonBehavior.IsVisible; Shell.SetBackButtonBehavior(this, backButtonBehavior); } - void OnToggleSearchHandler(object sender, EventArgs e) + void OnToggleSearchHandler(object? sender, EventArgs e) { var searchHandler = Shell.GetSearchHandler(this); if (searchHandler != null) @@ -138,24 +138,24 @@ void OnToggleSearchHandler(object sender, EventArgs e) AddSearchHandler("text here"); } - void OnToggleTabBar(object sender, EventArgs e) + void OnToggleTabBar(object? sender, EventArgs e) { Shell.SetTabBarIsVisible(this, !Shell.GetTabBarIsVisible(this)); } - void OnToggleTabBarTitleColor(object sender, EventArgs e) + void OnToggleTabBarTitleColor(object? sender, EventArgs e) { var random = new Random(); Shell.SetTabBarTitleColor(Shell.Current.CurrentItem, Color.FromRgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255))); } - void OnToggleTabBarUnselectedColor(object sender, EventArgs e) + void OnToggleTabBarUnselectedColor(object? sender, EventArgs e) { var random = new Random(); Shell.SetTabBarUnselectedColor(Shell.Current.CurrentItem, Color.FromRgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255))); } - void OnToggleTabBarForegroundColor(object sender, EventArgs e) + void OnToggleTabBarForegroundColor(object? sender, EventArgs e) { var random = new Random(); Shell.SetTabBarForegroundColor(Shell.Current.CurrentItem, Color.FromRgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255))); diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/ToolbarPage.cs b/src/Controls/samples/Controls.Sample/Pages/Core/ToolbarPage.cs index 2d8a6f779e16..858f382c9827 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/ToolbarPage.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/ToolbarPage.cs @@ -22,7 +22,7 @@ public ToolbarPage() BindingContext = this; } - void ItemClicked(object sender, EventArgs e) + void ItemClicked(object? sender, EventArgs e) { if (sender is ToolbarItem tbi) { @@ -30,17 +30,17 @@ void ItemClicked(object sender, EventArgs e) } } - void Button_Clicked(object sender, EventArgs e) + void Button_Clicked(object? sender, EventArgs e) { secondary4.IsEnabled = !secondary4.IsEnabled; } - void Button_Clicked1(object sender, EventArgs e) + void Button_Clicked1(object? sender, EventArgs e) { primary1.IsEnabled = !primary1.IsEnabled; } - void Button_Clicked2(object sender, EventArgs e) + void Button_Clicked2(object? sender, EventArgs e) { // 5 second delay so you can have the menu open and see the change. // However, the menu will close if change happens. There is no way around this. @@ -53,12 +53,12 @@ void Button_Clicked2(object sender, EventArgs e) }); } - void Button_Clicked3(object sender, EventArgs e) + void Button_Clicked3(object? sender, EventArgs e) { secondary1.Text = secondary1.Text == "Test Secondary (1)" ? "Changed Text" : "Test Secondary (1)"; } - void Button_Clicked4(object sender, EventArgs e) + void Button_Clicked4(object? sender, EventArgs e) { _cachedSecondary3 ??= secondary3; @@ -72,7 +72,7 @@ void Button_Clicked4(object sender, EventArgs e) } } - void Button_Clicked5(object sender, EventArgs e) + void Button_Clicked5(object? sender, EventArgs e) { secondary3.Command = new Command(() => { diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/WindowTitleBar.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/WindowTitleBar.xaml.cs index 9eb247912614..afdaca0fda0f 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/WindowTitleBar.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/WindowTitleBar.xaml.cs @@ -10,7 +10,7 @@ public WindowTitleBar() InitializeComponent(); } - public async void OnPushModalClicked(object sender, EventArgs args) + public async void OnPushModalClicked(object? sender, EventArgs args) { await Navigation.PushModalAsync(new ContentPage() { diff --git a/src/Controls/samples/Controls.Sample/Pages/HitTestingPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/HitTestingPage.xaml.cs index 510654b32fb2..90e9f1071436 100644 --- a/src/Controls/samples/Controls.Sample/Pages/HitTestingPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/HitTestingPage.xaml.cs @@ -32,12 +32,12 @@ public HitTestingPage() InitializeComponent(); } - private void RectangleSelectionCheckBox_CheckedChanged(object sender, Microsoft.Maui.Controls.CheckedChangedEventArgs e) + private void RectangleSelectionCheckBox_CheckedChanged(object? sender, Microsoft.Maui.Controls.CheckedChangedEventArgs e) { _state = RectangleSelectionCheckBox.IsChecked ? State.RectangleSelectionPickFirst : State.SingleSelection; } - private void ContentPage_Loaded(object sender, EventArgs e) + private void ContentPage_Loaded(object? sender, EventArgs e) { _window = this.GetParentWindow(); _overlay = new WindowOverlay(_window); @@ -85,7 +85,7 @@ void DoHandleOverlayTapped(object? sender, WindowOverlayTappedEventArgs e) - private void ContentPage_Unloaded(object sender, EventArgs e) + private void ContentPage_Unloaded(object? sender, EventArgs e) { _overlay!.RemoveWindowElement(this); _window!.RemoveOverlay(_overlay); diff --git a/src/Controls/samples/Controls.Sample/Pages/Layouts/LayoutIsEnabledPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Layouts/LayoutIsEnabledPage.xaml.cs index 42141315c1b8..ce0533acb262 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Layouts/LayoutIsEnabledPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Layouts/LayoutIsEnabledPage.xaml.cs @@ -50,14 +50,14 @@ public bool IsCommandEnabled public Command TheCommand { get; } - void OnDisableLayoutBtnClicked(object sender, EventArgs e) + void OnDisableLayoutBtnClicked(object? sender, EventArgs e) { MainLayout.IsEnabled = !MainLayout.IsEnabled; - ((Button)sender).Text = MainLayout.IsEnabled ? "Disable Layout" : "Enable Layout"; + ((Button)sender!).Text = MainLayout.IsEnabled ? "Disable Layout" : "Enable Layout"; } - void OnDisableButtonBtnClicked(object sender, EventArgs e) + void OnDisableButtonBtnClicked(object? sender, EventArgs e) { DisabledButton.IsEnabled = !DisabledButton.IsEnabled; DisabledCommandButton.IsEnabled = !DisabledCommandButton.IsEnabled; @@ -65,7 +65,7 @@ void OnDisableButtonBtnClicked(object sender, EventArgs e) DisabledButton.Text = DisabledButton.IsEnabled ? "Enabled" : "Disabled"; DisabledCommandButton.Text = DisabledCommandButton.IsEnabled ? "Enabled" : "Disabled"; - ((Button)sender).Text = DisabledButton.IsEnabled ? "Disable Button" : "Enable Button"; + ((Button)sender!).Text = DisabledButton.IsEnabled ? "Disable Button" : "Enable Button"; } void OnThe() diff --git a/src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPages/ScrollToEndPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPages/ScrollToEndPage.xaml.cs index e808dcff89b7..bef21f211a74 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPages/ScrollToEndPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPages/ScrollToEndPage.xaml.cs @@ -10,12 +10,12 @@ public ScrollToEndPage() InitializeComponent(); } - async void OnButtonClicked(object sender, EventArgs e) + async void OnButtonClicked(object? sender, EventArgs e) { await scrollView.ScrollToAsync(finalLabel, ScrollToPosition.End, true); } - void OnScrollViewScrolled(object sender, ScrolledEventArgs e) + void OnScrollViewScrolled(object? sender, ScrolledEventArgs e) { Console.WriteLine($"ScrollX: {e.ScrollX}, ScrollY: {e.ScrollY}"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPages/ScrollViewOrientationPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPages/ScrollViewOrientationPage.xaml.cs index 558964c1e49f..7e2f109ce98d 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPages/ScrollViewOrientationPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPages/ScrollViewOrientationPage.xaml.cs @@ -12,7 +12,7 @@ public ScrollViewOrientationPage() InitializeComponent(); } - public void OrientationSelectedIndexChanged(object sender, EventArgs args) + public void OrientationSelectedIndexChanged(object? sender, EventArgs args) { ScrollViewer.Orientation = (ScrollOrientation)Orientation.SelectedIndex; } diff --git a/src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPages/ScrollViewTemplatePage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPages/ScrollViewTemplatePage.xaml.cs index bf48c2330071..10fb9df3a333 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPages/ScrollViewTemplatePage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPages/ScrollViewTemplatePage.xaml.cs @@ -14,7 +14,7 @@ public ScrollViewTemplatePage() InitializeComponent(); } - private void OnCounterClicked(object sender, EventArgs e) + private void OnCounterClicked(object? sender, EventArgs e) { count++; diff --git a/src/Controls/samples/Controls.Sample/Pages/Others/GraphicsViewPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Others/GraphicsViewPage.xaml.cs index 67318830af62..7949f0326fc5 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Others/GraphicsViewPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Others/GraphicsViewPage.xaml.cs @@ -13,37 +13,37 @@ public GraphicsViewPage() InitializeComponent(); } - void OnButtonClicked(object sender, EventArgs e) + void OnButtonClicked(object? sender, EventArgs e) => GraphicsView.Invalidate(); - void GraphicsView_DragInteraction(object sender, TouchEventArgs e) + void GraphicsView_DragInteraction(object? sender, TouchEventArgs e) => UpdateInteractions("Drag Touches", e); - void GraphicsView_CancelInteraction(object sender, EventArgs e) + void GraphicsView_CancelInteraction(object? sender, EventArgs e) => UpdateInteractions("Cancel Touches"); - void GraphicsView_EndInteraction(object sender, TouchEventArgs e) + void GraphicsView_EndInteraction(object? sender, TouchEventArgs e) => UpdateInteractions("End Touches", e); - void GraphicsView_StartInteraction(object sender, TouchEventArgs e) + void GraphicsView_StartInteraction(object? sender, TouchEventArgs e) => UpdateInteractions("Start Touch", e); - void GraphicsView_StartHoverInteraction(object sender, TouchEventArgs e) + void GraphicsView_StartHoverInteraction(object? sender, TouchEventArgs e) => UpdateInteractions("Start Hover", e); - void GraphicsView_MoveHoverInteraction(object sender, TouchEventArgs e) + void GraphicsView_MoveHoverInteraction(object? sender, TouchEventArgs e) => UpdateInteractions("Move Hover", e); - void GraphicsView_EndHoverInteraction(object sender, EventArgs e) + void GraphicsView_EndHoverInteraction(object? sender, EventArgs e) => UpdateInteractions("End Hover"); - void GraphicsView_Tapped(object sender, EventArgs args) + void GraphicsView_Tapped(object? sender, EventArgs args) => UpdateGestures("TapGestureRecognizer"); - void GraphicsView_PanUpdated(object sender, PanUpdatedEventArgs args) + void GraphicsView_PanUpdated(object? sender, PanUpdatedEventArgs args) => UpdateGestures("PanGestureRecognizer"); - void GraphicsView_PinchUpdated(object sender, PinchGestureUpdatedEventArgs args) + void GraphicsView_PinchUpdated(object? sender, PinchGestureUpdatedEventArgs args) => UpdateGestures("PinchGestureRecognizer "); void UpdateInteractions(string name, TouchEventArgs e) diff --git a/src/Controls/samples/Controls.Sample/Pages/Others/RenderViewPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Others/RenderViewPage.xaml.cs index ac5b917a90d6..baa7a1641ee9 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Others/RenderViewPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Others/RenderViewPage.xaml.cs @@ -26,7 +26,7 @@ public RenderViewPage() BindingContext = vm = new RenderBindingModel(); } - async void RenderWindow_Clicked(object sender, EventArgs e) + async void RenderWindow_Clicked(object? sender, EventArgs e) { Reset(); stopwatch.Start(); @@ -38,7 +38,7 @@ async void RenderWindow_Clicked(object sender, EventArgs e) await RenderView(renderImage); } - async void RenderButton_Clicked(object sender, EventArgs e) + async void RenderButton_Clicked(object? sender, EventArgs e) { Reset(); stopwatch.Start(); @@ -50,7 +50,7 @@ async void RenderButton_Clicked(object sender, EventArgs e) await RenderView(renderImage); } - async void RenderViewSaved_Clicked(object sender, EventArgs e) + async void RenderViewSaved_Clicked(object? sender, EventArgs e) { if (imageStream is not null) { diff --git a/src/Controls/samples/Controls.Sample/Pages/Others/TemplatePage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Others/TemplatePage.xaml.cs index 5522cdd4bcbf..982909d84ffa 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Others/TemplatePage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Others/TemplatePage.xaml.cs @@ -10,7 +10,7 @@ public TemplatePage() } int count = 0; - private void OnCounterClicked(object sender, EventArgs e) + private void OnCounterClicked(object? sender, EventArgs e) { count++; CounterLabel.Text = $"Current count: {count}"; diff --git a/src/Controls/samples/Controls.Sample/Pages/OthersPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/OthersPage.xaml.cs index f46450170aa6..caf6e593349d 100644 --- a/src/Controls/samples/Controls.Sample/Pages/OthersPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/OthersPage.xaml.cs @@ -11,14 +11,14 @@ public OthersPage() InitializeComponent(); } - void TestAddOverlayWindow(object sender, EventArgs e) + void TestAddOverlayWindow(object? sender, EventArgs e) { var window = GetParentWindow(); overlay ??= new TestWindowOverlay(window); window.AddOverlay(overlay); } - void TestRemoveOverlayWindow(object sender, EventArgs e) + void TestRemoveOverlayWindow(object? sender, EventArgs e) { if (overlay is not null) { @@ -27,14 +27,14 @@ void TestRemoveOverlayWindow(object sender, EventArgs e) } } - void TestVisualTreeHelper(object sender, EventArgs e) + void TestVisualTreeHelper(object? sender, EventArgs e) { var overlay = GetParentWindow().VisualDiagnosticsOverlay; overlay.RemoveAdorners(); overlay.AddAdorner(TestButton, false); } - void EnableElementPicker(object sender, EventArgs e) + void EnableElementPicker(object? sender, EventArgs e) { GetParentWindow().VisualDiagnosticsOverlay.EnableElementSelector = true; } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidEntryPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidEntryPage.xaml.cs index 34dd6ae33420..21b504c7e9e9 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidEntryPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidEntryPage.xaml.cs @@ -12,7 +12,7 @@ public AndroidEntryPage() InitializeComponent(); } - void OnSelectedIndexChanged(object sender, EventArgs e) + void OnSelectedIndexChanged(object? sender, EventArgs e) { ImeFlags flag = (ImeFlags)Enum.Parse(typeof(ImeFlags), _picker.SelectedItem.ToString()!); _entry.On().SetImeOptions(flag); diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidListViewFastScrollPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidListViewFastScrollPage.xaml.cs index 143d814ff2b1..075e66f8c6ef 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidListViewFastScrollPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidListViewFastScrollPage.xaml.cs @@ -14,7 +14,7 @@ public AndroidListViewFastScrollPage() BindingContext = new ListViewViewModel(); } - void OnButtonClicked(object sender, EventArgs e) + void OnButtonClicked(object? sender, EventArgs e) { listView.On().SetIsFastScrollEnabled(!listView.On().IsFastScrollEnabled()); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidSoftInputModeAdjustPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidSoftInputModeAdjustPage.xaml.cs index b63683c7b4cf..7e9661bd62a3 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidSoftInputModeAdjustPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidSoftInputModeAdjustPage.xaml.cs @@ -12,12 +12,12 @@ public AndroidSoftInputModeAdjustPage() InitializeComponent(); } - void OnPanButtonClicked(object sender, EventArgs e) + void OnPanButtonClicked(object? sender, EventArgs e) { Microsoft.Maui.Controls.Application.Current!.On().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Pan); } - void OnResizeButtonClicked(object sender, EventArgs e) + void OnResizeButtonClicked(object? sender, EventArgs e) { Microsoft.Maui.Controls.Application.Current!.On().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidSwipeViewTransitionModePage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidSwipeViewTransitionModePage.xaml.cs index 6cf52a4ffaf9..a0d6fdd75ef2 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidSwipeViewTransitionModePage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidSwipeViewTransitionModePage.xaml.cs @@ -14,13 +14,13 @@ public AndroidSwipeViewTransitionModePage() InitializeComponent(); } - void OnSwipeViewTransitionModeChanged(object sender, EventArgs e) + void OnSwipeViewTransitionModeChanged(object? sender, EventArgs e) { - SwipeTransitionMode transitionMode = (SwipeTransitionMode)((EnumPicker)sender).SelectedItem; + SwipeTransitionMode transitionMode = (SwipeTransitionMode)((EnumPicker)sender!).SelectedItem!; swipeView.On().SetSwipeTransitionMode(transitionMode); } - async void OnDeleteSwipeItemInvoked(object sender, EventArgs e) + async void OnDeleteSwipeItemInvoked(object? sender, EventArgs e) { await DisplayAlertAsync("SwipeView", "Delete invoked.", "OK"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidTabbedPageSwipePage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidTabbedPageSwipePage.xaml.cs index 07ecdcd1badc..8b14ad7d09b3 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidTabbedPageSwipePage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidTabbedPageSwipePage.xaml.cs @@ -13,17 +13,17 @@ public AndroidTabbedPageSwipePage() InitializeComponent(); } - void OnSwipePagingButtonClicked(object sender, EventArgs e) + void OnSwipePagingButtonClicked(object? sender, EventArgs e) { On().SetIsSwipePagingEnabled(!On().IsSwipePagingEnabled()); } - void OnSmoothScrollButtonClicked(object sender, EventArgs e) + void OnSmoothScrollButtonClicked(object? sender, EventArgs e) { On().SetIsSmoothScrollEnabled(!On().IsSmoothScrollEnabled()); } - void OnReturnButtonClicked(object sender, EventArgs e) + void OnReturnButtonClicked(object? sender, EventArgs e) { Navigation.PopAsync(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidTitleViewPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidTitleViewPage.xaml.cs index 2c681cd7bdb8..e4578adae9fe 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidTitleViewPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidTitleViewPage.xaml.cs @@ -11,7 +11,7 @@ public AndroidTitleViewPage() InitializeComponent(); } - void OnReturnButtonClicked(object sender, EventArgs e) + void OnReturnButtonClicked(object? sender, EventArgs e) { Navigation.PopAsync(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/ContentPageTwo.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/ContentPageTwo.xaml.cs index 752be7d298b6..8dca8de73099 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/ContentPageTwo.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/ContentPageTwo.xaml.cs @@ -14,7 +14,7 @@ public ContentPageTwo(ICommand restore) _returnToPlatformSpecificsPage = restore; } - void OnReturnButtonClicked(object sender, EventArgs e) + void OnReturnButtonClicked(object? sender, EventArgs e) { _returnToPlatformSpecificsPage.Execute(null); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsAddRemoveToolbarItemsPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsAddRemoveToolbarItemsPage.xaml.cs index cd2fb16179d6..397474520532 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsAddRemoveToolbarItemsPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsAddRemoveToolbarItemsPage.xaml.cs @@ -26,19 +26,19 @@ public WindowsAddRemoveToolbarItemsPage() #endif } - void OnAddPrimaryButtonClicked(object sender, EventArgs e) + void OnAddPrimaryButtonClicked(object? sender, EventArgs e) { int index = ParentPage.ToolbarItems.Count(item => item.Order == ToolbarItemOrder.Primary) + 1; ParentPage.ToolbarItems.Add(new ToolbarItem(string.Format("Primary {0}", index), "calculator.png", _action, ToolbarItemOrder.Primary)); } - void OnAddSecondaryButtonClicked(object sender, EventArgs e) + void OnAddSecondaryButtonClicked(object? sender, EventArgs e) { int index = ParentPage.ToolbarItems.Count(item => item.Order == ToolbarItemOrder.Secondary) + 1; ParentPage.ToolbarItems.Add(new ToolbarItem(string.Format("Secondary {0}", index), "calculator.png", _action, ToolbarItemOrder.Secondary)); } - void OnRemoveButtonClicked(object sender, EventArgs e) + void OnRemoveButtonClicked(object? sender, EventArgs e) { if (ParentPage.ToolbarItems.Any()) { diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsCollapseStyleChangerPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsCollapseStyleChangerPage.xaml.cs index 1ce727b06fd7..1ceb4830dfc8 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsCollapseStyleChangerPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsCollapseStyleChangerPage.xaml.cs @@ -30,7 +30,7 @@ void PopulatePicker() } } - void OnPickerSelectedIndexChanged(object sender, EventArgs e) + void OnPickerSelectedIndexChanged(object? sender, EventArgs e) { ParentPage.On().SetCollapseStyle((CollapseStyle)Enum.Parse(typeof(CollapseStyle), picker.Items[picker.SelectedIndex])); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsCollapseWidthAdjusterPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsCollapseWidthAdjusterPage.xaml.cs index 152347e9666c..03617ad3eaca 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsCollapseWidthAdjusterPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsCollapseWidthAdjusterPage.xaml.cs @@ -19,7 +19,7 @@ public WindowsCollapseWidthAdjusterPage() InitializeComponent(); } - void OnChangeButtonClicked(object sender, EventArgs e) + void OnChangeButtonClicked(object? sender, EventArgs e) { double width; if (double.TryParse(entry.Text, out width)) diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsDragAndDropCustomization.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsDragAndDropCustomization.xaml.cs index 5d13e8afef17..d1f939bab214 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsDragAndDropCustomization.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsDragAndDropCustomization.xaml.cs @@ -23,7 +23,7 @@ public WindowsDragAndDropCustomization() }; } - void DropGestureRecognizer_DragOver(System.Object sender, Microsoft.Maui.Controls.DragEventArgs e) + void DropGestureRecognizer_DragOver(System.Object? sender, Microsoft.Maui.Controls.DragEventArgs e) { #if WINDOWS var dragUI = e.PlatformArgs!.DragEventArgs.DragUIOverride; diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsListViewPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsListViewPage.xaml.cs index 1cf2a476c0e7..feca21a3ebd2 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsListViewPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsListViewPage.xaml.cs @@ -14,17 +14,17 @@ public WindowsListViewPage() UpdateLabel(); } - async void OnListViewItemTapped(object sender, ItemTappedEventArgs e) + async void OnListViewItemTapped(object? sender, ItemTappedEventArgs e) { await DisplayAlertAsync("Item Tapped", "ItemTapped event fired.", "OK"); } - async void TapGestureRecognizer_Tapped(object sender, EventArgs e) + async void TapGestureRecognizer_Tapped(object? sender, EventArgs e) { await DisplayAlertAsync("Tap Gesture Recognizer", "Tapped event fired.", "OK"); } - void OnToggleButtonClicked(object sender, EventArgs e) + void OnToggleButtonClicked(object? sender, EventArgs e) { switch (_listView.On().GetSelectionMode()) { diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsReadingOrderPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsReadingOrderPage.xaml.cs index 1772e43e59cc..69770c62a3ef 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsReadingOrderPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsReadingOrderPage.xaml.cs @@ -13,7 +13,7 @@ public WindowsReadingOrderPage() UpdateLabel(); } - void OnToggleButtonClicked(object sender, EventArgs e) + void OnToggleButtonClicked(object? sender, EventArgs e) { var detectReadingOrder = _editor.On().GetDetectReadingOrderFromContent(); diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsRefreshViewPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsRefreshViewPage.xaml.cs index 97c49302154e..fc9fffe8f580 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsRefreshViewPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsRefreshViewPage.xaml.cs @@ -14,7 +14,7 @@ public WindowsRefreshViewPage() enumPicker.SelectedIndex = 0; } - void OnSelectedIndexChanged(object sender, EventArgs e) + void OnSelectedIndexChanged(object? sender, EventArgs e) { refreshView.On().SetRefreshPullDirection((RefreshPullDirection)enumPicker.SelectedItem); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsSearchBarPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsSearchBarPage.xaml.cs index 1383b020313d..e8df8906541e 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsSearchBarPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsSearchBarPage.xaml.cs @@ -11,7 +11,7 @@ public WindowsSearchBarPage() InitializeComponent(); } - void OnToggleButtonClicked(object sender, EventArgs e) + void OnToggleButtonClicked(object? sender, EventArgs e) { _searchBar.On().SetIsSpellCheckEnabled(!_searchBar.On().GetIsSpellCheckEnabled()); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsTileBarPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsTileBarPage.xaml.cs index 0764e759e029..96dee19793de 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsTileBarPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsTileBarPage.xaml.cs @@ -39,7 +39,7 @@ protected override void OnAppearing() Window.TitleBar = _customTitleBar; } - private void SetIconCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) + private void SetIconCheckBox_CheckedChanged(object? sender, CheckedChangedEventArgs e) { if (e.Value) { @@ -51,7 +51,7 @@ private void SetIconCheckBox_CheckedChanged(object sender, CheckedChangedEventAr } } - private void ColorButton_Clicked(object sender, EventArgs e) + private void ColorButton_Clicked(object? sender, EventArgs e) { if (Microsoft.Maui.Graphics.Color.TryParse(ColorTextBox.Text, out var color)) { @@ -59,7 +59,7 @@ private void ColorButton_Clicked(object sender, EventArgs e) } } - private void ForegroundColorButton_Clicked(object sender, EventArgs e) + private void ForegroundColorButton_Clicked(object? sender, EventArgs e) { if (Microsoft.Maui.Graphics.Color.TryParse(ForegroundColorTextBox.Text, out var color)) { @@ -67,7 +67,7 @@ private void ForegroundColorButton_Clicked(object sender, EventArgs e) } } - private void LeadingCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) + private void LeadingCheckBox_CheckedChanged(object? sender, CheckedChangedEventArgs e) { if (e.Value) { @@ -82,7 +82,7 @@ private void LeadingCheckBox_CheckedChanged(object sender, CheckedChangedEventAr } } - private void ContentCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) + private void ContentCheckBox_CheckedChanged(object? sender, CheckedChangedEventArgs e) { if (e.Value) { @@ -100,7 +100,7 @@ private void ContentCheckBox_CheckedChanged(object sender, CheckedChangedEventAr } } - private void TrailingCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) + private void TrailingCheckBox_CheckedChanged(object? sender, CheckedChangedEventArgs e) { if (e.Value) { @@ -127,7 +127,7 @@ private void TrailingCheckBox_CheckedChanged(object sender, CheckedChangedEventA } } - private void TallModeCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) + private void TallModeCheckBox_CheckedChanged(object? sender, CheckedChangedEventArgs e) { if (e.Value) { diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsToolbarPlacementChangerPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsToolbarPlacementChangerPage.xaml.cs index 8e587f87d438..9e2a85cf2c9c 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsToolbarPlacementChangerPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsToolbarPlacementChangerPage.xaml.cs @@ -30,7 +30,7 @@ void PopulatePicker() } } - void OnPickerSelectedIndexChanged(object sender, EventArgs e) + void OnPickerSelectedIndexChanged(object? sender, EventArgs e) { ParentPage.On().SetToolbarPlacement((ToolbarPlacement)Enum.Parse(typeof(ToolbarPlacement), picker.Items[picker.SelectedIndex])); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsVisualElementAccessKeysPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsVisualElementAccessKeysPage.xaml.cs index 401242628a8d..6637442da05c 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsVisualElementAccessKeysPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsVisualElementAccessKeysPage.xaml.cs @@ -11,7 +11,7 @@ public WindowsVisualElementAccessKeysPage() InitializeComponent(); } - async void OnButtonClicked(object sender, EventArgs e) + async void OnButtonClicked(object? sender, EventArgs e) { var button = sender as Button; await DisplayAlertAsync("Button clicked", $"Clicked {button?.Text}", "OK"); diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsWebViewPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsWebViewPage.xaml.cs index f1cbd9b83b77..501348e93447 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsWebViewPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsWebViewPage.xaml.cs @@ -16,12 +16,12 @@ public WindowsWebViewPage() }; } - void OnToggleButtonClicked(object sender, EventArgs e) + void OnToggleButtonClicked(object? sender, EventArgs e) { _webView.On().SetIsJavaScriptAlertEnabled(!_webView.On().IsJavaScriptAlertEnabled()); } - void OnLoadLocalAssetWithHtmlSourceAndBaseUrl(object sender, EventArgs e) + void OnLoadLocalAssetWithHtmlSourceAndBaseUrl(object? sender, EventArgs e) { _webView.Source = new HtmlWebViewSource { @@ -30,7 +30,7 @@ void OnLoadLocalAssetWithHtmlSourceAndBaseUrl(object sender, EventArgs e) }; } - void OnLoadLocalAssetWithUrlSource(object sender, EventArgs e) + void OnLoadLocalAssetWithUrlSource(object? sender, EventArgs e) { _webView.Source = new UrlWebViewSource { diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSBlurEffectPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSBlurEffectPage.xaml.cs index eac76a9c67f1..adc14007ec23 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSBlurEffectPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSBlurEffectPage.xaml.cs @@ -12,22 +12,22 @@ public iOSBlurEffectPage() InitializeComponent(); } - void OnNoBlurButtonClicked(object sender, EventArgs e) + void OnNoBlurButtonClicked(object? sender, EventArgs e) { image.On().UseBlurEffect(BlurEffectStyle.None); } - void OnExtraLightBlurButtonClicked(object sender, EventArgs e) + void OnExtraLightBlurButtonClicked(object? sender, EventArgs e) { image.On().UseBlurEffect(BlurEffectStyle.ExtraLight); } - void OnLightBlurButtonClicked(object sender, EventArgs e) + void OnLightBlurButtonClicked(object? sender, EventArgs e) { image.On().UseBlurEffect(BlurEffectStyle.Light); } - void OnDarkBlurButtonClicked(object sender, EventArgs e) + void OnDarkBlurButtonClicked(object? sender, EventArgs e) { image.On().UseBlurEffect(BlurEffectStyle.Dark); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSDatePickerPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSDatePickerPage.xaml.cs index 299ceac5faed..662ef0fc126a 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSDatePickerPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSDatePickerPage.xaml.cs @@ -12,7 +12,7 @@ public iOSDatePickerPage() InitializeComponent(); } - void OnButtonClicked(object sender, EventArgs e) + void OnButtonClicked(object? sender, EventArgs e) { switch (datePicker.On().UpdateMode()) { diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSDragAndDropRequestFullSize.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSDragAndDropRequestFullSize.xaml.cs index 453d0c52bdeb..7258cfab63ca 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSDragAndDropRequestFullSize.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSDragAndDropRequestFullSize.xaml.cs @@ -30,7 +30,7 @@ public iOSDragAndDropRequestFullSize() #endif } - void DragGestureRecognizer_DragStarting(System.Object sender, Microsoft.Maui.Controls.DragStartingEventArgs e) + void DragGestureRecognizer_DragStarting(System.Object? sender, Microsoft.Maui.Controls.DragStartingEventArgs e) { #if IOS || MACCATALYST if (drawnImageSwitch.IsToggled) @@ -74,19 +74,19 @@ void DragGestureRecognizer_DragStarting(System.Object sender, Microsoft.Maui.Con #endif } - void Drawn_Switch_Toggled(object sender, ToggledEventArgs e) + void Drawn_Switch_Toggled(object? sender, ToggledEventArgs e) { if (e.Value) dotnetBotImageSwitch.IsToggled = false; } - void DotnetBot_Switch_Toggled(object sender, ToggledEventArgs e) + void DotnetBot_Switch_Toggled(object? sender, ToggledEventArgs e) { if (e.Value) drawnImageSwitch.IsToggled = false; } - void DropGestureRecognizer_DragOver(System.Object sender, Microsoft.Maui.Controls.DragEventArgs e) + void DropGestureRecognizer_DragOver(System.Object? sender, Microsoft.Maui.Controls.DragEventArgs e) { #if IOS || MACCATALYST if (copySwitch.IsToggled) @@ -98,11 +98,11 @@ void DropGestureRecognizer_DragOver(System.Object sender, Microsoft.Maui.Control #endif } - void FullSized_Switch_Toggled(object sender, ToggledEventArgs e) + void FullSized_Switch_Toggled(object? sender, ToggledEventArgs e) { } - void Copy_Switch_Toggled(object sender, ToggledEventArgs e) + void Copy_Switch_Toggled(object? sender, ToggledEventArgs e) { if (e.Value) { @@ -111,7 +111,7 @@ void Copy_Switch_Toggled(object sender, ToggledEventArgs e) } } - void Move_Switch_Toggled(object sender, ToggledEventArgs e) + void Move_Switch_Toggled(object? sender, ToggledEventArgs e) { if (e.Value) { @@ -120,7 +120,7 @@ void Move_Switch_Toggled(object sender, ToggledEventArgs e) } } - void Forbidden_Switch_Toggled(object sender, ToggledEventArgs e) + void Forbidden_Switch_Toggled(object? sender, ToggledEventArgs e) { if (e.Value) { diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSEntryPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSEntryPage.xaml.cs index 0e556f2643a5..6af8eddd4103 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSEntryPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSEntryPage.xaml.cs @@ -12,7 +12,7 @@ public iOSEntryPage() InitializeComponent(); } - void OnButtonClicked(object sender, EventArgs e) + void OnButtonClicked(object? sender, EventArgs e) { entry.On().SetAdjustsFontSizeToFitWidth(!entry.On().AdjustsFontSizeToFitWidth()); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSFlyoutPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSFlyoutPage.xaml.cs index deeafe64c817..68b3b2e59024 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSFlyoutPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSFlyoutPage.xaml.cs @@ -15,12 +15,12 @@ public iOSFlyoutPage(ICommand restore) returnToPlatformSpecificsPage = restore; } - void OnShadowButtonClicked(object sender, EventArgs e) + void OnShadowButtonClicked(object? sender, EventArgs e) { On().SetApplyShadow(!On().GetApplyShadow()); } - void OnReturnButtonClicked(object sender, EventArgs e) + void OnReturnButtonClicked(object? sender, EventArgs e) { returnToPlatformSpecificsPage.Execute(null); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSHideHomeIndicatorPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSHideHomeIndicatorPage.xaml.cs index 12a0730475d8..b1f8a5f56f38 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSHideHomeIndicatorPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSHideHomeIndicatorPage.xaml.cs @@ -12,22 +12,22 @@ public iOSHideHomeIndicatorPage() InitializeComponent(); } - void NavigationPage_Clicked(object sender, EventArgs e) + void NavigationPage_Clicked(object? sender, EventArgs e) { Navigation.PushAsync(new iOSHideHomeIndicatorNavigationPageDemo()); } - void TabbedPage_Clicked(object sender, EventArgs e) + void TabbedPage_Clicked(object? sender, EventArgs e) { Navigation.PushAsync(new iOSHideHomeIndicatorPageDemo()); } - void FlyoutPage_Clicked(object sender, EventArgs e) + void FlyoutPage_Clicked(object? sender, EventArgs e) { Navigation.PushAsync(new iOSHideHomeIndicatorFlyoutPageDemo()); } - void Shell_Clicked(object sender, EventArgs e) + void Shell_Clicked(object? sender, EventArgs e) { Navigation.PushAsync(new iOSHideHomeIndicatorShellDemo()); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSLargeTitlePage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSLargeTitlePage.xaml.cs index 92cad19ebad7..19ff9b404b96 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSLargeTitlePage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSLargeTitlePage.xaml.cs @@ -13,7 +13,7 @@ public iOSLargeTitlePage() InitializeComponent(); } - void OnButtonClicked(object sender, EventArgs e) + void OnButtonClicked(object? sender, EventArgs e) { switch (On().LargeTitleDisplay()) { @@ -29,7 +29,7 @@ void OnButtonClicked(object sender, EventArgs e) } } - void OnReturnButtonClicked(object sender, EventArgs e) + void OnReturnButtonClicked(object? sender, EventArgs e) { Navigation.PopAsync(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSModalPagePresentationStyle.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSModalPagePresentationStyle.xaml.cs index 2f5e234b3b5d..4d40b9f6bb2c 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSModalPagePresentationStyle.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSModalPagePresentationStyle.xaml.cs @@ -38,26 +38,26 @@ public iOSModalPagePresentationStyle(UIModalPresentationStyle presentationStyle, this.isChildPage = isChildPage; } - async void OnPushFormSheetClicked(object sender, EventArgs e) + async void OnPushFormSheetClicked(object? sender, EventArgs e) { Microsoft.Maui.Controls.Page pushMe = new iOSModalPagePresentationStyle(UIModalPresentationStyle.FormSheet, true); await Navigation.PushModalAsync(pushMe); } - async void OnPushPopoverClicked(object sender, EventArgs e) + async void OnPushPopoverClicked(object? sender, EventArgs e) { Microsoft.Maui.Controls.Page pushMe = new iOSModalPagePresentationStyle(UIModalPresentationStyle.Popover, true, originButton); await Navigation.PushModalAsync(pushMe); } - async void OnPushPopoverOffsetClicked(object sender, EventArgs e) + async void OnPushPopoverOffsetClicked(object? sender, EventArgs e) { var offset = new System.Drawing.Rectangle(0, 0, 100, 10); Microsoft.Maui.Controls.Page pushMe = new iOSModalPagePresentationStyle(UIModalPresentationStyle.Popover, true, originButton2, offset); await Navigation.PushModalAsync(pushMe); } - async void OnReturnButtonClicked(object sender, EventArgs e) + async void OnReturnButtonClicked(object? sender, EventArgs e) { if (isChildPage) { diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSPanGestureRecognizerPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSPanGestureRecognizerPage.xaml.cs index 19a18d1ce4e7..801ab0176ae8 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSPanGestureRecognizerPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSPanGestureRecognizerPage.xaml.cs @@ -14,13 +14,13 @@ public iOSPanGestureRecognizerPage() BindingContext = new ListViewViewModel(); } - void OnButtonClicked(object sender, EventArgs e) + void OnButtonClicked(object? sender, EventArgs e) { Microsoft.Maui.Controls.Application.Current!.On().SetPanGestureRecognizerShouldRecognizeSimultaneously( !Microsoft.Maui.Controls.Application.Current!.On().GetPanGestureRecognizerShouldRecognizeSimultaneously()); } - void OnPanUpdated(object sender, PanUpdatedEventArgs e) + void OnPanUpdated(object? sender, PanUpdatedEventArgs e) { _messageLabel.Text = $"panned x:{e.TotalX} y:{e.TotalY}"; } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSPickerPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSPickerPage.xaml.cs index f9fc27b458cf..8e3b1c2df2e8 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSPickerPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSPickerPage.xaml.cs @@ -12,7 +12,7 @@ public iOSPickerPage() InitializeComponent(); } - void OnButtonClicked(object sender, EventArgs e) + void OnButtonClicked(object? sender, EventArgs e) { switch (picker.On().UpdateMode()) { diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSafeAreaPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSafeAreaPage.xaml.cs index 7eb309d2078d..6dbbfb4a96d6 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSafeAreaPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSafeAreaPage.xaml.cs @@ -10,7 +10,7 @@ public iOSSafeAreaPage() InitializeComponent(); } - void OnButtonClicked(object sender, EventArgs e) + void OnButtonClicked(object? sender, EventArgs e) { this.SafeAreaEdges = Microsoft.Maui.SafeAreaEdges.None; (sender as Button)!.IsEnabled = false; diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSScrollViewPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSScrollViewPage.xaml.cs index 6c9a340b2760..4650db069abc 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSScrollViewPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSScrollViewPage.xaml.cs @@ -12,12 +12,12 @@ public iOSScrollViewPage() InitializeComponent(); } - void OnButtonClicked(object sender, EventArgs e) + void OnButtonClicked(object? sender, EventArgs e) { scrollView.On().SetShouldDelayContentTouches(!scrollView.On().ShouldDelayContentTouches()); } - void OnReturnButtonClicked(object sender, EventArgs e) + void OnReturnButtonClicked(object? sender, EventArgs e) { Navigation.PopAsync(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSearchBarPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSearchBarPage.xaml.cs index 1a437d23a633..9d0ea12dccca 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSearchBarPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSearchBarPage.xaml.cs @@ -13,7 +13,7 @@ public iOSSearchBarPage() InitializeComponent(); } - void OnSearchBarStyleButtonClicked(object sender, EventArgs e) + void OnSearchBarStyleButtonClicked(object? sender, EventArgs e) { switch (searchBar.On().GetSearchBarStyle()) { @@ -29,7 +29,7 @@ void OnSearchBarStyleButtonClicked(object sender, EventArgs e) } } - void OnToggleBackgroundButtonClicked(object sender, EventArgs e) + void OnToggleBackgroundButtonClicked(object? sender, EventArgs e) { searchBar.BackgroundColor = (searchBar.BackgroundColor == Colors.Teal) ? Colors.Black : Colors.Teal; } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSliderUpdateOnTapPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSliderUpdateOnTapPage.xaml.cs index 5058ac207e91..ca3dcfa48a1a 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSliderUpdateOnTapPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSliderUpdateOnTapPage.xaml.cs @@ -12,7 +12,7 @@ public iOSSliderUpdateOnTapPage() InitializeComponent(); } - void OnButtonClicked(object sender, EventArgs e) + void OnButtonClicked(object? sender, EventArgs e) { _slider.On().SetUpdateOnTap(!_slider.On().GetUpdateOnTap()); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSStatusBarPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSStatusBarPage.xaml.cs index 5b55c8a91217..2a050874208e 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSStatusBarPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSStatusBarPage.xaml.cs @@ -12,7 +12,7 @@ public iOSStatusBarPage() InitializeComponent(); } - void OnPrefersStatusBarHiddenButtonClicked(object sender, EventArgs e) + void OnPrefersStatusBarHiddenButtonClicked(object? sender, EventArgs e) { switch (On().PrefersStatusBarHidden()) { @@ -28,7 +28,7 @@ void OnPrefersStatusBarHiddenButtonClicked(object sender, EventArgs e) } } - void OnPreferredStatusBarUpdateAnimationButtonClicked(object sender, EventArgs e) + void OnPreferredStatusBarUpdateAnimationButtonClicked(object? sender, EventArgs e) { switch (On().PreferredStatusBarUpdateAnimation()) { diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSwipeViewTransitionModePage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSwipeViewTransitionModePage.xaml.cs index e785d7d951e1..8456d9719061 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSwipeViewTransitionModePage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSSwipeViewTransitionModePage.xaml.cs @@ -14,13 +14,13 @@ public iOSSwipeViewTransitionModePage() InitializeComponent(); } - void OnSwipeViewTransitionModeChanged(object sender, EventArgs e) + void OnSwipeViewTransitionModeChanged(object? sender, EventArgs e) { SwipeTransitionMode transitionMode = (SwipeTransitionMode)(sender as EnumPicker)!.SelectedItem; swipeView.On().SetSwipeTransitionMode(transitionMode); } - async void OnDeleteSwipeItemInvoked(object sender, EventArgs e) + async void OnDeleteSwipeItemInvoked(object? sender, EventArgs e) { await DisplayAlertAsync("SwipeView", "Delete invoked.", "OK"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTimePickerPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTimePickerPage.xaml.cs index 53070066d656..c944bd9daa07 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTimePickerPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTimePickerPage.xaml.cs @@ -12,7 +12,7 @@ public iOSTimePickerPage() InitializeComponent(); } - void OnButtonClicked(object sender, EventArgs e) + void OnButtonClicked(object? sender, EventArgs e) { switch (timePicker.On().UpdateMode()) { diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTitleViewPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTitleViewPage.xaml.cs index 5f370facd790..15c576a5bcd3 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTitleViewPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTitleViewPage.xaml.cs @@ -12,7 +12,7 @@ public iOSTitleViewPage() _searchBar.Effects.Add(Effect.Resolve("XamarinDocs.SearchBarEffect")); } - void OnReturnButtonClicked(object sender, EventArgs e) + void OnReturnButtonClicked(object? sender, EventArgs e) { Navigation.PopAsync(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTranslucentNavigationBarPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTranslucentNavigationBarPage.xaml.cs index 4a5923a12535..d7c5722c0c2f 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTranslucentNavigationBarPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTranslucentNavigationBarPage.xaml.cs @@ -13,12 +13,12 @@ public iOSTranslucentNavigationBarPage() InitializeComponent(); } - void OnTranslucentNavigationBarButtonClicked(object sender, EventArgs e) + void OnTranslucentNavigationBarButtonClicked(object? sender, EventArgs e) { (this.Window!.Page as Microsoft.Maui.Controls.NavigationPage)!.On().SetIsNavigationBarTranslucent(!(this.Window!.Page as Microsoft.Maui.Controls.NavigationPage)!.On().IsNavigationBarTranslucent()); } - void OnReturnButtonClicked(object sender, EventArgs e) + void OnReturnButtonClicked(object? sender, EventArgs e) { Navigation.PopAsync(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTranslucentTabbedPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTranslucentTabbedPage.xaml.cs index b65ec80ce919..93a85dd07515 100644 --- a/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTranslucentTabbedPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTranslucentTabbedPage.xaml.cs @@ -11,7 +11,7 @@ public iOSTranslucentTabbedPage() InitializeComponent(); } - void OnToggleButtonClicked(object sender, EventArgs e) + void OnToggleButtonClicked(object? sender, EventArgs e) { switch (On().GetTranslucencyMode()) { @@ -27,7 +27,7 @@ void OnToggleButtonClicked(object sender, EventArgs e) } } - void OnReturnButtonClicked(object sender, EventArgs e) + void OnReturnButtonClicked(object? sender, EventArgs e) { Navigation.PopAsync(); } diff --git a/src/Controls/samples/Controls.Sample/Pages/SettingsPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/SettingsPage.xaml.cs index e3537f5cc27c..8b8ad33f9de8 100644 --- a/src/Controls/samples/Controls.Sample/Pages/SettingsPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/SettingsPage.xaml.cs @@ -11,12 +11,12 @@ public SettingsPage() InitializeComponent(); } - void OnTapGestureRecognizerTapped(object sender, EventArgs args) + void OnTapGestureRecognizerTapped(object? sender, EventArgs args) { Navigation.PopModalAsync(); } - void OnRTLToggled(object sender, ToggledEventArgs e) + void OnRTLToggled(object? sender, ToggledEventArgs e) { var mainPage = this.Window!.Page; diff --git a/src/Controls/samples/Controls.Sample/Pages/UserInterface/AnimationPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/UserInterface/AnimationPage.xaml.cs index f889f0256efa..4f97b84a808a 100644 --- a/src/Controls/samples/Controls.Sample/Pages/UserInterface/AnimationPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/UserInterface/AnimationPage.xaml.cs @@ -11,7 +11,7 @@ public AnimationsPage() InitializeComponent(); } - async void OnStartAnimationButtonClicked(object sender, EventArgs e) + async void OnStartAnimationButtonClicked(object? sender, EventArgs e) { SetIsEnabledButtonState(false, true); @@ -37,7 +37,7 @@ async void OnStartAnimationButtonClicked(object sender, EventArgs e) SetIsEnabledButtonState(true, false); } - void OnStartCustomAnimationButtonClicked(object sender, EventArgs e) + void OnStartCustomAnimationButtonClicked(object? sender, EventArgs e) { var parentAnimation = new Animation(); var scaleUpAnimation = new Animation(v => DotNetBotImage.Scale = v, 1, 2, Easing.SpringIn); @@ -51,7 +51,7 @@ void OnStartCustomAnimationButtonClicked(object sender, EventArgs e) parentAnimation.Commit(this, "CustomAnimation", 16, 4000, null, (v, c) => SetIsEnabledButtonState(true, false)); } - void OnCancelAnimationButtonClicked(object sender, EventArgs e) + void OnCancelAnimationButtonClicked(object? sender, EventArgs e) { Microsoft.Maui.Controls.ViewExtensions.CancelAnimations(DotNetBotImage); SetIsEnabledButtonState(true, false); From 7f2fdf6daabe082858f09d7ac8eb6716a84eab57 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 14 Jan 2026 17:40:27 +0100 Subject: [PATCH 12/13] Add RadioButtonContentGallery.xaml to Runtime inflator list (XSG nullability issue) --- .../samples/Controls.Sample/Maui.Controls.Sample.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj b/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj index 589dee412a63..00e5f3025caf 100644 --- a/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj +++ b/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj @@ -95,11 +95,12 @@ - + + From 37cfc0b0b080b86d4c69711f863ef8aabb102391 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Feb 2026 11:51:01 +0000 Subject: [PATCH 13/13] Fix device tests build: suppress CS0618 warning for deprecated XamlCompilation attribute (#33894) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Device tests were failing to build with CS0618 errors when the deprecated `[XamlCompilation]` attribute was treated as an error during CI builds. ## Changes - Added `#pragma warning disable/restore CS0618` around `[XamlCompilation]` attribute in `RadioButtonUsing.xaml.cs` - Follows the same suppression pattern used in sample projects that need to retain the deprecated attribute for testing purposes The attribute remains deprecated as intended but no longer breaks the build when warnings are treated as errors. --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rmarinho <1235097+rmarinho@users.noreply.github.com> --- src/Controls/tests/DeviceTests/Xaml/RadioButtonUsing.xaml.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Controls/tests/DeviceTests/Xaml/RadioButtonUsing.xaml.cs b/src/Controls/tests/DeviceTests/Xaml/RadioButtonUsing.xaml.cs index 5b4420d900aa..ecb38c34d6b3 100644 --- a/src/Controls/tests/DeviceTests/Xaml/RadioButtonUsing.xaml.cs +++ b/src/Controls/tests/DeviceTests/Xaml/RadioButtonUsing.xaml.cs @@ -3,7 +3,9 @@ namespace Microsoft.Maui.DeviceTests { +#pragma warning disable CS0618 // XamlCompilationAttribute is deprecated, remove this in .NET 12 [XamlCompilation(XamlCompilationOptions.Compile)] +#pragma warning restore CS0618 public partial class RadioButtonUsing : ContentPage { public RadioButtonUsing()