-
Notifications
You must be signed in to change notification settings - Fork 735
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
mcNets
wants to merge
19
commits into
unoplatform:master
Choose a base branch
from
mcNets:platform-runtime-helper
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+122
−0
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c0aef67
feat: Added PlatformRuntimeHelper to get the current target at runtime.
mcNets 1c3106f
Added a RuntimeHelper to Toolkit
mcNets 4da5a6b
fix: Added WinUI specific enums
mcNets 0349cc8
fix: Update src/Uno.UI.Toolkit/UnoRuntimePlatform.cs
mcNets 231b43f
fix: Some errors pointed out in conversation.
mcNets 2cee6c0
Merge branch 'platform-runtime-helper' of https://github.com/mcNets/u…
mcNets 9c801db
fix: Typo fixed.
mcNets c30a070
fix: PlatformRuntimeHelper must be public.,
mcNets a0cdd81
fix: Same name in Uno.UI.Helper and Uno.UI.Toolkit
mcNets 59dffec
feat: Added PlatformRuntimeHelper to get the current target at runtime.
mcNets ca9e0c2
feat: Added a RuntimeHelper to Toolkit
mcNets 2bbd9d4
fix: Added WinUI specific enums
mcNets 4e6a320
fix: Some errors pointed out in conversation.
mcNets 545651d
fix: Typo fixed.
mcNets 7fbe6d4
fix: PlatformRuntimeHelper must be public.,
mcNets b5035d9
fix: Same name in Uno.UI.Helper and Uno.UI.Toolkit
mcNets 6475085
Merge branch 'platform-runtime-helper' of https://github.com/mcNets/u…
mcNets 4767456
Merge branch 'master' into platform-runtime-helper
mcNets 46a9f73
fix: WPF points to SkiaWpfIslands, default to Unknown
mcNets File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Uno.UI.Helpers; | ||
|
||
namespace Uno.UI.Toolkit; | ||
|
||
public static class PlatformRuntimeHelper | ||
{ | ||
public static UnoRuntimePlatform Current => | ||
#if !HAS_UNO | ||
Uno.UI.Toolkit.UnoRuntimePlatform.Windows; | ||
#else | ||
(Uno.UI.Toolkit.UnoRuntimePlatform)PlatformRuntimeHelper.Current; | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Uno.UI.Toolkit; | ||
|
||
public enum UnoRuntimePlatform | ||
{ | ||
Unknown, | ||
Android, | ||
iOS, | ||
MacCatalyst, | ||
MacOSX, | ||
WebAssembly, | ||
Windows, | ||
SkiaGtk, | ||
SkiaWpfIslands, | ||
SkiaX11, | ||
SkiaFrameBuffer, | ||
SkiaMacOS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Uno.UI.Helpers; | ||
|
||
public static class PlatformRuntimeHelper | ||
{ | ||
internal static UnoRuntimePlatform SkiaPlatform { get; set; } = UnoRuntimePlatform.Unknown; | ||
|
||
public static UnoRuntimePlatform Current => GetPlatform(); | ||
|
||
private static UnoRuntimePlatform GetPlatform() => | ||
#if __ANDROID__ | ||
UnoRuntimePlatform.Android; | ||
#elif __IOS__ | ||
UnoRuntimePlatform.iOS; | ||
#elif __MACCATALYST__ | ||
UnoRuntimePlatform.MacCatalyst; | ||
#elif __MACOS__ | ||
UnoRuntimePlatform.MacOSX; | ||
#elif __WASM__ | ||
UnoRuntimePlatform.WebAssembly; | ||
#elif __SKIA__ | ||
SkiaPlatform; | ||
#else | ||
UnoRuntimePlatform.Unknown; | ||
#endif | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Uno.UI.Helpers; | ||
|
||
public enum UnoRuntimePlatform | ||
{ | ||
Unknown, | ||
Android, | ||
iOS, | ||
MacCatalyst, | ||
MacOSX, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
WebAssembly, | ||
Windows, | ||
SkiaGtk, | ||
SkiaWpfIslands, | ||
SkiaX11, | ||
SkiaFrameBuffer, | ||
SkiaMacOS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Uno.UI.Helpers; | ||
|
||
internal static class UnoRuntimePlatformExtensions | ||
{ | ||
public static bool IsSkia(UnoRuntimePlatform platform) | ||
{ | ||
return platform == UnoRuntimePlatform.SkiaFrameBuffer | ||
|| platform == UnoRuntimePlatform.SkiaGtk | ||
|| platform == UnoRuntimePlatform.SkiaMacOS | ||
|| platform == UnoRuntimePlatform.SkiaWpfIslands | ||
|| platform == UnoRuntimePlatform.SkiaX11; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 notUnknown
- this will future proof us against potential new platforms being added and us forgetting to update this code path