Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Conversation

VincentH-Net
Copy link
Contributor

@VincentH-Net VincentH-Net commented Nov 2, 2020

Description of Change

Move the full C# Markup functionality from the Xamarin Forms CSharpForMarkup Part 2 PR into the XCT

  • With full git history from Forms repo
  • Without experimental feature flags
  • With working example app, ported from Introducing C# Markup for Xamarin.Forms
  • 100% Unit test coverage; all tests green.
    Two tests signaling Forms issue 12683 will fail after that issue is fixed; how to fix the tests then is included in TODO comments
  • As a separate NuGet package Xamarin.CommunityToolkit.Markup (with corresponding namespace), targeting Forms 5; no dependencies on other XCT package(s)

This XCT PR depends on Forms PR 12623; until this is available in a NuGet feed, this XCT PR downloads and unzips the NuGet packages of the Forms PR on the restore build target

Bugs Fixed

API Changes

Add API's documented in PR 29.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard

VincentH-Net and others added 30 commits February 27, 2020 15:03
* - Add MarkupExtensions from https://github.com/VincentH-Net/CSharpForMarkup/blob/061566282706de22d040e5b7b32bc3c2e3e323e3/src/XamarinFormsMarkupExtensions.cs
- Remove specific converters
- Fix .NETStandard 1 build errors by refactoring IConvertible to Enum generic constraints
- Add RegisterDefaultBindableProperties method
- Reformat source to comply with Forms contibuting guidelines

* - Move markup extensions to Xamarin.Forms.Markup namespace to prevent impact on existing code and to support clear separation of UI markup from UI logic
- Split up source file for better maintainability

* Cleanup:
- Names of generic types and variables to reflect where clauses
- Namespaces remove unused & sort
- Add whitespace
- Remove unused file

* Fix for incorrect type name in exception message
Remove RowCol helpers because compiler cannot infer its generic type parameters. Use Row and Col methods instead

* Add targetNullValue and fallbackValue parameters to binding helpers.
Equivalent to https://github.com/VincentH-Net/CSharpForMarkup/tree/bd7f99957653f5e813ec805e3dad88aa487b9526

* rename binding helpers sourcePropertyName parameter to path

* Enable Style<T> on BindableObject instead of Element to resolve xamarin/Xamarin.Forms#8342 (comment)

* Fix for Grid properties Row, Col, RowSpan, ColumnSpan not set when default value is specified VincentH-Net/CSharpForMarkup#7

* Support DefaultBindableProperties for BindableObject (was limited to Element)

* .Font:
- Support any IFontElement (was limited to Button, Label, Entry and Picker)
- Fix for italic ignored when bold == true

* Fix for .FontSize, .Bold, .Italic return Label instead of type derived from Label

* Unit tests batch 1: for LabelExtensions, LayoutExtensions, ViewExtensions

* Add DefaultBindableProperties for more BindableObject types

* Remove .Menu() helper from ViewInFlexLayoutExtensions (bc no relation to FlexLayout)

* Fix for .Row and .Col without span specified still sets span

* Rename MarkupBaseTestFixture.TestPropertySet to TestPropertiesSet

* Add unit tests for ViewInFlexLayoutExtensions, ViewInGridExtensions and VisualElementExtensions

* Add default bindable property for all applicable bindable objects in core.

* Add unit tests for DefaultBindableProperties

* Support Bind, Assign and Invoke on BindableObject (was Element)
Add inline doc to clarify purpose of Bind overloads

* Add unit tests for BindableObjectExtensions

* Fix for attributes not set in .Font
Rename fontSize parameter to size
Enable .FontSize, .Bold and .Italic on IFontElement (was Label)

* Add unit tests for ElementExtensions

* Add unit tests for ElementExtensions

* Add assert of exception message content in GetDefaultBindablePropertyForUnsupportedType

* Add unit tests for EnumsForGridRowsAndColumns

* Add inline doc to clarify purpose of gesture recognizer binding overloads
Rename private constant bindingContextPropertyName to bindingContextPath for clarity

* Add unit tests for Style; cleanup namespaces in Style

* Simplify BindableObjectExtensions implementation (functionality unchanged)

* Add IGestureRecognizers to GestureElement and View, to avoid code duplication when accessing the existing GestureRecognizers property

* - Add specific helpers for more built-in gesture recognizers
- Add helpers to support initializing gesture recognizers
- Eliminate duplicate code for View and GestureElement by using new IGestureRecognizers
- Simplify implementation
- Rename ViewGesturesExtensions to ElementGesturesExtensions

* Extract BindingHelpers from BindableObjectExtensionsTests

* Add unit tests for ElementGesturesExtensions

* Add support for typed converter parameters
Add asserts for conversion values in unit tests

* Add unit tests for FuncConverter

* Add missing calls to Bind overloads in unit test for supporting derived types in BindableObject extensions fluent API

* Cleanup: remove unneeded Xamarin.Forms. prefix from static class references

* Add unit tests for PlatformSpecificsExtensions

* Reorder FuncConverter type params to optimize for most common usage and to remain backwards compatible with https://github.com/VincentH-Net/CSharpForMarkup

* Extend Bind*Gesture helpers to support all possible binding parameters

* Rename EnumsForGridRowsAndColumns to GridRowColEnums

* Add BindCommand helper to bind to default Command + CommandParameter properties
Add RegisterForCommand to register default Command + CommandParameter properties for custom bindable objects

* - Change Bind*Gesture helper parameters to match BindCommand parameters, to enable binding to Command + CommandParameter in a single compact call (removed parameters did not make sense for a command).
- Add inline doc to more ElementGesturesExtensions helpers where needed
- Improve ElementGesturesExtensions source formattting for consistency and readability

* Remove PlatformSpecificsExtensions
(only 2 iOS-only helpers; replace with guidance in PR description on how to use any platform specific with .Invoke)

* Fix inline doc spelling: it's -> its

* Rename TextLeft -> TextStart, TextRight -> TextEnd to support RTL

* Add Columns.Define(width, width ...) and Rows.Define(height, height ...) overloads for Grid

* Rename Grid rows & columns extensions class to GridRowsColumns

* Change gesture recognizer helpers implementation from reuse existing instance to always add new instance

* Change Bind*Gesture helpers default to not bind the commandparameter (is the more common scenario)

* Rename BoolNotConverter to NotConverter and make it a 2-way converter

* Add culture support to FuncConverter

* Rename helpers Left -> Start, Right -> End
Add opt-in LeftToRight and RightToLeft helpers

* Rename Col -> Column throughout

* Rename H -> Horizontal and V -> Vertical throughout

* Add Markup_Experimental flag for all API methods and update all unit tests to run with and without the flag

* Re-add "Markup_Experimental" flag

* Add default bindable properties / test exclusions for new BindableObject types in core

* Add constructorHint to FuncConverter and Style for more clear experimental flag message

* Add default bindable property for RadioButton - fixes test AllBindableElementsInCoreHaveDefaultBindablePropertyOrAreExcluded failure
* Implement OnAppTheme

* Implement AppThemeColor

* Added tests

* Finishing up

* Implement UWP

* Xcode 11 and additional test

* Update Forms.cs

* Update ViewRenderer.cs

* Update ViewRenderer.cs

* Remove IAppThemeProvider

* Implemented RequestedThemeChanged

* Update WindowsBasePlatformServices.cs

* Bindable props and Android invalidate

* Update DefaultBindableProperties.cs

* Updates at runtime

* Review feedback part 1

* Implement VisualElement.OnRequestedThemeChanged

* UWP Dispatcher

* Add experimental flag

* ControlGallery restructure

* Update ViewRenderer.cs

* Update WindowsBasePlatformServices.cs

* iOS pre-13 fix
* Various fixes

* Back to basics
* Added Shapes to Core and Core Gallery samples
Implemented basic Shapes on iOS

* Added basic shapes Android implementation

* Fixed UWP namespace conflicts

* Fixed WPF namespace conflicts

* Implemented basic shapes on UWP

* Fixed UWP Ellipse and Rectangle size issue

* Fixed Tizen Build

* Changes to fix the build errors

* Exclude shapes renderers from Tizen compilation

* Implemented LineCap and LineJoin in Android and iOS

* Implemented LineCap and LineJoin on UWP

* Fixed build error

* Updated Polygon sample

* Fixed UWP Build error (namespace conflicts)

* Fixed namespaces collision build error

* Added "Shapes_Experimental" flag

* Update UWP ShapeRenderer size logic

* Updated iOS and Android ShapeRenderer size logic

* Fixed UWP Build error

* Added WPF implementation

* Fixed Tizen Build error

* Added Shapes macOS implementation

* Fixed broken unit tests

* Use the same Shapes classes between UWP and WPF backends

* Fixed flipper macOS shape issue

* Changed Shape class to be abstract

* Added Polygon and Polyline unit tests

* Added more Shapes Unit Tests

* Moved Shapes to Xamarin.Forms.Shapes in Android, iOS and macOS

* Moved Shapes to Xamarin.Forms.Shapes namespace in Windows (UWP and WPF)

fixes #2452 (partially)
fixes #9178
* Added Path definition in Core (Shapes)
Implemented Path in Android and iOS

* Fixed Android build errors

* Fixed UWP Build

* Fixed WPF Build

* Implemented PathRenderer on UWP

* Added unit tests

* Fixed namespaces conflicts in Platform projects

* Changes to fix the build errors

* Implemented Path Transformations in Android and iOS

* Fixed Build error in WPF and UWP

* Implemented Path Transformations in UWP

* Fixed iOS Build error

* Changes to fix the Build (Path namespace conflict)

* More changes to fix the build error

* Fixed Windows Build errors

* Fixed Path size issue on UWP

* Added Shapes_Experimental flag

* Updated path sample

* Updated Android ShapeRenderer size logic

* Added Shape Aspect sample in Core Gallery

* Added more Shapes samples

* Updated UWP PathRenderer size logic

* Updated droid and iOS pathRenderer size logic (same behavior in all the platforms)

* Updated UWP ShapeRenderer

* Implemented Path in WPF Backend

* Fixed build error

* Initial Clip implementation in WPF and UWP (work in progress)

* Added Path implementation on macOS

* Added Clip implementation in Android, iOS and macOS

* Fixed broken unit tests

* Notify the change of Geometry if any of the child properties changed

* Added new sample clipping different views

* Fixed flipped shape issue on macOS

* Added support to Clip using EllipseGeometry, LineGeometry and RectangleGeometry in UWP

* Changed Shape class to be abstract

* Moved Shapes to Xamarin.Forms.Shapes in Android, iOS and macOS

* Moved Shapes to Xamarin.Forms.Shapes namespace in Windows (UWP and WPF)

* Fixed wrong property in LineGeometry

* Fixed build error

* Added Clip Performance sample in Core Gallery

* Update Matrix.cs

* Update RectangleGeometry.cs

* Update Xamarin.Forms.Platform.macOS.csproj

* Some duplicate classes

* Update PointCollectionTests.cs

* Update ImageButtonRenderer.cs

* Update Xamarin.Forms.Platform.iOS.csproj

* Update Xamarin.Forms.Platform.iOS.csproj

* Fixed tabs error

Co-authored-by: Samantha Houts <[email protected]>

fixes #2452 (partially)
fixes #9178
…o use named parameters across all FontElement extensions)
- Improve Bind markup helpers: add multibinding, make more strongly typed, remove converterParameter where unused
- wip Add unit tests for multiconverter and multibind
wip Complete MultiBind unit tests
…change namespace to Xamarin.CommunityToolkit.Markup, add TODO comments for inaccessible IPaddingElement
…lkit.Markup.UnitTests, remove experimental flag testing. add TODO comments for inacccessible API's
Get unit tests working and succeeding except for issue in Forms
Cleanup mocks and remove all unused code from them
Remove all unnecessary namespace usings
… fix notimplemented exception in MockPlatformServices
@VincentH-Net
Copy link
Contributor Author

VincentH-Net commented Nov 5, 2020

@jfversluis can you help me get the Xamarin.CommunityToolkit.Markup.UnitTests.csproj results visible? Thx!

The unit tests run in CI e.g. see log but they are not listed in the test overview and also not present in the test results tab in Azure Devops

There should be 1310 tests total (255 markup tests)

@VincentH-Net
Copy link
Contributor Author

@jfversluis is it possible to enable code coverage in CI?
Markup is at 100%
image

@VincentH-Net VincentH-Net marked this pull request as ready for review November 5, 2020 12:30
@jfversluis
Copy link
Member

Looks like I can see them just fine?

image

image

Note that for the screen in AzDO it filters automatically for only failed tests. If you disable that, they show up.

I'll have a look at the coverage.

@VincentH-Net
Copy link
Contributor Author

VincentH-Net commented Nov 5, 2020

@jfversluis

Looks like I can see them just fine?

Nope, those are only the Xamarin.CommunityToolkit.UnitTests.csproj tests.
The tests in Xamarin.CommunityToolkit.Markup.UnitTests.csproj are not included; try filtering on Passed and "Markup".

Once they are included you should see an additional 255 tests

@jfversluis
Copy link
Member

You mean these?

image

@VincentH-Net
Copy link
Contributor Author

You mean these?

@jfversluis yes! User error - I saw the top tests listed like this:
image

So I assumed my tests would also include the full namespace and I filtered on "Markup"
But for some reason my tests are shown like this:
image
(probably some NUnit default - I saw you use XUnit)

So that's why I never saw a result. 1055 is the correct total nr of tests

@jfversluis
Copy link
Member

Yeah I agree, would be great if we can align that and get a bit better naming/categorising, etc. but something for later :)

@jfversluis
Copy link
Member

If you pull in the change from #524 coverage is enabled too

@VincentH-Net
Copy link
Contributor Author

If you pull in the change from #524 coverage is enabled too

@jfversluis merged; works. Thanks! Results:

image

Not counting tests, C# Markup is just 13% of total XCT blocks. XCT is bigger than I thought 👍

@jfversluis jfversluis added this to the v1.0 milestone Nov 5, 2020
@jfversluis
Copy link
Member

Can we switch this one to pre4 that should have all the bits? Then it's good to go afaic :)

remove custom Forms NuGet download targets
update unit tests for Forms fix fix xamarin/Xamarin.Forms#12689
Markup sample to Markup 1.0.0-pre4 and Forms 5.0.0.1709-pre4
@VincentH-Net
Copy link
Contributor Author

Can we switch this one to pre4 that should have all the bits? Then it's good to go afaic :)

@jfversluis Done. Markup package version 1.0.0-pre4. All tests green; sample updated and tested; all works on Android, UWP and iOS.

Minor visual issue in the sample on iOS : the like button does not display - possibly a forms 5 issue; it uses FontImageSource.GlyphProperty with characters "\u2764" and "\u2661". Will look into that later but for now this can be released, assuming that the Markup package and build settings for public release are OK (I copied those from the main XCT package but can't verify them for myself)

@jfversluis
Copy link
Member

The version of the package will be overriden at the time of release, but we'll figure that out also in light of #529

@jfversluis jfversluis merged commit c030809 into xamarin:main Nov 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move C# Markup Extensions from Forms to Toolkit
3 participants