Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hr): Remove cnomua #19020

Merged
merged 30 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
28e12c5
chore: Remove attribute
Youssef1313 Jul 16, 2024
46b481a
chore: Refactor to generate methods instead of lambdas for generic apply
jeromelaban Jul 17, 2024
ae08979
chore: Adjust formatting
jeromelaban Jul 17, 2024
8126837
chore: Adjust apply generation
jeromelaban Jul 18, 2024
30a468d
chore: Remove more createnewtype facilites
jeromelaban Jul 18, 2024
b3f077b
test(hr): Fix main HR tests with no cnomua
dr1rrb Dec 5, 2024
cbb4d39
chore: Import changes from 1e7006508efe1ff13017a149efc5a379e19a962e
dr1rrb Dec 5, 2024
b6d0138
test: All green
dr1rrb Dec 5, 2024
87c931a
fix(reg): Fix invalid code gen
dr1rrb Dec 5, 2024
7aefebe
chore: Remove dead code
dr1rrb Dec 5, 2024
574d4d9
test(hr): Fix rebase
dr1rrb Dec 5, 2024
361d014
fix: Fix invalid code gen
dr1rrb Dec 6, 2024
79ed849
fix: Fix x:Bind not applied properly
dr1rrb Dec 9, 2024
9613875
fix(hr): Fix invalid code gen for custom markup extensions
dr1rrb Dec 9, 2024
55822b3
fix(hr): Fix invalid gen for top level dic
dr1rrb Dec 10, 2024
69b6aa1
fix(reg): Fix _rootInstance field is always null
dr1rrb Dec 10, 2024
beb33aa
fix(hr): Avoid rude edit
dr1rrb Dec 10, 2024
4867046
fix(hr): Use properties for subjects
dr1rrb Dec 10, 2024
4ea7bce
fix(hr): Always generate the Bindings class when HR is enabled
dr1rrb Dec 10, 2024
7a8536a
fix(hr): Restore udage of cnomua for resource dictionnaries
dr1rrb Dec 10, 2024
3db1f2c
fix(reg): Fix ANdroid test not passing
dr1rrb Dec 11, 2024
ac83205
test(hr): Remove invalid clss from UWP tests
dr1rrb Dec 11, 2024
00f4a15
fix(hr): Disable partial reload on compatible targets
dr1rrb Dec 11, 2024
e15e967
fix(hr): Do not restore MSBuild properties in HR workspace
dr1rrb Dec 12, 2024
c9d39da
test(hr): Fix invalid space chars
dr1rrb Dec 12, 2024
5aeb92b
test(hr): Prevent cross-tests impacts
dr1rrb Dec 12, 2024
797c168
test(hr): Update test scenario
dr1rrb Dec 12, 2024
7aae564
fix(reg): Fix HR no allowing to remove x:Bind as first change
dr1rrb Dec 13, 2024
6c3cc54
test(HR): Add several test scenario
dr1rrb Dec 13, 2024
9cfe4ae
chore: Apply code review comments
dr1rrb Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading