-
Notifications
You must be signed in to change notification settings - Fork 750
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
fix: Ensure x:Uid is set only when both name and namespace are correct #19148
Open
AndrewKeepCoding
wants to merge
3
commits into
unoplatform:master
Choose a base branch
from
AndrewKeepCoding:fix-xuid-on-non-windows-platforms
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+86
−2
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
20 changes: 20 additions & 0 deletions
20
...s/Tests/Windows_UI_Xaml/Controls/When_xUid_Conflicts_With_AttachedProperty_Named_Uid.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,20 @@ | ||
<UserControl | ||
x:Class="Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls.When_xUid_Conflicts_With_AttachedProperty_Named_Uid" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
d:DesignHeight="300" | ||
d:DesignWidth="400" | ||
mc:Ignorable="d"> | ||
|
||
<StackPanel> | ||
<TextBlock x:Name="xUidTextBlock" | ||
x:Uid="When_xUid_Conflicts_With_AttachedProperty_Named_Uid" | ||
x:FieldModifier="public" /> | ||
<TextBlock x:Name="attachedPropertyUidTextBlock" | ||
local:Uids.Uid="AttachedPropertyUid" | ||
x:FieldModifier="public" /> | ||
</StackPanel> | ||
</UserControl> |
51 changes: 51 additions & 0 deletions
51
...ests/Windows_UI_Xaml/Controls/When_xUid_Conflicts_With_AttachedProperty_Named_Uid.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,51 @@ | ||
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; | ||
|
||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | ||
|
||
namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls | ||
{ | ||
public static class Uids | ||
{ | ||
public static readonly DependencyProperty UidProperty = DependencyProperty.RegisterAttached( | ||
"Uid", | ||
typeof(string), | ||
typeof(Uids), | ||
new PropertyMetadata(default)); | ||
|
||
public static string GetUid(DependencyObject dependencyObject) | ||
{ | ||
return (string)dependencyObject.GetValue(UidProperty); | ||
} | ||
|
||
public static void SetUid(DependencyObject dependencyObject, string uid) | ||
{ | ||
dependencyObject.SetValue(UidProperty, uid); | ||
} | ||
} | ||
|
||
public sealed partial class When_xUid_Conflicts_With_AttachedProperty_Named_Uid : UserControl | ||
{ | ||
public When_xUid_Conflicts_With_AttachedProperty_Named_Uid() | ||
{ | ||
this.InitializeComponent(); | ||
Loaded += When_xUid_Has_Name_Conflict_Loaded; | ||
} | ||
|
||
private void When_xUid_Has_Name_Conflict_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might need to be fixed as well:
uno/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
Line 5885 in 4dd8184
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be
var localizedObject = FindMember(objectDefinition, "Uid", XamlConstants.XamlXmlNamespace)
A test that covers the code path I mentioned may be needed as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Youssef1313 ! Thanks for the feedback. I'm so sorry for not being able to do this earlier.
Do you mean to add a test for the
GenerateFile
method? Not sure how to add one for this. Can you give some tips please?