Skip to content

Commit a2f8ec9

Browse files
Fix Controls.Sample build with XSG default
- Add NoWarn for CS0612 (obsolete APIs usage is intentional in sample) - 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)
1 parent 51cb02b commit a2f8ec9

125 files changed

Lines changed: 447 additions & 445 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Controls/samples/Controls.Sample.Profiling/Startup.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
using Microsoft.Maui;
22
using Microsoft.Maui.Controls.Hosting;
3-
using Microsoft.Maui.Controls.Xaml;
43
using Microsoft.Maui.Hosting;
54

6-
#pragma warning disable CS0618 // XamlCompilationAttribute is deprecated, remove this in .NET 12
7-
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
8-
#pragma warning restore CS0618
9-
105
namespace Maui.Controls.Sample.Profiling
116
{
127
public static class MauiProgram

src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
<RootNamespace>Maui.Controls.Sample</RootNamespace>
1111
<AssemblyName>Maui.Controls.Sample</AssemblyName>
1212
<IsPackable>false</IsPackable>
13-
<NoWarn>$(NoWarn);CA1416;CS0618;XC0618;XC0022</NoWarn>
13+
<NoWarn>$(NoWarn);CA1416;CS0612;CS0618;XC0618;XC0022</NoWarn>
1414
<Nullable>enable</Nullable>
15-
<!-- This sample project uses deprecated APIs for demonstration - use Runtime inflation -->
16-
<MauiXamlInflator>Runtime</MauiXamlInflator>
1715
<!-- Disable multi-RID builds to workaround a parallel build issue -->
1816
<RuntimeIdentifier Condition="$(TargetFramework.Contains('-maccatalyst'))">maccatalyst-x64</RuntimeIdentifier>
1917
<RuntimeIdentifier Condition="$(TargetFramework.Contains('-maccatalyst')) and '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'arm64'">maccatalyst-arm64</RuntimeIdentifier>
@@ -91,5 +89,14 @@
9189

9290
<Import Project="$(MauiSrcDirectory)Maui.InTree.props" Condition=" '$(UseMaui)' != 'true' " />
9391

92+
<!-- These XAML files have XSG parsing issues, use Runtime inflator until fixed -->
93+
<!-- Must be after Maui.InTree.props to properly override the globbed items -->
94+
<ItemGroup>
95+
<MauiXaml Remove="Pages/Controls/SwipeViewGalleries/*.xaml;Pages/Others/StyleSheetsPage.xaml;Pages/Others/TwoPaneViewPage.xaml;Pages/Controls/ButtonPage.xaml" />
96+
<MauiXaml Include="Pages/Controls/SwipeViewGalleries/*.xaml" Inflator="Runtime" />
97+
<MauiXaml Include="Pages/Others/StyleSheetsPage.xaml" Inflator="Runtime" />
98+
<MauiXaml Include="Pages/Others/TwoPaneViewPage.xaml" Inflator="Runtime" />
99+
<MauiXaml Include="Pages/Controls/ButtonPage.xaml" Inflator="Runtime" />
100+
</ItemGroup>
94101

95102
</Project>

src/Controls/samples/Controls.Sample/Pages/AppShell.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public AppShell()
1818

1919
public string ShellTitle { get; set; } = "Welcome to Shell";
2020

21-
void OnChangeTabBarBackgroundColor(object sender, EventArgs e)
21+
void OnChangeTabBarBackgroundColor(object? sender, EventArgs e)
2222
{
2323
var random = new Random();
2424

src/Controls/samples/Controls.Sample/Pages/Compatibility/ListViewGalleries/ListViewContextActions.xaml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ public ListViewContextActions()
1717
.ToList();
1818
}
1919

20-
private void OnDetailClicked(object sender, EventArgs e)
20+
private void OnDetailClicked(object? sender, EventArgs e)
2121
{
22-
var mi = ((MenuItem)sender);
22+
var mi = ((MenuItem)sender!);
2323
DisplayAlertAsync("Detail Action", $"Details for item {mi.CommandParameter}", "OK");
2424
}
2525

26-
private void OnDeleteClicked(object sender, EventArgs e)
26+
private void OnDeleteClicked(object? sender, EventArgs e)
2727
{
28-
var mi = ((MenuItem)sender);
28+
var mi = ((MenuItem)sender!);
2929
DisplayAlertAsync("Delete Action", $"Deleting item {mi.CommandParameter}!", "OK");
3030
}
3131

src/Controls/samples/Controls.Sample/Pages/Compatibility/TabbedPageGalleryMainPage.xaml.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void SetNewMainPage(Page page)
2222
Application.Current!.Windows[0].Page = page;
2323
}
2424

25-
void OnTabbedPageAsRoot(object sender, EventArgs e)
25+
void OnTabbedPageAsRoot(object? sender, EventArgs e)
2626
{
2727
var topTabs =
2828
new TabbedPage()
@@ -37,7 +37,7 @@ void OnTabbedPageAsRoot(object sender, EventArgs e)
3737
SetNewMainPage(topTabs);
3838
}
3939

40-
void OnSetToBottomTabs(object sender, EventArgs e)
40+
void OnSetToBottomTabs(object? sender, EventArgs e)
4141
{
4242
var bottomTabs = new TabbedPage()
4343
{
@@ -53,60 +53,60 @@ void OnSetToBottomTabs(object sender, EventArgs e)
5353
this.Window!.Page = bottomTabs;
5454
}
5555

56-
void OnChangeTabIndex(object sender, EventArgs e)
56+
void OnChangeTabIndex(object? sender, EventArgs e)
5757
{
5858
GetTabbedPage().CurrentPage = GetTabbedPage().Children[1];
5959
}
6060

61-
void OnToggleTabBar(object sender, EventArgs e)
61+
void OnToggleTabBar(object? sender, EventArgs e)
6262
{
6363
if ((GetTabbedPage().BarBackground as SolidColorBrush)?.Color == SolidColorBrush.Purple.Color)
6464
GetTabbedPage().BarBackground = null;
6565
else
6666
GetTabbedPage().BarBackground = SolidColorBrush.Purple;
6767
}
6868

69-
void OnToggleTabBarTextColor(object sender, EventArgs e)
69+
void OnToggleTabBarTextColor(object? sender, EventArgs e)
7070
{
7171
if (GetTabbedPage().BarTextColor == Colors.Green)
7272
GetTabbedPage().BarTextColor = null;
7373
else
7474
GetTabbedPage().BarTextColor = Colors.Green;
7575
}
7676

77-
void OnToggleTabItemUnSelectedColor(object sender, EventArgs e)
77+
void OnToggleTabItemUnSelectedColor(object? sender, EventArgs e)
7878
{
7979
if (GetTabbedPage().UnselectedTabColor == Colors.Blue)
8080
GetTabbedPage().UnselectedTabColor = null;
8181
else
8282
GetTabbedPage().UnselectedTabColor = Colors.Blue;
8383
}
8484

85-
void OnToggleTabItemSelectedColor(object sender, EventArgs e)
85+
void OnToggleTabItemSelectedColor(object? sender, EventArgs e)
8686
{
8787
if (GetTabbedPage().SelectedTabColor == Colors.Pink)
8888
GetTabbedPage().SelectedTabColor = null;
8989
else
9090
GetTabbedPage().SelectedTabColor = Colors.Pink;
9191
}
9292

93-
void OnRemoveTab(object sender, EventArgs e)
93+
void OnRemoveTab(object? sender, EventArgs e)
9494
{
9595
if (GetTabbedPage().Children.LastOrDefault() is TabbedPageGalleryMainPage mainPage)
9696
{
9797
GetTabbedPage().Children.Remove(mainPage);
9898
}
9999
}
100100

101-
void OnRemoveAllTabs(object sender, EventArgs e)
101+
void OnRemoveAllTabs(object? sender, EventArgs e)
102102
{
103103
while (GetTabbedPage().Children.LastOrDefault() is TabbedPageGalleryMainPage mainPage)
104104
{
105105
GetTabbedPage().Children.Remove(mainPage);
106106
}
107107
}
108108

109-
void OnAddTab(object sender, EventArgs e)
109+
void OnAddTab(object? sender, EventArgs e)
110110
{
111111
GetTabbedPage()
112112
.Children

src/Controls/samples/Controls.Sample/Pages/Controls/ButtonPage.xaml.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ public ButtonPage()
1919
BindingContext = new ButtonPageViewModel();
2020
}
2121

22-
void OnButtonClicked(object sender, System.EventArgs e)
22+
void OnButtonClicked(object? sender, System.EventArgs e)
2323
{
2424
Debug.WriteLine("Clicked");
2525
}
2626

27-
void Button_Clicked(System.Object sender, System.EventArgs e)
27+
void Button_Clicked(System.Object? sender, System.EventArgs e)
2828
{
2929
if (ImageSourceButton.ImageSource is null)
3030
{
@@ -36,7 +36,7 @@ void Button_Clicked(System.Object sender, System.EventArgs e)
3636
}
3737
}
3838

39-
void OnPositionChange(object sender, System.EventArgs e)
39+
void OnPositionChange(object? sender, System.EventArgs e)
4040
{
4141
var newPosition = ((int)positionChange.ContentLayout.Position) + 1;
4242

@@ -48,21 +48,21 @@ void OnPositionChange(object sender, System.EventArgs e)
4848
positionChange.ContentLayout.Spacing);
4949
}
5050

51-
void OnDecreaseSpacing(object sender, System.EventArgs e)
51+
void OnDecreaseSpacing(object? sender, System.EventArgs e)
5252
{
5353
positionChange.ContentLayout =
5454
new Button.ButtonContentLayout(positionChange.ContentLayout.Position,
5555
positionChange.ContentLayout.Spacing - 1);
5656
}
5757

58-
void OnIncreasingSpacing(object sender, System.EventArgs e)
58+
void OnIncreasingSpacing(object? sender, System.EventArgs e)
5959
{
6060
positionChange.ContentLayout =
6161
new Button.ButtonContentLayout(positionChange.ContentLayout.Position,
6262
positionChange.ContentLayout.Spacing + 1);
6363
}
6464

65-
void OnLineBreakModeButtonClicked(object sender, System.EventArgs e)
65+
void OnLineBreakModeButtonClicked(object? sender, System.EventArgs e)
6666
{
6767
LineBreakModeButton.LineBreakMode = ImageLineBreakModeButton.LineBreakMode = SelectLineBreakMode();
6868
}
@@ -90,13 +90,13 @@ LineBreakMode SelectLineBreakMode()
9090

9191
int _backgroundCount;
9292

93-
void OnBackgroundButtonClicked(object sender, System.EventArgs e)
93+
void OnBackgroundButtonClicked(object? sender, System.EventArgs e)
9494
{
9595
BackgroundButton.Text = $"Background tapped {_backgroundCount} times";
9696
_backgroundCount++;
9797
}
9898

99-
void OnChangeBrushButtonClicked(System.Object sender, System.EventArgs e)
99+
void OnChangeBrushButtonClicked(System.Object? sender, System.EventArgs e)
100100
{
101101
UpdateButtonBrush();
102102
}

src/Controls/samples/Controls.Sample/Pages/Controls/CheckBoxPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public CheckBoxPage()
1313
UpdateControls();
1414
}
1515

16-
void OnChangeIsCheckedButtonClicked(object sender, EventArgs e)
16+
void OnChangeIsCheckedButtonClicked(object? sender, EventArgs e)
1717
{
1818
_isGreen = !_isGreen;
1919
UpdateControls();

src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/CarouselViewGalleries/CarouselViewPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public CarouselViewPage()
99
InitializeComponent();
1010
}
1111

12-
async void TapGestureRecognizer_Tapped(object sender, EventArgs e)
12+
async void TapGestureRecognizer_Tapped(object? sender, EventArgs e)
1313
{
1414
await DisplayAlertAsync("Item", "Tapped", "Successfully");
1515
}

src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/DataTemplateSelectorGalleries/VariedSizeDataTemplateSelectorGallery.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ public bool ShouldTriggerReset
6464
set => SetValue(ref _shouldTriggerReset, value);
6565
}
6666

67-
void Insert_OnClicked(object sender, EventArgs e)
67+
void Insert_OnClicked(object? sender, EventArgs e)
6868
{
6969
if (!IsValid(out var index))
7070
return;
7171

7272
Items.Insert(index, CreateDrink());
7373
}
7474

75-
void Add_OnClicked(object sender, EventArgs e)
75+
void Add_OnClicked(object? sender, EventArgs e)
7676
{
7777
if (!IsValid(out var _))
7878
return;
@@ -89,7 +89,7 @@ void SetValue<T>(ref T backingField, in T value, [CallerMemberName] string calle
8989
OnPropertyChanged(callerName);
9090
}
9191

92-
void Remove_OnClicked(object sender, EventArgs e)
92+
void Remove_OnClicked(object? sender, EventArgs e)
9393
{
9494
if (!IsValid(out var index))
9595
return;

src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/EmptyViewGalleries/EmptyViewRTLGallery.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public EmptyViewRTLGallery()
2222
SearchBar.SearchCommand = new Command(() => _demoFilteredItemSource.FilterItems(SearchBar.Text));
2323
}
2424

25-
void OnPickerSelectedIndexChanged(object sender, EventArgs e)
25+
void OnPickerSelectedIndexChanged(object? sender, EventArgs e)
2626
{
2727
switch (Picker.SelectedIndex)
2828
{

0 commit comments

Comments
 (0)