-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(xamlreader): Ensure adding properties on an explicit property rep…
…orts an error (cherry picked from commit c038beb)
- Loading branch information
1 parent
facdc38
commit 83e5279
Showing
4 changed files
with
148 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...re.Tests/Windows_UI_Xaml_Controls/ParserTests/Controls/When_Invalid_Element_Property.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Page x:Class="Uno.UI.Tests.Windows_UI_Xaml_Controls.ParserTests.Controls.When_Invalid_Element_Property" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:Uno.UI.Tests.Windows_UI_XAML_Controls.GridTests.Controls" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Grid> | ||
|
||
<NavigationView IsBackButtonVisible="Collapsed" | ||
IsPaneToggleButtonVisible="False" | ||
IsSettingsVisible="False" | ||
PaneDisplayMode="Left"> | ||
|
||
<NavigationView.PaneTitle FontSize="16" | ||
FontWeight="Bold" | ||
Text="PaneTitle" /> | ||
|
||
</NavigationView> | ||
|
||
</Grid> | ||
</Page> |
31 changes: 31 additions & 0 deletions
31
...Tests/Windows_UI_Xaml_Controls/ParserTests/Controls/When_Invalid_Element_Property.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 | ||
|
||
namespace Uno.UI.Tests.Windows_UI_Xaml_Controls.ParserTests.Controls | ||
{ | ||
/// <summary> | ||
/// An empty page that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class When_Invalid_Element_Property : Page | ||
{ | ||
public When_Invalid_Element_Property() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
...no.UI.SourceGenerators.netcore.Tests/Windows_UI_Xaml_Controls/ParserTests/Given_Parser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System.Text; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using Microsoft.CodeAnalysis.Text; | ||
using Uno.UI.SourceGenerators.Tests.Verifiers; | ||
|
||
namespace Uno.UI.SourceGenerators.Tests.Windows_UI_Xaml_Controls.ParserTests; | ||
|
||
using Verify = XamlSourceGeneratorVerifier; | ||
|
||
[TestClass] | ||
public class Given_Parser | ||
{ | ||
[TestMethod] | ||
public async Task When_Invalid_Element_Property() | ||
{ | ||
var xamlFiles = new[] | ||
{ | ||
new XamlFile( | ||
"MainPage.xaml", | ||
""" | ||
<Page x:Class="TestRepro.MainPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"> | ||
<Grid> | ||
<NavigationView IsBackButtonVisible="Collapsed" | ||
IsPaneToggleButtonVisible="False" | ||
IsSettingsVisible="False" | ||
PaneDisplayMode="Left"> | ||
<NavigationView.PaneTitle FontSize="16" | ||
FontWeight="Bold" | ||
Text="PaneTitle" /> | ||
</NavigationView> | ||
</Grid> | ||
</Page> | ||
"""), | ||
}; | ||
|
||
var test = new Verify.Test(xamlFiles) | ||
{ | ||
TestState = | ||
{ | ||
Sources = | ||
{ | ||
""" | ||
using Windows.UI.Xaml.Controls; | ||
namespace TestRepro | ||
{ | ||
public sealed partial class MainPage : Page | ||
{ | ||
public MainPage() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} | ||
} | ||
""" | ||
} | ||
} | ||
}; | ||
|
||
test.ExpectedDiagnostics.AddRange( | ||
new[] { | ||
// /0/MainPage.xaml(13,5): error UXAML0001: Member 'PaneTitle' cannot have properties at line 13, position 5 | ||
DiagnosticResult.CompilerError("UXAML0001").WithSpan("/0/MainPage.xaml", 13, 5, 13, 5).WithArguments("Member 'PaneTitle' cannot have properties at line 13, position 5"), | ||
// /0/Test0.cs(9,9): error CS1061: 'MainPage' does not contain a definition for 'InitializeComponent' and no accessible extension method 'InitializeComponent' accepting a first argument of type 'MainPage' could be found (are you missing a using directive or an assembly reference?) | ||
DiagnosticResult.CompilerError("CS1061").WithSpan(9, 9, 9, 28).WithArguments("TestRepro.MainPage", "InitializeComponent") | ||
} | ||
); | ||
await test.RunAsync(); | ||
} | ||
} |