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

[net8.0] Merge main to net8.0 #17284

Merged
merged 23 commits into from
Sep 11, 2023
Merged

[net8.0] Merge main to net8.0 #17284

merged 23 commits into from
Sep 11, 2023

Conversation

rmarinho
Copy link
Member

@rmarinho rmarinho commented Sep 8, 2023

Description of Change

Bring latest changes from main to net8.0

jonathanpeppers and others added 23 commits August 29, 2023 13:21
Fixes: #11467
Context: https://github.com/maiia-kuzmishyna/MAUI-ProtectedEventHandlers

Reviewing the customer sample, it appears to be a valid case. Consider a
`ChildButton` defined in XAML:

    <local:ParentButton
        xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        xmlns:local="clr-namespace:foo"
        x:Class="foo.ChildButton">
    </local:ParentButton>

Where `ParentButton` is also defined in XAML:

    <Button
        xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        x:Class="foo.ParentButton"
        Clicked="ParentButton_OnClicked">
    </Button>

Where `ParentButton_OnClicked` is of course private:

    private void ParentButton_OnClicked(object sender, EventArgs e) { }

Throws an exception at runtime with:

    No method ParentButton_OnClicked with correct signature found on type foo.ChildButton

What was also odd, it appears the problem just "goes away" in Release
mode, meaning it works under XamlC. This kind of points to a bug with
non-compiled XAML.

It appears the problem was the code:

    foreach (var mi in rootElement.GetType().GetRuntimeMethods())
    {
        //...
        if (mi.Name == (string)value)
        {
            addMethod.Invoke(element, new[] { mi.CreateDelegate(eventInfo.EventHandlerType, mi.IsStatic ? null : rootElement) });
            return true;
        }
        //...
    }

In this example, `rootElement` is of type `ChildButton` while the method
is on type `ParentButton`. As mentioned on:

https://stackoverflow.com/a/2267299

You need to access `Type.BaseType` to find private methods on base types.

I changed this to instead:

* Iterate over `rootElement.GetType()` and its base types.

* Call `Type.GetMethod()` using the method name, passing the appropriate
  `BindingFlags`.

This appears to make the new test pass, solving the issue.
Fixes #11467
Context: https://github.com/maiia-kuzmishyna/MAUI-ProtectedEventHandlers

Reviewing the customer sample, it appears to be a valid case. Consider a
`ChildButton` defined in XAML:

    <local:ParentButton
        xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        xmlns:local="clr-namespace:foo"
        x:Class="foo.ChildButton">
    </local:ParentButton>

Where `ParentButton` is also defined in XAML:

    <Button
        xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        x:Class="foo.ParentButton"
        Clicked="ParentButton_OnClicked">
    </Button>

Where `ParentButton_OnClicked` is of course private:

    private void ParentButton_OnClicked(object sender, EventArgs e) { }

Throws an exception at runtime with:

No method ParentButton_OnClicked with correct signature found on type
foo.ChildButton

What was also odd, it appears the problem just "goes away" in Release
mode, meaning it works under XamlC. This kind of points to a bug with
non-compiled XAML.

It appears the problem was the code:

    foreach (var mi in rootElement.GetType().GetRuntimeMethods())
    {
        //...
        if (mi.Name == (string)value)
        {
addMethod.Invoke(element, new[] {
mi.CreateDelegate(eventInfo.EventHandlerType, mi.IsStatic ? null :
rootElement) });
            return true;
        }
        //...
    }

In this example, `rootElement` is of type `ChildButton` while the method
is on type `ParentButton`. As mentioned on:

https://stackoverflow.com/a/2267299

You need to access `Type.BaseType` to find private methods on base
types.

I changed this to instead:

* Iterate over `rootElement.GetType()` and its base types.

* Call `Type.GetMethod()` using the method name, passing the appropriate
`BindingFlags`.

This appears to make the new test pass, solving the issue.
…30831.1 (#17196)

Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit
 From Version 8.0.0-prerelease.23421.1 -> To Version 8.0.0-prerelease.23431.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
* Make ViewHandlerConverter use apps MauiContext

Tentative change

* Improve comment

* Fix render issue from logical child perspective

* Add UI test

* Only clear items in the ItemSource

We only cant to remove chlidren that are inside the items.

* Address PR feedback

* Bandaid fix android tests

* Add missing link

* Simplify code

* Fix merge conflicts

* Newline nit
* [docs] Document View

* Apply suggestions from code review

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>

* More PR feedback

---------

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
* Remove need for MapMenuItems flag to sync selected item

Co-authored-by: Mike Corsaro <mikecorsaro@microsoft.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Context: https://learn.microsoft.com/nuget/consume-packages/Central-Package-Management
Fixes: #12953

@mattleibow has already made a few changes to improve this scenario, by
introducing `$(DisableMauiImplicitPackageReferences)`.

I think the main thing missing is to change default values when
`$(ManagePackageVersionsCentrally)` is true. This setting, that enables
CPM, should automatically turn off all implicit `@(PackageReference)`.

I renamed `$(EnableMauiImplicitPackageReferences)` to
`$(DisableMauiImplicitPackageReferences)` to better align with the
changes we made in MAUI in .NET 7 for a future servicing release:

#17046

I tested these changes in a sample application here:

hypdeb/repros@master...jonathanpeppers:MauiNuGetCPMRepro:peppers

I also updated `Workload/README.md` to have a section showing how to
setup NuGet CPM.
* Copy Windows assets to the output folder for Unpackaged

## Description

I noticed that when publishing unpackaged apps, the content was not copied to the publish folder.

This PR makes sure we indicate that we want to do this.

MSIX apps automatically know to copy it, but unpackaged follows the default .NET SDK rules and requires more instructions.

* Update BaseBuildTest.cs

* Update TemplateTests.cs

* Update DotnetInternal.cs
* Fix Tab Colors on iOS

* Added device tests

* Fix the build

* Fix the test

* Updated tests

* Fix mistakes from merge

* Fix the build

* - fix up tests to better represent state

* - cleanup and enable tabbedpage tests for all platforms

* - fix tests for bottom navigation view

* - fix iOS tests

* Update TabbedPageTests.cs

* - fixup tests

* - fix winui coloring

---------

Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
I've been working to get back some of our lost startup performance on
Android in .NET MAUI. We are really close, a few changes will get .NET 8
on par or faster than .NET 7.

Profiling startup of a `dotnet new maui` app on a Pixel 5,
`dotnet-trace` reported time spent in:

    16.62ms microsoft.maui.controls!Microsoft.Maui.Controls.Platform.ToolbarExtensions.UpdateIconColor(

If you drill in further in this method, you can see the time spent in:

    10.19ms xamarin.androidx.appcompat!AndroidX.AppCompat.Widget.Toolbar.get_OverflowIcon()
     6.42ms microsoft.maui!Microsoft.Maui.Platform.DrawableExtensions.SetColorFilter()

The project template doesn't even display a `Toolbar` icon, but it looks
like there are some straightforward performance wins here.

In 9b091fd, accessing `OverflowIcon` was introduced to fix the color of
the overflow icon. This code had the pattern:

    if (navIconColor != null && nativeToolbar.OverflowIcon != null)
    {
        nativeToolbar.OverflowIcon.SetColorFilter(navIconColor, FilterMode.SrcAtop);
    }

This accesses `OverflowIcon` twice, where we can use pattern matching
instead to avoid this.

Additionally, `SetColorFilter` appears to be called in a couple places
throughout .NET MAUI, we can move most of its logic to Java to avoid
interop.

So for example:

    switch (mode)
    {
        case FilterMode.SrcIn:
            return BlendMode.SrcIn;
        case FilterMode.Multiply:
            return BlendMode.Multiply;
        case FilterMode.SrcAtop:
            return BlendMode.SrcAtop;
    }

`Enum` values are just classes in Java, so this calling a Java method
from C# that returns an object. We then have to do various bookkeeping
around handling this Java object instance in C#.

Then the other call, also does Java interop for `BlendModeColorFilter`'s
constructor and the `SetColorFilter()`:

    drawable.SetColorFilter(new BlendModeColorFilter(color, filterMode29));

By moving this logic to Java, we can instead call:

    PlatformInterop.SetColorFilter(drawable, color, (int)mode);

We also do the API Q/29 platform checks on the Java side.

With these changes in place, the three methods above are improved:

    6.19ms microsoft.maui.controls!Microsoft.Maui.Controls.Platform.ToolbarExtensions.UpdateIconColor()
    3.87ms xamarin.androidx.appcompat!AndroidX.AppCompat.Widget.Toolbar.get_OverflowIcon()
    1.15ms microsoft.maui!Microsoft.Maui.Platform.DrawableExtensions.SetColorFilter()

I would estimate these changes improve startup by about ~10ms on a Pixel
5, seeing the savings on the topmost method, `UpdateIconColor()`.
* Enable Mac Catalyst Core Device Tests in CI

* Enable CI run for Core tests

* Fix not finding NSWindow in headless scenario

* Update AssertionExtensions.iOS.cs

* Update SearchBarHandlerTests.cs
Co-authored-by: Mike Corsaro <mikecorsaro@microsoft.com>
…7277)

* Stronger Type for RoutedEventArg property

* change type name

---------

Co-authored-by: TJ Lambert (HE/HIM/HIS) <antlambe@microsoft.com>
Bumps [NUnit3TestAdapter](https://github.com/nunit/nunit3-vs-adapter) from 4.4.2 to 4.5.0.
- [Release notes](https://github.com/nunit/nunit3-vs-adapter/releases)
- [Commits](nunit/nunit3-vs-adapter@V4.4.2...V4.5.0)

---
updated-dependencies:
- dependency-name: NUnit3TestAdapter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
# Conflicts:
#	src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs
@rmarinho rmarinho added this to the .NET 8 GA milestone Sep 8, 2023
@rmarinho rmarinho requested a review from a team as a code owner September 8, 2023 21:25
@rmarinho rmarinho merged commit 27f79a1 into net8.0 Sep 11, 2023
39 checks passed
@rmarinho rmarinho deleted the merge-main-net8 branch September 11, 2023 14:14
@github-actions github-actions bot locked and limited conversation to collaborators Dec 6, 2023
@samhouts samhouts added the fixed-in-8.0.0-rc.2.9373 Look for this fix in 8.0.0-rc.2.9373! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-8.0.0-rc.2.9373 Look for this fix in 8.0.0-rc.2.9373! t/housekeeping ♻︎
Projects
None yet
Development

Successfully merging this pull request may close these issues.