Skip to content

Commit dee6870

Browse files
committed
feat!: Bump to net6 preview 13.2
BREAKING CHANGE: This update contains binary breaking changes to follow .NET 6 Mobile iOS/macOS/Catalyst API changes. It requires Visual Studio 2022 17.2 Preview 1 or later and cannot work on previous VS 2022 releases.
1 parent a2ce826 commit dee6870

File tree

13 files changed

+118
-31
lines changed

13 files changed

+118
-31
lines changed

build/ci/templates/dotnet6-install-mac.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
parameters:
2-
DotNetVersion: '6.0.200-preview.22055.15'
2+
DotNetVersion: '6.0.200'
33
UnoCheck_Version: '1.1.0-dev.22'
4-
UnoCheck_Manifest: 'https://raw.githubusercontent.com/unoplatform/uno.check/4b89f56d8fa3f2cdd980425dcc8cbc4db1249d99/manifests/uno.ui-preview.manifest.json'
4+
UnoCheck_Manifest: 'https://raw.githubusercontent.com/unoplatform/uno.check/90603a57991621c9998fa66534a14e5bf470acc4/manifests/uno.ui-preview.manifest.json'
55
Dotnet_Root: '/usr/local/share/dotnet/'
66
Dotnet_Tools: '~/.dotnet/tools'
77

@@ -20,14 +20,23 @@ steps:
2020
version: 3.1.x
2121
installationPath: ${{ parameters.Dotnet_Root }}
2222

23-
- bash: |
24-
export PATH="${{ parameters.Dotnet_Root }}:${{ parameters.Dotnet_Tools }}:$PATH"
25-
curl -L https://raw.githubusercontent.com/dotnet/install-scripts/7a9d5dcab92cf131fc2d8977052f8c2c2d540e22/src/dotnet-install.sh > dotnet-install.sh
26-
sh dotnet-install.sh --version ${{ parameters.DotNetVersion }} --install-dir $DOTNET_ROOT --verbose
27-
dotnet --list-sdks
28-
echo "##vso[task.setvariable variable=PATH]$PATH"
29-
displayName: install .NET ${{ parameters.DotNetVersion }}
23+
## Required until .NET 6 installs properly using UseDotnet
24+
## using preview builds
25+
# - bash: |
26+
# export PATH="${{ parameters.Dotnet_Root }}:${{ parameters.Dotnet_Tools }}:$PATH"
27+
# curl -L https://raw.githubusercontent.com/dotnet/install-scripts/11b4eebe23d871c074364940d301c3eb53e7c7ec/src/dotnet-install.sh > dotnet-install.sh
28+
# sh dotnet-install.sh --version ${{ parameters.DotNetVersion }} --install-dir $DOTNET_ROOT --verbose
29+
# dotnet --list-sdks
30+
# echo "##vso[task.setvariable variable=PATH]$PATH"
31+
# displayName: install .NET ${{ parameters.DotNetVersion }}
32+
# retryCountOnTaskFailure: 3
33+
34+
- task: UseDotNet@2
35+
displayName: 'Use .NET Core SDK ${{ parameters.DotNetVersion }}'
3036
retryCountOnTaskFailure: 3
37+
inputs:
38+
packageType: sdk
39+
version: ${{ parameters.DotNetVersion }}
3140

3241
- template: jdk-setup.yml
3342

build/ci/templates/dotnet6-install-windows.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
parameters:
2-
DotNetVersion: '6.0.200-preview.22055.15'
2+
DotNetVersion: '6.0.200'
33
UnoCheck_Version: '1.1.0-dev.22'
4-
UnoCheck_Manifest: 'https://raw.githubusercontent.com/unoplatform/uno.check/4b89f56d8fa3f2cdd980425dcc8cbc4db1249d99/manifests/uno.ui-preview.manifest.json'
4+
UnoCheck_Manifest: 'https://raw.githubusercontent.com/unoplatform/uno.check/90603a57991621c9998fa66534a14e5bf470acc4/manifests/uno.ui-preview.manifest.json'
55

66
steps:
77

88
## Required until .NET 6 installs properly on Windows using UseDotnet
9-
- powershell: |
10-
$ProgressPreference = 'SilentlyContinue'
11-
Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile dotnet-install.ps1
12-
& .\dotnet-install.ps1 -Version ${{ parameters.DotNetVersion }} -InstallDir "$env:ProgramFiles\dotnet\" -Verbose
13-
& dotnet --list-sdks
14-
displayName: Install .NET ${{ parameters.DotNetVersion }}
15-
errorActionPreference: stop
9+
## using preview builds
10+
#- powershell: |
11+
# $ProgressPreference = 'SilentlyContinue'
12+
# Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile dotnet-install.ps1
13+
# & .\dotnet-install.ps1 -Version ${{ parameters.DotNetVersion }} -InstallDir "$env:ProgramFiles\dotnet\" -Verbose
14+
# & dotnet --list-sdks
15+
# displayName: Install .NET ${{ parameters.DotNetVersion }}
16+
# errorActionPreference: stop
17+
# retryCountOnTaskFailure: 3
18+
- task: UseDotNet@2
19+
displayName: 'Use .NET Core SDK ${{ parameters.DotNetVersion }}'
1620
retryCountOnTaskFailure: 3
21+
inputs:
22+
packageType: sdk
23+
version: ${{ parameters.DotNetVersion }}
1724

1825
- template: jdk-setup.yml
1926

src/AddIns/Uno.UI.MSAL/AcquireTokenInteractiveParameterBuilderExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ public static AcquireTokenInteractiveParameterBuilder WithUnoHelpers(this Acquir
1515
#if __WASM__
1616
builder.WithCustomWebUi(WasmWebUi.Instance);
1717
#elif __MACOS__
18+
#if NET6_0_OR_GREATER
19+
// WithUnoHelpers is not yet supported for macOS on .NET 6
20+
// builder.WithParentActivityOrWindow(Windows.UI.Xaml.Window.Current.Content.Window);
21+
#else
1822
builder.WithParentActivityOrWindow(Windows.UI.Xaml.Window.Current.Content.Window);
23+
#endif
1924
#endif
2025
return builder;
2126
}

src/Uno.UI/Extensions/Matrix3x2Extensions.iOSmacOS.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ internal static class Matrix3x2Extensions
1111
public static CATransform3D ToTransform3D(this Matrix3x2 matrix)
1212
=> new CATransform3D
1313
{
14+
#if !NET6_0_OR_GREATER
1415
// Note: The transformation X and Y (M31 and M32) are on the fourth row of 4x4 transform matrix.
1516
// Note2: As we cannot assume that there is no marshaling on each value we set, we set only the
1617
// needed values for an affine transform (3x2).
@@ -19,6 +20,16 @@ public static CATransform3D ToTransform3D(this Matrix3x2 matrix)
1920
m21 = matrix.M21, m22 = matrix.M22, // m23 = 0, m24 = 0,
2021
/*m31 = 0, m32 = 0,*/ m33 = 1, // m34 = 0,
2122
m41 = matrix.M31, m42 = matrix.M32, /*m43 = 0,*/ m44 = 1
23+
#else
24+
// Note: The transformation X and Y (M31 and M32) are on the fourth row of 4x4 transform matrix.
25+
// Note2: As we cannot assume that there is no marshaling on each value we set, we set only the
26+
// needed values for an affine transform (3x2).
27+
28+
M11 = matrix.M11, M12 = matrix.M12, // m13 = 0, m14 = 0,
29+
M21 = matrix.M21, M22 = matrix.M22, // m23 = 0, m24 = 0,
30+
/*m31 = 0, m32 = 0,*/ M33 = 1, // m34 = 0,
31+
M41 = matrix.M31, M42 = matrix.M32, /*m43 = 0,*/ M44 = 1
32+
#endif
2233
};
2334
}
2435
}

src/Uno.UI/Services/ResourceService.iOSmacOS.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ private string GetLocalizedStringOrDefault(string id, NSBundle bundle)
3232
// If key is nil and value is non-nil, returns value.
3333
// If key is not found and value is nil or an empty string, returns key.
3434
// If key is not found and value is non-nil and not empty, return value.
35+
#if NET6_0_OR_GREATER
36+
var localizedString = bundle.GetLocalizedString(id, KeyNotFoundValue, null);
37+
#else
3538
#pragma warning disable CS0618 // Type or member is obsolete
3639
var localizedString = bundle.LocalizedString(id, KeyNotFoundValue, null);
3740
#pragma warning restore CS0618 // Type or member is obsolete
41+
#endif
3842

3943
if (localizedString == KeyNotFoundValue)
4044
{

src/Uno.UI/UI/Xaml/Application.macOS.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,13 @@ private void SetCurrentLanguage()
153153

154154
partial void ObserveSystemThemeChanges()
155155
{
156-
NSDistributedNotificationCenter.GetDefaultCenter().AddObserver(
156+
NSDistributedNotificationCenter
157+
#if NET6_0_OR_GREATER
158+
.DefaultCenter
159+
#else
160+
.GetDefaultCenter()
161+
#endif
162+
.AddObserver(
157163
this,
158164
_modeSelector,
159165
_themeChangedNotification,

src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ public partial class MenuFlyout
2020
private static DependencyProperty CancelTextIosOverrideProperty = ToolkitHelper.GetProperty("Uno.UI.Toolkit.MenuFlyoutExtensions", "CancelTextIosOverride");
2121

2222
#pragma warning disable CS0618 // Type or member is obsolete
23-
private string LocalizedCancelString => NSBundle.FromIdentifier("com.apple.UIKit").LocalizedString("Cancel", null);
23+
private string LocalizedCancelString => NSBundle.FromIdentifier("com.apple.UIKit")
24+
#if NET6_0_OR_GREATER
25+
.GetLocalizedString("Cancel", null);
26+
#else
27+
.LocalizedString("Cancel", null);
28+
#endif
2429
#pragma warning restore CS0618 // Type or member is obsolete
2530

2631
internal protected override void Open()

src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.iOS.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,14 @@ private Size LayoutTypography(Size size)
321321
}
322322

323323
_textContainer.Size = size;
324-
return _layoutManager.GetUsedRectForTextContainer(_textContainer).Size;
324+
325+
#if NET6_0_OR_GREATER
326+
return _layoutManager.GetUsedRect
327+
#else
328+
return _layoutManager.GetUsedRectForTextContainer
329+
#endif
330+
331+
(_textContainer).Size;
325332
}
326333
else
327334
{
@@ -344,9 +351,17 @@ private int GetCharacterIndexAtPoint(Point point)
344351
// Find the tapped character's index
345352
var partialFraction = (nfloat)0;
346353
var pointInTextContainer = new CGPoint(point.X - _drawRect.X, point.Y - _drawRect.Y);
354+
355+
#if NET6_0_OR_GREATER
356+
var characterIndex = (int)_layoutManager.GetCharacterIndex
357+
(pointInTextContainer, _layoutManager.TextContainers.FirstOrDefault(), out partialFraction);
358+
#else
347359
#pragma warning disable CS0618 // Type or member is obsolete (For VS2017 compatibility)
348-
var characterIndex = (int)_layoutManager.CharacterIndexForPoint(pointInTextContainer, _layoutManager.TextContainers.FirstOrDefault(), ref partialFraction);
360+
var characterIndex = (int)_layoutManager.CharacterIndexForPoint
361+
(pointInTextContainer, _layoutManager.TextContainers.FirstOrDefault(), ref partialFraction);
349362
#pragma warning restore CS0618 // Type or member is obsolete
363+
#endif
364+
350365

351366
return characterIndex;
352367
}

src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.macOS.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ public override void DrawRect(CGRect rect)
6666
// While DrawBackgroundForGlyphRange will draw the background mark for specified Glyphs DrawGlyphsForGlyphRange will draw the actual Glyphs.
6767

6868
// Note: This part of the code is called only under very specific situations. For most of the scenarios DrawString is used to draw the text.
69-
_layoutManager?.DrawGlyphsForGlyphRange(new NSRange(0, (nint)_layoutManager.NumberOfGlyphs), _drawRect.Location);
69+
#if NET6_0_OR_GREATER
70+
_layoutManager?.DrawGlyphs
71+
#else
72+
_layoutManager?.DrawGlyphsForGlyphRange
73+
#endif
74+
(new NSRange(0, (nint)_layoutManager.NumberOfGlyphs), _drawRect.Location);
7075
}
7176
else
7277
{
@@ -366,7 +371,13 @@ private Size LayoutTypography(Size size)
366371
_textContainer.Size = size;
367372
// Required for GetUsedRectForTextContainer to return a value.
368373
_layoutManager.GetGlyphRange(_textContainer);
369-
return _layoutManager.GetUsedRectForTextContainer(_textContainer).Size;
374+
return _layoutManager
375+
#if NET6_0_OR_GREATER
376+
.GetUsedRect
377+
#else
378+
.GetUsedRectForTextContainer
379+
#endif
380+
(_textContainer).Size;
370381
}
371382
else
372383
{
@@ -390,9 +401,15 @@ private int GetCharacterIndexAtPoint(Point point)
390401
var partialFraction = (nfloat)0;
391402
var pointInTextContainer = new CGPoint(point.X - _drawRect.X, point.Y - _drawRect.Y);
392403

404+
#if NET6_0_OR_GREATER
405+
var characterIndex = (int)_layoutManager.GetCharacterIndex
406+
(pointInTextContainer, _layoutManager.TextContainers.FirstOrDefault(), out partialFraction);
407+
#else
393408
#pragma warning disable CS0618 // Type or member is obsolete (For VS2017 compatibility)
394-
var characterIndex = (int)_layoutManager.CharacterIndexForPoint(pointInTextContainer, _layoutManager.TextContainers.FirstOrDefault(), ref partialFraction);
409+
var characterIndex = (int)_layoutManager.CharacterIndexForPoint
410+
(pointInTextContainer, _layoutManager.TextContainers.FirstOrDefault(), ref partialFraction);
395411
#pragma warning restore CS0618 // Type or member is obsolete
412+
#endif
396413

397414
return characterIndex;
398415
}

src/Uno.UI/UI/Xaml/Media/Animation/Animators/GPUFloatValueAnimator.iOSmacOS.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,16 @@ private UnoCoreAnimation CreateCoreAnimation(
401401
private NSValue ToCASkewTransform(float angleX, float angleY)
402402
{
403403
var matrix = CGAffineTransform.MakeIdentity();
404-
matrix.yx = (float)Math.Tan(MathEx.ToRadians(angleY));
405-
matrix.xy = (float)Math.Tan(MathEx.ToRadians(angleX));
404+
var b = (float)Math.Tan(MathEx.ToRadians(angleY));
405+
var c = (float)Math.Tan(MathEx.ToRadians(angleX));
406+
407+
#if NET6_0_OR_GREATER
408+
matrix.B = b;
409+
matrix.C = c;
410+
#else
411+
matrix.yx = b;
412+
matrix.xy = c;
413+
#endif
406414

407415
return NSValue.FromCATransform3D(CATransform3D.MakeFromAffine(matrix));
408416
}

src/Uno.UI/UI/Xaml/Media/ImageSource.macOS.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private void DownloadUsingPlatformDownloader()
250250

251251
#pragma warning disable CS0618
252252
// fallback on the platform's loader
253-
using (var data = NSData.FromUrl(url, NSDataReadingOptions.Coordinated, out error))
253+
using (var data = NSData.FromUrl(url, NSDataReadingOptions.Mapped, out error))
254254
#pragma warning restore CS0618
255255
{
256256
if (error != null)

src/Uno.UWP/ApplicationModel/Contacts/ContactPicker.iOS.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public partial class ContactPicker
1919
private async Task<Contact[]> PickContactsAsync(bool multiple, CancellationToken token)
2020
{
2121
var window = UIApplication.SharedApplication.KeyWindow;
22-
var controller = window.RootViewController;
22+
var controller = window?.RootViewController;
2323
if (controller == null)
2424
{
2525
throw new InvalidOperationException(

src/Uno.UWP/Security/Authentication/Web/WebAuthenticationBrokerProvider.iOSmacOS.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ void Start()
171171
private class PresentationContextProviderToSharedKeyWindow : NSObject, IASWebAuthenticationPresentationContextProviding
172172
{
173173
#if __IOS__
174-
public UIWindow GetPresentationAnchor(ASWebAuthenticationSession session) => UIApplication.SharedApplication.KeyWindow;
174+
public UIWindow GetPresentationAnchor(ASWebAuthenticationSession session) => UIApplication.SharedApplication.KeyWindow!;
175175
#else
176-
public NSWindow GetPresentationAnchor(ASWebAuthenticationSession session) => NSApplication.SharedApplication.KeyWindow;
176+
public NSWindow GetPresentationAnchor(ASWebAuthenticationSession session) => NSApplication.SharedApplication.KeyWindow!;
177177
#endif
178178
}
179179

0 commit comments

Comments
 (0)