Skip to content

Fix Analyser to work with global types#9680

Merged
jonathanpeppers merged 4 commits intomainfrom
dev/dellis1972/globalconstructor
Jan 14, 2025
Merged

Fix Analyser to work with global types#9680
jonathanpeppers merged 4 commits intomainfrom
dev/dellis1972/globalconstructor

Conversation

@dellis1972
Copy link
Copy Markdown
Contributor

@dellis1972 dellis1972 commented Jan 13, 2025

We are seeing the following error in maui apps.

error DNAA0001: Application class 'MainApplication' does not have an Activation Constructor 'MainApplication(IntPtr handle, JniHandleOwnership transfer)'. 

this is because they are using global::Android.Runtime.JniHandleOwnership rather than Android.Runtime.JniHandleOwnership. This causes our string comparisons to fail to we report a false error message.

Rather than using .ToString() we should switch over to using QualifiedNameSyntax and IdentifierNameSyntax to get the name of the class. This allows us to remove some string comparisons as we can now get the name of the class without the full namespace if it has a global:: prefix.

@dellis1972 dellis1972 marked this pull request as ready for review January 14, 2025 12:01
@dellis1972 dellis1972 requested a review from jonpryor as a code owner January 14, 2025 12:01
@dellis1972 dellis1972 removed the request for review from jonpryor January 14, 2025 13:05
Comment thread src/Microsoft.Android.Sdk.Analysis/Tests/DNAA0001Tests.cs Outdated
Copy link
Copy Markdown
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

This looks good now, I reran some test lanes.

@jonathanpeppers jonathanpeppers merged commit 9f5dc78 into main Jan 14, 2025
@jonathanpeppers jonathanpeppers deleted the dev/dellis1972/globalconstructor branch January 14, 2025 21:17
grendello added a commit that referenced this pull request Jan 15, 2025
* main:
  [illink] consolidate & remove hardcoded assembly names (#9662)
  Bump to NuGet/NuGet.Client@aa7eb998 (#9682)
  [Microsoft.Android.Sdk.Analysis] fix global types (#9680)
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants