From 26c67720202287220a98e380cc7648ba2d567113 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Tue, 10 Jan 2023 10:45:42 +0200 Subject: [PATCH] fix(uap): Fix generators should not run under uap builds --- .../Helpers/PlatformHelper.cs | 9 +-------- .../Content/Uno.UI.SourceGenerators.props | 16 +++++++--------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/SourceGenerators/SourceGeneratorHelpers/Helpers/PlatformHelper.cs b/src/SourceGenerators/SourceGeneratorHelpers/Helpers/PlatformHelper.cs index 0fced12d4476..33dfa82ed56c 100644 --- a/src/SourceGenerators/SourceGeneratorHelpers/Helpers/PlatformHelper.cs +++ b/src/SourceGenerators/SourceGeneratorHelpers/Helpers/PlatformHelper.cs @@ -15,23 +15,16 @@ public class PlatformHelper { public static bool IsValidPlatform(GeneratorExecutionContext context) { - var evaluatedValue = context.GetMSBuildPropertyValue("TargetPlatformIdentifier"); - var windowsAppSDKWinUI = context.GetMSBuildPropertyValue("WindowsAppSDKWinUI"); var projectTypeGuids = context.GetMSBuildPropertyValue("ProjectTypeGuidsProperty"); - var isUAP = evaluatedValue?.Equals("UAP", StringComparison.OrdinalIgnoreCase) ?? false; - // Those two checks are now required since VS 16.9 which enables source generators by default // and the uno targets files are not present for uap targets. var isWindowsRuntimeApplicationOutput = context.Compilation.Options.OutputKind == OutputKind.WindowsRuntimeApplication; var isWindowsRuntimeMetadataOutput = context.Compilation.Options.OutputKind == OutputKind.WindowsRuntimeMetadata; - var isWinAppSDK = windowsAppSDKWinUI?.Equals("True", StringComparison.OrdinalIgnoreCase) ?? false; var isNetCoreDesktop = projectTypeGuids?.Equals("{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", StringComparison.OrdinalIgnoreCase) ?? false; - return !isUAP - && !isWinAppSDK - && !isNetCoreDesktop + return !isNetCoreDesktop && !isWindowsRuntimeMetadataOutput && !isWindowsRuntimeApplicationOutput; } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props b/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props index 4d0fe0705677..3742f1eab118 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props @@ -69,7 +69,6 @@ - @@ -186,7 +185,7 @@ - @@ -363,9 +362,9 @@ - @@ -451,10 +450,9 @@ Text="Uno.UI is using Uno.SourceGenerators" /> - - + + + <_AnalyzerToRemove Include="@(Analyzer)" Condition="'%(FileName)'=='Uno.UI.SourceGenerators'" />