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

feat: Platform runtime helper #18758

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

mcNets
Copy link
Contributor

@mcNets mcNets commented Nov 9, 2024

GitHub Issue (If applicable): closes #11545

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

You have to use conditionals to knot the current platform runtime.

What is the new behavior?

You can use RuntimeHelper.CurrentPlatform enumeration.

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

Follow this conversation:
#18432 (reply in thread)

I've had some issues with the filtered solutions, I've had been able to test it in Skia only.

Please, someone else should check the other platforms.

Internal Issue (If applicable):
#11545

@github-actions github-actions bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Nov 9, 2024
Comment on lines 18 to 22
SkiaGtk,
SkiaWpf,
SkiaX11,
SkiaFrameBuffer,
SkiaMacOS,
Copy link
Member

Choose a reason for hiding this comment

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

SkiaIslands?

Copy link
Member

Choose a reason for hiding this comment

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

In such case I would go with SkiaWpfIslands to make it even more specific

@MartinZikmund MartinZikmund force-pushed the platform-runtime-helper branch from a0cdd81 to b5035d9 Compare November 21, 2024 11:05
@MartinZikmund
Copy link
Member

@mcNets rebased on latest master and adjusted the faulty commit message, hopefully now the PR will be green

Comment on lines 18 to 22
SkiaGtk,
SkiaWpf,
SkiaX11,
SkiaFrameBuffer,
SkiaMacOS,
Copy link
Member

Choose a reason for hiding this comment

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

In such case I would go with SkiaWpfIslands to make it even more specific

Android,
iOS,
MacCatalyst,
MacOSX,
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 this entry is not necessary, as it is actually only temporary anyway, as we will be dropping the legacy macOS implementation

src/Uno.UI/Helpers/UnoRuntimePlatform.cs Outdated Show resolved Hide resolved

public static UnoRuntimePlatform Current => GetPlatform();

private static UnoRuntimePlatform GetPlatform() =>
Copy link
Member

Choose a reason for hiding this comment

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

Please add a runtime test that gets the value from GetPlatform() at runtime and checks that the result is not Unknown - this will future proof us against potential new platforms being added and us forgetting to update this code path

SkiaX11,
SkiaFrameBuffer,
SkiaMacOS,
Unknown
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 Unknown should be the default value - (= 0)

@MartinZikmund
Copy link
Member

@mcNets Nice PR! I know we are thorough with the review, but as this can be a very useful and frequently used API and it is public, we want to make sure to get it right 🙏

@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-18758/index.html

@mcNets
Copy link
Contributor Author

mcNets commented Nov 21, 2024

@MartinZikmund I've set default to Unknown, I removed IsAndroid, IsIOS, etc, and changed SkiaWpf by SkiaWpfIslands. I'll merged main branch again but still not green.

Where should I add the test: Uno.UI.Test.Helpers?

@unodevops
Copy link
Contributor

⚠️⚠️ The build 148080 has failed on Uno.UI - CI.

@unodevops
Copy link
Contributor

⚠️⚠️ The build 148061 has failed on Uno.UI - docs.

@MartinZikmund
Copy link
Member

@mcNets the test belongs in Uno.UI.RuntimeTests as it needs to run on each platform at runtime. There is this folder - https://github.com/unoplatform/uno/tree/master/src/Uno.UI.RuntimeTests/Tests/Uno_UI_Toolkit where you can add your new test class. Theoretically you can also add platform-specific tests in that test class as well - e.g.:

  • GetPlatform_Not_Unknown()
  • #if __ANDROID__ -> GetPlatform_IsAndroid()
  • #if __iOS__ -> GetPlatform_IsiOS()
  • etc.

@mcNets
Copy link
Contributor Author

mcNets commented Nov 25, 2024

@MartinZikmund Do you know why CodeQL test is always failling?

@jeromelaban
Copy link
Member

@MartinZikmund Do you know why CodeQL test is always failling?

This was fixed a few merges ago, the next build will succeed.

@unodevops
Copy link
Contributor

⚠️⚠️ The build 149380 has failed on Uno.UI - docs.

@unodevops
Copy link
Contributor

⚠️⚠️ The build 149382 has failed on Uno.UI - CI.

@mcNets
Copy link
Contributor Author

mcNets commented Dec 5, 2024

@MartinZikmund I've added the tests now, I've checked with Skia and it pass.

I'm trying to reword the commit that is causing red on conventional commits, but I'm getting some issue with the git rebase.

@Youssef1313 , @spouliot Would you mind taking a look at the unresolved conversations and let me know if they can be closed?

@unodevops
Copy link
Contributor

⚠️⚠️ The build 149475 has failed on Uno.UI - docs.

@unodevops
Copy link
Contributor

⚠️⚠️ The build 149476 has failed on Uno.UI - CI.

@MartinZikmund MartinZikmund force-pushed the platform-runtime-helper branch from ff8e2bd to e2675e1 Compare December 12, 2024 17:25
@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-18758/index.html

@unodevops
Copy link
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-18758/index.html

@unodevops
Copy link
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-18758/index.html

@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-18758/index.html

@mcNets
Copy link
Contributor Author

mcNets commented Dec 17, 2024

@jeromelaban there are still some test that they fail, and it seems that at least one of them is required. Any advice on what should I look for?

@MartinZikmund
Copy link
Member

MartinZikmund commented Dec 26, 2024

@mcNets the fails occurs specifically on WPF Islands:

image

You can use the https://github.com/unoplatform/uno/tree/master/src/SamplesApp/UnoIslandsSamplesApp.Skia.Wpf app to run these two locally and see what is the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/skia ✏️ Categorizes an issue or PR as relevant to Skia
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an API to get the current Uno Platform target at runtime
6 participants