Context: dotnet#3018
PR dotnet#3108 was a good start in enabling implicit C# global usings.
However, there were a couple of issues to work through:
1. There is a `GlobalUsings.cs` file. Can we do this in MSBuild, so
it's just there by default? I added:
<ItemGroup Condition=" '$(UseMaui)' == 'true' and ('$(ImplicitUsings)' == 'true' or '$(ImplicitUsings)' == 'enable') ">
<!-- %(Sdk) is only here if something later needs to identify these -->
<Using Include="Microsoft.Extensions.DependencyInjection" Sdk="Maui" />
<Using Include="Microsoft.Maui" Sdk="Maui" />
<Using Include="Microsoft.Maui.Controls" Sdk="Maui" />
<Using Include="Microsoft.Maui.Controls.Hosting" Sdk="Maui" />
<Using Include="Microsoft.Maui.Controls.Xaml" Sdk="Maui" />
<Using Include="Microsoft.Maui.Graphics" Sdk="Maui" />
<Using Include="Microsoft.Maui.Essentials" Sdk="Maui" />
<Using Include="Microsoft.Maui.Hosting" Sdk="Maui" />
</ItemGroup>
2. The platform-specific usings were not cleared. So types like
`Microsoft.Maui.Controls.Application` could conflict with
`Android.App.Application`.
To solve this, I added a `%(Platform)` metadata in the Android, iOS,
macOS, MacCatalyst, and tvOS workloads:
<Using Include="Android.App" Platform="Android" />
<Using Include="Android.Widget" Platform="Android" />
<Using Include="Android.OS.Bundle" Alias="Bundle" Platform="Android" />
Then in .NET MAUI's MSBuild targets we can do:
<ItemGroup Condition=" '$(UseMaui)' == 'true' and '$(MauiEnablePlatformUsings)' != 'true' and ('$(ImplicitUsings)' == 'true' or '$(ImplicitUsings)' == 'enable') ">
<Using Remove="@(Using->HasMetadata('Platform'))" />
</ItemGroup>
I created `$(MauiEnablePlatformUsings)`, just in case someone ever
needs to turn this off.
I updated the templates to specify `ImplicitUsings=enable`.
I updated `Controls.Sample.Tests.csproj`, as it was a .NET 6 project.
We probably can't update the other samples yet, because there are
Xamarin projects that would not support C# 10 language features.