Skip to content

Commit

Permalink
Remove obsolete MauiWinUIApplication properties (#17667)
Browse files Browse the repository at this point in the history
* Remove obsolete MauiWinUIApplication properties

* - add better comments

* - ignore banned on winui generated xaml file
  • Loading branch information
PureWeen committed Sep 27, 2023
1 parent 0a05525 commit 9895399
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Expand Up @@ -184,3 +184,8 @@ indent_size = 2
end_of_line = lf
[*.{cmd, bat}]
end_of_line = crlf

# Ignore Banned APIs that get generated by the WinUI Xaml Generator
# This is currently being used for the banned Services/Application APIs
[**/obj/**/XamlTypeInfo.g.cs]
dotnet_diagnostic.RS0030.severity = none
2 changes: 2 additions & 0 deletions eng/BannedSymbols.txt
@@ -1,2 +1,4 @@
M:Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAddSingleton`2(Microsoft.Extensions.DependencyInjection.IServiceCollection);Use a Factory method to create the service instead
M:Android.Content.Res.ColorStateList.#ctor(System.Int32[][],System.Int32[]);Use Microsoft.Maui.PlatformInterop.Get*ColorStateList() Java methods instead
P:Microsoft.Maui.MauiWinUIApplication.Services;Use the IPlatformApplication.Current.Services instead
P:Microsoft.Maui.MauiWinUIApplication.Application;Use the IPlatformApplication.Current.Application instead
14 changes: 12 additions & 2 deletions src/Core/src/Platform/Windows/MauiWinUIApplication.cs
Expand Up @@ -61,14 +61,24 @@ protected override void OnLaunched(UI.Xaml.LaunchActivatedEventArgs args)

IApplication IPlatformApplication.Application => _application!;

[Obsolete("Use the IPlatformApplication.Current.Services instead.")]
// TODO NET9 MARK THESE AS OBSOLETE. We didn't mark them obsolete in NET8 because that
// was causing warnings to generate for our WinUI projects, so we need to workaround that
// before we mark this as obsolete.
/// <summary>
/// Use the IPlatformApplication.Current.Services instead.
/// </summary>
public IServiceProvider Services
{
get => _services!;
protected set => _services = value;
}

[Obsolete("Use the IPlatformApplication.Current.Application instead.")]
// TODO NET9 MARK THESE AS OBSOLETE. We didn't mark them obsolete in NET8 because that
// was causing warnings to generate for our WinUI projects, so we need to workaround that
// before we mark this as obsolete.
/// <summary>
/// Use the IPlatformApplication.Current.Application instead.
/// </summary>
public IApplication Application
{
get => _application!;
Expand Down

0 comments on commit 9895399

Please sign in to comment.