diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs index d0b5ac652ef3..0f29ef6dbd5a 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs @@ -16,8 +16,8 @@ namespace Uno.UI.SourceGenerators.Tests.DependencyObjectGeneratorTests; [TestClass] public class Given_DependencyObjectGenerator { - private static readonly ReferenceAssemblies _net80Android = ReferenceAssemblies.Net.Net80Android.AddPackages([new PackageIdentity("Uno.Diagnostics.Eventing", "2.1.0")]); - private static readonly ReferenceAssemblies _net80 = ReferenceAssemblies.Net.Net80.AddPackages([new PackageIdentity("Uno.Diagnostics.Eventing", "2.1.0")]); + private static readonly ReferenceAssemblies _refAsmAndroid = _Dotnet.CurrentAndroid.ReferenceAssemblies.AddPackages([new PackageIdentity("Uno.Diagnostics.Eventing", "2.1.0")]); + private static readonly ReferenceAssemblies _refAsm = _Dotnet.Current.ReferenceAssemblies.AddPackages([new PackageIdentity("Uno.Diagnostics.Eventing", "2.1.0")]); private const string Configuration = #if DEBUG @@ -26,16 +26,25 @@ public class Given_DependencyObjectGenerator "Release"; #endif - private const string TFM = "net8.0"; + private const string TFMPrevious = "net8.0"; + private const string TFMCurrent = "net9.0"; private static MetadataReference[] BuildUnoReferences(bool isAndroid) { string[] availableTargets = isAndroid - ? [Path.Combine("Uno.UI.netcoremobile", Configuration, $"{TFM}-android")] + ? [ + Path.Combine("Uno.UI.netcoremobile", Configuration, $"{TFMPrevious}-android"), + Path.Combine("Uno.UI.netcoremobile", Configuration, $"{TFMCurrent}-android"), + ] : [ - Path.Combine("Uno.UI.Skia", Configuration, TFM), - Path.Combine("Uno.UI.Reference", Configuration, TFM), - Path.Combine("Uno.UI.Tests", Configuration, TFM), + // On CI the test assemblies set must be first, as it contains all + // dependent assemblies, which the other platforms don't (see DisablePrivateProjectReference). + Path.Combine("Uno.UI.Tests", Configuration, TFMPrevious), + Path.Combine("Uno.UI.Reference", Configuration, TFMPrevious), + Path.Combine("Uno.UI.Skia", Configuration, TFMPrevious), + Path.Combine("Uno.UI.Tests", Configuration, TFMCurrent), + Path.Combine("Uno.UI.Reference", Configuration, TFMCurrent), + Path.Combine("Uno.UI.Skia", Configuration, TFMCurrent), ]; var unoUIBase = Path.Combine( @@ -70,7 +79,7 @@ private async Task TestAndroid(string testCode, params DiagnosticResult[] expect { Sources = { testCode }, }, - ReferenceAssemblies = _net80Android, + ReferenceAssemblies = _refAsmAndroid, }; test.TestState.AdditionalReferences.AddRange(BuildUnoReferences(isAndroid: true)); @@ -81,7 +90,7 @@ private async Task TestAndroid(string testCode, params DiagnosticResult[] expect [TestMethod] public async Task TestAndroidViewImplementingDependencyObject() { - await TestAndroid(""" + var source = """ using Android.Content; using Windows.UI.Core; using Microsoft.UI.Dispatching; @@ -92,7 +101,7 @@ public class C : Android.Views.View, DependencyObject public C(Context context) : base(context) { } - + public CoreDispatcher Dispatcher { get; } public DispatcherQueue DispatcherQueue { get; } public object GetValue(DependencyProperty dp) => null; @@ -103,9 +112,12 @@ public void ClearValue(DependencyProperty dp) { } public long RegisterPropertyChangedCallback(DependencyProperty dp, DependencyPropertyChangedCallback callback) => 0; public void UnregisterPropertyChangedCallback(DependencyProperty dp, long token) { } } - """, - // /0/Test0.cs(5,14): error Uno0003: 'Android.Views.View' shouldn't implement 'DependencyObject'. Inherit 'FrameworkElement' instead. - DiagnosticResult.CompilerError("Uno0003").WithSpan(6, 14, 6, 15).WithArguments("Android.Views.View")); + """; + + await TestAndroid( + source, + // /0/Test0.cs(5,14): error Uno0003: 'Android.Views.View' shouldn't implement 'DependencyObject'. Inherit 'FrameworkElement' instead. + DiagnosticResult.CompilerError("Uno0003").WithSpan(6, 14, 6, 15).WithArguments("Android.Views.View")); } [TestMethod] @@ -341,7 +353,7 @@ public void SuspendBindings() => """, Encoding.UTF8)) } } }, - ReferenceAssemblies = _net80, + ReferenceAssemblies = _refAsm, }; test.TestState.AdditionalReferences.AddRange(BuildUnoReferences(isAndroid: false)); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyPropertyGeneratorTests/Given_DependencyPropertyGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyPropertyGeneratorTests/Given_DependencyPropertyGenerator.cs index 91c6894298cb..117a75dd2674 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyPropertyGeneratorTests/Given_DependencyPropertyGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyPropertyGeneratorTests/Given_DependencyPropertyGenerator.cs @@ -124,7 +124,7 @@ partial class Owner } } }, - ReferenceAssemblies = ReferenceAssemblies.Net.Net80.AddPackages(ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))), + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), }; await test.RunAsync(); @@ -251,7 +251,7 @@ partial class Owner } } }, - ReferenceAssemblies = ReferenceAssemblies.Net.Net80.AddPackages(ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))), + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), }; await test.RunAsync(); @@ -376,7 +376,7 @@ private static void OnMyValueBackingFieldUpdate(object instance, object newValue } } }, - ReferenceAssemblies = ReferenceAssemblies.Net.Net80.AddPackages(ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))), + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), }; test.ExpectedDiagnostics.Add( diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/ImplementedRoutedEventsGeneratorTests/Given_ImplementedRoutedEventsGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/ImplementedRoutedEventsGeneratorTests/Given_ImplementedRoutedEventsGenerator.cs index aa2a31423661..580edb09ab67 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/ImplementedRoutedEventsGeneratorTests/Given_ImplementedRoutedEventsGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/ImplementedRoutedEventsGeneratorTests/Given_ImplementedRoutedEventsGenerator.cs @@ -12,7 +12,7 @@ namespace Uno.UI.SourceGenerators.Tests.ImplementedRoutedEventsGeneratorTests [TestClass] public class Given_ImplementedRoutedEventsGenerator { - private static readonly ReferenceAssemblies s_defaultWithUno = ReferenceAssemblies.Net.Net80.AddPackages( + private static readonly ReferenceAssemblies s_defaultWithUno = _Dotnet.Current.ReferenceAssemblies.AddPackages( ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))); private async Task TestGeneratorAsync(string inputSource, params GeneratedFile[] generatedFiles) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs index 90cd7c6ca69a..bb5ba0926b45 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs @@ -1,17 +1,6 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; -using System.Runtime.Serialization; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.VisualStudio.TestPlatform.Utilities; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Uno.Extensions; -using Uno.UI.RemoteControl.Host.HotReload.MetadataUpdates; using Uno.UI.SourceGenerators.MetadataUpdates; namespace Uno.UI.SourceGenerators.Tests.MetadataUpdateTests; @@ -25,9 +14,15 @@ public async Task HR(string name, Scenario? scenario, Project[]? projects) { if (scenario != null) { + if (scenario.IsCrashingRoslyn) + { + Assert.Inconclusive("Case is known to crash roslyn."); + return; + } + var results = await ApplyScenario(projects, scenario.IsDebug, scenario.IsMono, scenario.UseXamlReaderReload, name); - for (int i = 0; i < scenario.PassResults.Length; i++) + for (var i = 0; i < scenario.PassResults.Length; i++) { var resultValidation = scenario.PassResults[i]; @@ -47,7 +42,7 @@ public record ScenariosDescriptor( public record Project(string Name, ProjectReference[]? ProjectReferences); public record ProjectReference(string Name); - public record Scenario(bool IsDebug, bool IsMono, bool UseXamlReaderReload, params PassResult[] PassResults) + public record Scenario(bool IsDebug, bool IsMono, bool IsCrashingRoslyn, bool UseXamlReaderReload, params PassResult[] PassResults) { public override string ToString() => $"{(IsDebug ? "Debug" : "Release")},{(IsMono ? "MonoVM" : "NetCore")},XR:{UseXamlReaderReload}"; @@ -63,6 +58,13 @@ public record DiagnosticsResult(string Id); var scenarioName = Path.GetFileName(scenarioFolder); var path = Path.Combine(scenarioFolder, "Scenario.json"); +#if DEBUG && false + if (!path.Contains("When_DataTemplate_xLoad_xBind_Remove")) + { + continue; + } +#endif + if (File.Exists(path)) { var scenariosDescriptor = ReadScenarioConfig(path); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add/0/p1/MainPage.xaml b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add/0/p1/MainPage.xaml new file mode 100644 index 000000000000..f8d477b0e53d --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add/0/p1/MainPage.xaml @@ -0,0 +1,19 @@ + + + + +