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

NativeAOT: Add integration tests for testing MAUI compatibility with NativeAOT on iOS #19194

Merged
merged 5 commits into from
Dec 13, 2023

Conversation

ivanpovazan
Copy link
Member

@ivanpovazan ivanpovazan commented Dec 4, 2023

Description

This PR introduces two new integration tests which are testing MAUI compatibility with NativeAOT on iOS.
The added tests will enable us to catch early any regression in compatibility between MAUI iOS and NativeAOT, but also to guide us forward as we progress with: #18658

Changes

  • Introduced new test cases:
    1. PublishNativeAOT - tests publishing a template MAUI iOS app with NativeAOT
    2. PublishNativeAOTCheckWarnings - tests the generated warnings according to NativeAOT: Add integration tests for testing MAUI compatibility with NativeAOT on iOS #19194 (comment)
  • Created a new utility method DotnetInternal.ConstructBuildArgs with a common logic for setting up build arguments which is shared between tests calling Build and Publish targets
  • Added BuildWarningsUtilities.cs which encapsulates all the logic for parsing, storing and comparing build warnings

NOTE: This should be an initial set of tests verifying our progress in the effort of making MAUI trim-compatible (with NativeAOT). The set can and will be expanded to testing on device, covering support for other iOS-platforms with NativeAOT etc, as we progress.

/cc: @jonathanpeppers @simonrozsival

@ghost ghost added the community ✨ Community Contribution label Dec 4, 2023
@ghost
Copy link

ghost commented Dec 4, 2023

Hey there @ivanpovazan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@jonathanpeppers
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jonathanpeppers
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@ivanpovazan ivanpovazan marked this pull request as ready for review December 5, 2023 17:01
@ivanpovazan ivanpovazan requested a review from a team as a code owner December 5, 2023 17:01
@ivanpovazan
Copy link
Member Author

CI failures are unrelated.

Code = "IL2067",
Messages = new List<string>
{
"Microsoft.Maui.Controls.ResourceDictionary.<>c.<SetAndLoadSource>b__8_0(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The parameter 'key' of method 'Microsoft.Maui.Controls.ResourceDictionary.<>c.<SetAndLoadSource>b__8_0(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResourceDictionary.<>c.b__8_0(Type): 'type'

If b__8_0 changed to b__9_0, for example, what would the test failure look like? Would it be easy for a random dev to understand?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If b__9_0 starts appearing in the warning message the test would fail with:

Expected warning message 'Microsoft.Maui.Controls.ResourceDictionary.<>c.<SetAndLoadSource>b__8_0(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The parameter 'key' of method 'Microsoft.Maui.Controls.ResourceDictionary.<>c.<SetAndLoadSource>b__8_0(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.' was not found for the expected warnings file path 'src/Controls/src/Core/ResourceDictionary.cs' and warning code 'IL2067'
  Expected: True
  But was:  False

Not sure how intuitive it is, but I tried to include as much information as possible.
Nevertheless, I am open for suggestions on providing better error messages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is probably good enough for now. We can see if problems come up after merging.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One idea (if this turns out to be a problem) could be to do a regexp comparison instead, ignoring the anonymous type parts of the names generated by the C# compiler.

rolfbjarne
rolfbjarne previously approved these changes Dec 13, 2023
Code = "IL2067",
Messages = new List<string>
{
"Microsoft.Maui.Controls.ResourceDictionary.<>c.<SetAndLoadSource>b__8_0(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The parameter 'key' of method 'Microsoft.Maui.Controls.ResourceDictionary.<>c.<SetAndLoadSource>b__8_0(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One idea (if this turns out to be a problem) could be to do a regexp comparison instead, ignoring the anonymous type parts of the names generated by the C# compiler.

@ivanpovazan ivanpovazan added area-testing Unit tests, device tests and removed community ✨ Community Contribution labels Dec 13, 2023
@jonathanpeppers jonathanpeppers merged commit 572fcf2 into dotnet:main Dec 13, 2023
47 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2024
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.

8 participants