From 0aeac14134846280ad0d90998ff2e684954e0732 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Thu, 28 Mar 2024 16:41:06 +0100 Subject: [PATCH 1/5] Enable analyzers wherever possible without any changes --- .../Microsoft.AspNetCore.Components.WebView.Maui.csproj | 6 ++++++ ...rosoft.AspNetCore.Components.WebView.WindowsForms.csproj | 6 ++++++ .../Wpf/Microsoft.AspNetCore.Components.WebView.Wpf.csproj | 6 ++++++ src/Controls/Foldable/src/Controls.Foldable.csproj | 5 +++++ src/Controls/Maps/src/Controls.Maps.csproj | 6 ++++++ src/Controls/src/NuGet/Controls.NuGet.csproj | 6 ++++++ src/Core/maps/src/Maps.csproj | 6 ++++++ src/Core/src/Core.csproj | 2 +- src/Graphics/src/Graphics.Skia.WPF/Graphics.Skia.WPF.csproj | 6 ++++++ src/Graphics/src/Graphics.Skia/Graphics.Skia.csproj | 6 ++++++ src/Graphics/src/Graphics.Win2D/Graphics.Win2D.csproj | 6 ++++++ src/Graphics/src/Graphics/Graphics.csproj | 6 ++++++ 12 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/BlazorWebView/src/Maui/Microsoft.AspNetCore.Components.WebView.Maui.csproj b/src/BlazorWebView/src/Maui/Microsoft.AspNetCore.Components.WebView.Maui.csproj index 71e06b830a2e..9949c79dbd61 100644 --- a/src/BlazorWebView/src/Maui/Microsoft.AspNetCore.Components.WebView.Maui.csproj +++ b/src/BlazorWebView/src/Maui/Microsoft.AspNetCore.Components.WebView.Maui.csproj @@ -7,6 +7,12 @@ true + + true + true + true + + true diff --git a/src/BlazorWebView/src/WindowsForms/Microsoft.AspNetCore.Components.WebView.WindowsForms.csproj b/src/BlazorWebView/src/WindowsForms/Microsoft.AspNetCore.Components.WebView.WindowsForms.csproj index 679fc335bcbc..3008e21d112f 100644 --- a/src/BlazorWebView/src/WindowsForms/Microsoft.AspNetCore.Components.WebView.WindowsForms.csproj +++ b/src/BlazorWebView/src/WindowsForms/Microsoft.AspNetCore.Components.WebView.WindowsForms.csproj @@ -12,6 +12,12 @@ true + + true + true + true + + true diff --git a/src/BlazorWebView/src/Wpf/Microsoft.AspNetCore.Components.WebView.Wpf.csproj b/src/BlazorWebView/src/Wpf/Microsoft.AspNetCore.Components.WebView.Wpf.csproj index a4b722ce6ab3..6a1c608e8ab2 100644 --- a/src/BlazorWebView/src/Wpf/Microsoft.AspNetCore.Components.WebView.Wpf.csproj +++ b/src/BlazorWebView/src/Wpf/Microsoft.AspNetCore.Components.WebView.Wpf.csproj @@ -12,6 +12,12 @@ true + + true + true + true + + true diff --git a/src/Controls/Foldable/src/Controls.Foldable.csproj b/src/Controls/Foldable/src/Controls.Foldable.csproj index 8f2e10d0d09e..08ff3ce30ab3 100644 --- a/src/Controls/Foldable/src/Controls.Foldable.csproj +++ b/src/Controls/Foldable/src/Controls.Foldable.csproj @@ -9,6 +9,11 @@ $(NoWarn);CS1591 true + + true + true + true + True diff --git a/src/Controls/Maps/src/Controls.Maps.csproj b/src/Controls/Maps/src/Controls.Maps.csproj index 5576732cada8..1b4fe0949f70 100644 --- a/src/Controls/Maps/src/Controls.Maps.csproj +++ b/src/Controls/Maps/src/Controls.Maps.csproj @@ -12,6 +12,12 @@ $(WarningsAsErrors);CS1591 + + true + true + true + + True diff --git a/src/Controls/src/NuGet/Controls.NuGet.csproj b/src/Controls/src/NuGet/Controls.NuGet.csproj index 8492370d2ffe..46d42f9eda67 100644 --- a/src/Controls/src/NuGet/Controls.NuGet.csproj +++ b/src/Controls/src/NuGet/Controls.NuGet.csproj @@ -8,6 +8,12 @@ false + + true + true + true + + true diff --git a/src/Core/maps/src/Maps.csproj b/src/Core/maps/src/Maps.csproj index fe599049d654..82a864dd114a 100644 --- a/src/Core/maps/src/Maps.csproj +++ b/src/Core/maps/src/Maps.csproj @@ -10,6 +10,12 @@ $(NoWarn);CS1591;RS0041;RS0026;RS0027 + + true + true + true + + .NET MAUI Maps provides a map control for .NET MAUI apps. This only contains the core types. If you want the Map control, please install the Microsoft.Maui.Controls.Maps package. diff --git a/src/Core/src/Core.csproj b/src/Core/src/Core.csproj index c7c23ec1455a..e5f3c9ed32a8 100644 --- a/src/Core/src/Core.csproj +++ b/src/Core/src/Core.csproj @@ -11,7 +11,7 @@ $(NoWarn);CS1591;RS0041;RS0026;RS0027 - + true true true diff --git a/src/Graphics/src/Graphics.Skia.WPF/Graphics.Skia.WPF.csproj b/src/Graphics/src/Graphics.Skia.WPF/Graphics.Skia.WPF.csproj index 06db2242d315..91c53ce8e60b 100644 --- a/src/Graphics/src/Graphics.Skia.WPF/Graphics.Skia.WPF.csproj +++ b/src/Graphics/src/Graphics.Skia.WPF/Graphics.Skia.WPF.csproj @@ -11,6 +11,12 @@ $(NoWarn);RS0041 + + true + true + true + + diff --git a/src/Graphics/src/Graphics.Skia/Graphics.Skia.csproj b/src/Graphics/src/Graphics.Skia/Graphics.Skia.csproj index 2ed804e4de21..4822a52ee844 100644 --- a/src/Graphics/src/Graphics.Skia/Graphics.Skia.csproj +++ b/src/Graphics/src/Graphics.Skia/Graphics.Skia.csproj @@ -9,6 +9,12 @@ $(NoWarn);CS1591;RS0026;RS0027;RS0041 + + true + true + true + + true diff --git a/src/Graphics/src/Graphics.Win2D/Graphics.Win2D.csproj b/src/Graphics/src/Graphics.Win2D/Graphics.Win2D.csproj index fd4aeee39530..dd910c2c61fe 100644 --- a/src/Graphics/src/Graphics.Win2D/Graphics.Win2D.csproj +++ b/src/Graphics/src/Graphics.Win2D/Graphics.Win2D.csproj @@ -9,6 +9,12 @@ $(DefineConstants);MAUI_GRAPHICS_WIN2D + + true + true + true + + true diff --git a/src/Graphics/src/Graphics/Graphics.csproj b/src/Graphics/src/Graphics/Graphics.csproj index ccf351316238..7411afdce822 100644 --- a/src/Graphics/src/Graphics/Graphics.csproj +++ b/src/Graphics/src/Graphics/Graphics.csproj @@ -13,6 +13,12 @@ $(NoWarn);CS1591;RS0026;RS0027;RS0041 + + true + true + true + + true From 74335b4d38234018bdbe7deed032ded066771c87 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Thu, 28 Mar 2024 16:41:37 +0100 Subject: [PATCH 2/5] Change IsTrimmable to IsAotCompatible --- src/Compatibility/Core/src/Compatibility.csproj | 2 +- src/Essentials/src/Essentials.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Compatibility/Core/src/Compatibility.csproj b/src/Compatibility/Core/src/Compatibility.csproj index 9c185620b649..23b3529955a2 100644 --- a/src/Compatibility/Core/src/Compatibility.csproj +++ b/src/Compatibility/Core/src/Compatibility.csproj @@ -8,7 +8,7 @@ iOS\ Windows\ Tizen\ - true + true true true $(NoWarn);CS1591 diff --git a/src/Essentials/src/Essentials.csproj b/src/Essentials/src/Essentials.csproj index 1573d64a1250..03fee6525ee6 100644 --- a/src/Essentials/src/Essentials.csproj +++ b/src/Essentials/src/Essentials.csproj @@ -5,7 +5,7 @@ Microsoft.Maui.Essentials false BI1234 - true + true true $(NoWarn);NU5104;RS0041;RS0026 $(WarningsAsErrors);CS1591 From 17729789aa3fb36291d4c9b8828ed2edeb9f0845 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Thu, 28 Mar 2024 22:23:02 +0100 Subject: [PATCH 3/5] Windows Essentials are just Trimmable, not AOT compatible --- src/Essentials/src/Essentials.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Essentials/src/Essentials.csproj b/src/Essentials/src/Essentials.csproj index 03fee6525ee6..12b82787dc28 100644 --- a/src/Essentials/src/Essentials.csproj +++ b/src/Essentials/src/Essentials.csproj @@ -5,7 +5,8 @@ Microsoft.Maui.Essentials false BI1234 - true + true + true true $(NoWarn);NU5104;RS0041;RS0026 $(WarningsAsErrors);CS1591 From 81f208bda462cbb9351570b9a1f18f3bb17e2c8f Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Mon, 8 Apr 2024 13:56:33 +0200 Subject: [PATCH 4/5] Avoid using non-generic Enum.GetValues on Tizen --- src/Compatibility/Core/src/Tizen/ResourcePath.cs | 2 +- .../src/Core/Platform/Tizen/Extensions/ImageExtensions.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Compatibility/Core/src/Tizen/ResourcePath.cs b/src/Compatibility/Core/src/Tizen/ResourcePath.cs index 47671abfd080..b1fee46baf59 100644 --- a/src/Compatibility/Core/src/Tizen/ResourcePath.cs +++ b/src/Compatibility/Core/src/Tizen/ResourcePath.cs @@ -14,7 +14,7 @@ public static string GetPath(string res) return res; } - foreach (AppFW.ResourceManager.Category category in Enum.GetValues(typeof(AppFW.ResourceManager.Category))) + foreach (AppFW.ResourceManager.Category category in Enum.GetValues()) { var path = AppFW.ResourceManager.TryGetPath(category, res); diff --git a/src/Controls/src/Core/Platform/Tizen/Extensions/ImageExtensions.cs b/src/Controls/src/Core/Platform/Tizen/Extensions/ImageExtensions.cs index b90c7ed5b90f..366409dab67a 100644 --- a/src/Controls/src/Core/Platform/Tizen/Extensions/ImageExtensions.cs +++ b/src/Controls/src/Core/Platform/Tizen/Extensions/ImageExtensions.cs @@ -64,7 +64,7 @@ static string GetPath(string res) return res; } - foreach (AppFW.ResourceManager.Category category in Enum.GetValues(typeof(AppFW.ResourceManager.Category))) + foreach (AppFW.ResourceManager.Category category in Enum.GetValues()) { foreach (var file in new[] { res, res + ".jpg", res + ".png", res + ".gif" }) { From 2d4a1bdabf24a22b8df1e32d4535ebc89f6f7308 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Mon, 8 Apr 2024 14:02:05 +0200 Subject: [PATCH 5/5] Ignore SingleFileAnalyzer warnings in BlazorWebView WPF and WinForms --- src/BlazorWebView/src/WindowsForms/BlazorWebView.cs | 2 ++ src/BlazorWebView/src/Wpf/BlazorWebView.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs b/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs index 0af5f6fc0198..2d819bb965f1 100644 --- a/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs +++ b/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs @@ -170,7 +170,9 @@ private void StartWebViewCoreIfPossible() // We assume the host page is always in the root of the content directory, because it's // unclear there's any other use case. We can add more options later if so. string appRootDir; +#pragma warning disable IL3000 // 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'. var entryAssemblyLocation = Assembly.GetEntryAssembly()?.Location; +#pragma warning restore IL3000 if (!string.IsNullOrEmpty(entryAssemblyLocation)) { appRootDir = Path.GetDirectoryName(entryAssemblyLocation)!; diff --git a/src/BlazorWebView/src/Wpf/BlazorWebView.cs b/src/BlazorWebView/src/Wpf/BlazorWebView.cs index 98d6a68ca62f..ad7747a5f7dd 100644 --- a/src/BlazorWebView/src/Wpf/BlazorWebView.cs +++ b/src/BlazorWebView/src/Wpf/BlazorWebView.cs @@ -255,7 +255,9 @@ private void StartWebViewCoreIfPossible() // We assume the host page is always in the root of the content directory, because it's // unclear there's any other use case. We can add more options later if so. string appRootDir; +#pragma warning disable IL3000 // 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'. var entryAssemblyLocation = Assembly.GetEntryAssembly()?.Location; +#pragma warning restore IL3000 if (!string.IsNullOrEmpty(entryAssemblyLocation)) { appRootDir = Path.GetDirectoryName(entryAssemblyLocation)!;