Skip to content

Commit

Permalink
Merge pull request #19020 from unoplatform/dev/dr/hr-no-create-new
Browse files Browse the repository at this point in the history
feat(hr): Remove cnomua
  • Loading branch information
dr1rrb authored Dec 16, 2024
2 parents cd94b2a + 9cfe4ae commit 3a5478e
Show file tree
Hide file tree
Showing 211 changed files with 5,186 additions and 2,200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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));
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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]
Expand Down Expand Up @@ -341,7 +353,7 @@ public void SuspendBindings() =>
""", Encoding.UTF8)) }
}
},
ReferenceAssemblies = _net80,
ReferenceAssemblies = _refAsm,
};

test.TestState.AdditionalReferences.AddRange(BuildUnoReferences(isAndroid: false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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];

Expand All @@ -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}";
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Page x:Class="Test01.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Test01"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<DataTemplate x:Key="MyDataTemplate" x:DataType="local:MainPage">
<Button Content="Hello" />
</DataTemplate>
</Page.Resources>

<Grid>
<ContentPresenter Content="Hello" ContentTemplate="{StaticResource MyDataTemplate}" />
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Page x:Class="Test01.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Test01"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<DataTemplate x:Key="MyDataTemplate" x:DataType="local:MainPage">
<Button Content="Hello" Click="{x:Bind OnClick}" />
</DataTemplate>
</Page.Resources>

<Grid>
<ContentPresenter Content="Hello" ContentTemplate="{StaticResource MyDataTemplate}" />
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;

namespace Test01;

public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}

public void OnClick()
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
"IsMono": true,
"PassResults": [
{
"MetadataUpdates": 0,
"Diagnostics": [
// MainPage_c2bc688a73eab5431d787dcd21fe32b9.cs(68,83): error ENC0049: Ceasing to capture variable '__that' requires restarting the application.
{ "Id": "ENC0049" }
]
"MetadataUpdates": 1,
"Diagnostics": []
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Page x:Class="Test01.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Test01"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<DataTemplate x:Key="MyDataTemplate" x:DataType="local:MainPage">
<Button Content="Hello" />
</DataTemplate>
</Page.Resources>

<Grid>
<ContentPresenter Content="Hello" ContentTemplate="{StaticResource MyDataTemplate}" />
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;

namespace Test01;

public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Page x:Class="Test01.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Test01"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<DataTemplate x:Key="MyDataTemplate" x:DataType="local:MainPage">
<Button Content="Hello" Click="{x:Bind OnClick}" />
</DataTemplate>
</Page.Resources>

<Grid>
<ContentPresenter Content="Hello" ContentTemplate="{StaticResource MyDataTemplate}" />
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;

namespace Test01;

public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}

public void OnClick()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Page x:Class="Test01.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Test01"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<DataTemplate x:Key="MyDataTemplate" x:DataType="local:MainPage">
<Button Content="Hello" />
</DataTemplate>
</Page.Resources>

<Grid>
<ContentPresenter Content="Hello" ContentTemplate="{StaticResource MyDataTemplate}" />
</Grid>
</Page>
Loading

0 comments on commit 3a5478e

Please sign in to comment.