-
Notifications
You must be signed in to change notification settings - Fork 719
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
Styles and Xaml resources compatibility #1766
Conversation
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs
Outdated
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileParser.cs
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlGlobalStaticResourcesMap.cs
Outdated
Show resolved
Hide resolved
@@ -59,10 +60,10 @@ private int PageSize | |||
} | |||
else | |||
{ | |||
if (ScrollViewer?.Style == Uno.UI.GlobalStaticResources.ListViewBaseScrollViewerStyle) | |||
if (ScrollViewer?.Style != null && ScrollViewer.Style == ResourceResolver.GetSystemResource<Style>("ListViewBaseScrollViewerStyle")) //TODO: this, too, properly |
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.
Todo in this PR ?
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.
Depends if I end up adjusting the timing of template application to the Measure phase. I'd rather push that particular change back, but it depends on what regressions come up in testing.
Once templates are materialized on Measure, it'll be trivially easy to give ScrollViewers inside virtualized lists a 'fake' ScrollContentPresenter without any user intervention.
642f1b1
to
ad1f20a
Compare
f6c8ef9
to
a5ae9a8
Compare
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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 file may clash with generated code on CI for versionning. You should consider using a SDK-style project.
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.
I initially tried to make it an SDK-style project and ran into weird issues, I'll circle around and try again before I complete the PR.
Here is an overview of what got changed by this pull request: Issues
======
+ Solved 33
- Added 155
Complexity increasing per file
==============================
- src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileParser.cs 5
- src/Uno.UI/UI/Xaml/FrameworkElement.iOS.cs 1
- src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/Button/Button_UseUWPDefaultStyles.xaml.cs 2
- src/Uno.UI.Tests/App/Views/MyDependencyObject.cs 1
- src/Uno.UI/UI/Xaml/Controls/MediaPlayer/MediaPlayerElement.net.cs 1
- src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs 2
- src/Uno.UI/UI/Xaml/Controls/WebView/NativeWebView.Android.cs 1
- src/Uno.UI.Tests/Windows_UI_Xaml/Given_Implicit_Style.cs 1
- src/Uno.UI.Tests/Windows_UI_Xaml/Given_ResourceDictionary.cs 1
- src/Uno.UI.Tests/App/Views/MyControl.cs 1
- src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ButtonTests/Button_Tests.cs 1
- src/Uno.UI.Tests/App/Xaml/Test_Page.xaml.cs 1
- src/Uno.UI/UI/Xaml/Controls/Primitives/PivotHeaderItem.cs 1
- src/Uno.UWP/Media/Playback/MediaPlayer.net.cs 1
- src/Uno.UI.Tests/Helpers/AssertEx.cs 1
- src/Uno.UI/Mock/ViewExtensions.net.cs 2
- src/Uno.UI.Tests.ViewLibrary/MyExtControl.cs 1
- src/Uno.UI/UI/Xaml/DependencyObjectStore.cs 1
- src/Uno.UI/UI/Xaml/Style/Style.cs 7
- src/Uno.UI/UI/Xaml/Application.cs 5
- src/Uno.UI/UI/Xaml/UIElementCollection.net.cs 1
- src/Uno.UI.Tests/Windows_UI_Xaml/Given_ThemeResource.cs 1
- src/Uno.UI/UI/Xaml/Controls/GridView/GridViewHeaderItem.cs 1
- src/Uno.UI.Tests/App/Views/BooleanToBrushConverter.cs 3
- src/Uno.UI/UI/Xaml/FrameworkElement.wasm.cs 2
- src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlGlobalStaticResourcesMap.cs 2
- src/Uno.UI/Extensions/ViewExtensions.wasm.cs 6
- src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileDefinition.cs 1
- src/Uno.UI/UI/Xaml/Controls/FlipView/NativeFlipView.iOS.cs 1
- src/SourceGenerators/Uno.UI.SourceGenerators/ApiInformation.cs 1
- src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/BackingFieldDefinition.cs 3
- src/Uno.UI/UI/Xaml/ResourceResolver.cs 7
- src/Uno.UI.Tests/App/Views/SpiffyItemsControl.cs 1
- src/Uno.UI.Tests/App/Views/MyPoco.cs 1
- src/Uno.UI/UI/Xaml/Controls/UserControl/UserControl.cs 1
- src/Uno.UI/UI/Xaml/XamlScope.cs 1
- src/Uno.Foundation/Metadata/ApiInformation.shared.cs 2
- src/Uno.UI.Tests/Windows_UI_Xaml/Given_Explicit_Style.cs 1
- src/Uno.UI.Tests/Windows_UI_Xaml/Given_Conditional_Xaml.cs 1
- src/Uno.UI.Tests/App/Views/ResourceTestControl.cs 1
- src/Uno.UI/UI/Xaml/Data/ResourceBinding.cs 1
- src/Uno.UI.Tests/Windows_UI_XAML_Controls/TextBlockTests/Given_TextBlock.cs 1
- src/Uno.UI.Tests/App/Views/MyBehavior.cs 1
- src/Uno.UI.Tests/App/Views/StylesTestControl.cs 1
Complexity decreasing per file
==============================
+ src/Uno.UI/UI/Xaml/Controls/ContentControl/ContentControl.macOS.cs -1
+ src/Uno.UI/UI/Xaml/Documents/Underline.cs -1
+ src/Uno.UI/UI/Xaml/Documents/Run.cs -1
+ src/Uno.UI/UI/Xaml/Documents/Bold.cs -1
+ src/Uno.UI/UI/Xaml/Documents/Span.cs -1
+ src/Uno.UI/UI/Xaml/Documents/Inline.cs -1
+ src/Uno.UI/UI/Xaml/FrameworkElement.cs -1
+ src/Uno.UI/UI/Xaml/Documents/Italic.cs -1
+ src/Uno.UI.Tests/Windows_UI_Xaml_Markup/XamlReaderTests/Given_XamlReader.cs -2
+ src/Uno.UI/UI/Xaml/ResourceDictionary.cs -2
See the complete overview on Codacy |
So, after this PR be accepted, I would need to add |
@pkar70 Yes, indeed you should add it right now, currently it just won't do anything. |
return null; | ||
} | ||
|
||
public static observeSystemTheme() { | ||
if (!this.dispatchThemeChange) { |
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.
|
||
public bool Remove(KeyValuePair<object, object> key) => _values.Remove(key.Key.ToString()); | ||
public bool Remove(KeyValuePair<object, object> key) => _values.Remove(key.Key); |
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.
.GetTypeInfo() | ||
.GetDeclaredProperty("DefaultStyleKey"); | ||
#else | ||
.GetProperty("DefaultStyleKey", BindingFlags.NonPublic | BindingFlags.Instance); |
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.
return absoluteTargetPath.Replace('\\', '/'); | ||
} | ||
|
||
internal static bool IsAbsolutePath(string relativeTargetPath) => relativeTargetPath.StartsWith(AppXIdentifier) |
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.
|
||
public static observeSystemTheme() { | ||
if (!this.dispatchThemeChange) { | ||
this.dispatchThemeChange = (<any>Module).mono_bind_static_method("[Uno] Windows.UI.Xaml.Application:DispatchSystemThemeChange"); |
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.
} | ||
|
||
_isParsing = value; | ||
if (_isParsing) |
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.
? childLevelLimit.Value | ||
: Int32.MaxValue; | ||
|
||
return (T)view.EnumerateAllChildren(childSelector, maxDepth).FirstOrDefault(); |
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.
{ | ||
if (value is bool b) | ||
{ | ||
return b ? TrueValue |
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.
|
||
public static void SetNoDPProperty(FrameworkElement obj, double value) | ||
{ | ||
obj.Tag = value; |
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.
|
||
public static void SetBulbousness(DependencyObject obj, double value) | ||
{ | ||
obj.SetValue(BulbousnessProperty, value); |
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.
// Set initial value based on statically-available top-level resources. | ||
if (TryStaticRetrieval(resourceKey, context, out var value)) | ||
{ | ||
owner.SetValue(property, BindingPropertyHelper.Convert(() => property.Type, value)); |
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.
|
||
public static double GetNoDPProperty(FrameworkElement obj) | ||
{ | ||
if (obj.Tag is double value) |
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.
public static T FindFirstChild<T>(this ViewGroup view, int? childLevelLimit = null, bool includeCurrent = true) | ||
where T : View | ||
{ | ||
return view.FindFirstChild<T>(null, childLevelLimit, includeCurrent); |
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.
@@ -36,6 +36,7 @@ internal partial class XamlFileGenerator | |||
private string[] _clrNamespaces; | |||
private readonly static Func<INamedTypeSymbol, IPropertySymbol> _findContentProperty; | |||
private readonly static Func<INamedTypeSymbol, string, bool> _isAttachedProperty; | |||
private readonly static Func<INamedTypeSymbol, string, INamedTypeSymbol> _getAttachedPropertyType; |
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.
{ | ||
Assert.IsNotNull(resources); | ||
|
||
AssertHasColor(resources[key] as Brush, expected); |
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.
{ | ||
var textDarkStaticMarkup = control.TemplateFromResourceControl.TextBlock5.Text; | ||
Assert.AreEqual("ApplicationLevelLight", textDarkStaticMarkup); //StaticResource markup doesn't change | ||
; |
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.
Issue found: Remove this empty statement.
} | ||
|
||
_isParsing = value; | ||
if (_isParsing) |
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.
The build 16049 found UI Test snapshots differences.
|
The build 16049 found UI Test snapshots differences.
|
No way! 🎉🎉🎉🎉🎉🎉🎉 |
@davidjohnoliver Really nice work! One more not-insignificant roadblock in compatibility is gone!! |
GitHub Issue (If applicable): fixes #119 , fixes #1335, fixes #55, fixes #49, fixes #55, fixes #96, fixes #371, fixes #833, fixes #1427, fixes #3216, fixes #1420, fixes #2404
Related: #2744
PR Type
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
Numerous compatibility fixes:
DefaultStyleKey
is now respectedDefaultStyleKey
is overriddenPR Checklist
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Run
results.Contains NO breaking changesOther information
Internal Issue (If applicable):