Skip to content

Commit

Permalink
Merge branch 'main' into xcode15.3-bump
Browse files Browse the repository at this point in the history
  • Loading branch information
dalexsoto authored Feb 14, 2024
2 parents f6f3595 + d437e9c commit cc0fb84
Show file tree
Hide file tree
Showing 26 changed files with 466 additions and 88 deletions.
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="8.0.103-servicing.24108.7">
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="8.0.103-servicing.24112.7">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>34ceb5eeb4c8cf1cb42ed943798fd92c643ab7c4</Sha>
<Sha>43e7082a34d849cc77e5e3f760b0aca82e281639</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink" Version="8.0.0-rtm.23524.7">
<Uri>https://github.com/dotnet/runtime</Uri>
Expand Down Expand Up @@ -61,9 +61,9 @@
<Uri>https://github.com/dotnet/templating</Uri>
<Sha />
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.iOS.Shared" Version="9.0.0-prerelease.24105.1">
<Dependency Name="Microsoft.DotNet.XHarness.iOS.Shared" Version="9.0.0-prerelease.24112.1">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>18d9997c993b22deea92407e990bbd769701de6a</Sha>
<Sha>2f3f51a1adec18475563c8a49fd9b668ae9f2f31</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--Package versions-->
<PropertyGroup>
<!-- Versions updated by maestro -->
<MicrosoftDotnetSdkInternalPackageVersion>8.0.103-servicing.24108.7</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftDotnetSdkInternalPackageVersion>8.0.103-servicing.24112.7</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>8.0.1</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftNETILLinkPackageVersion>8.0.0-rtm.23524.7</MicrosoftNETILLinkPackageVersion>
<MicrosoftDotNetBuildTasksFeedPackageVersion>6.0.0-beta.21212.6</MicrosoftDotNetBuildTasksFeedPackageVersion>
Expand All @@ -11,7 +11,7 @@
<MicrosoftNETRuntimeMonoTargetsSdkPackageVersion>8.0.0</MicrosoftNETRuntimeMonoTargetsSdkPackageVersion>
<MicrosoftTemplateEngineTasksVersion>7.0.100-alpha.1.21601.1</MicrosoftTemplateEngineTasksVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.23509.2</MicrosoftDotNetCecilPackageVersion>
<MicrosoftDotNetXHarnessiOSSharedPackageVersion>9.0.0-prerelease.24105.1</MicrosoftDotNetXHarnessiOSSharedPackageVersion>
<MicrosoftDotNetXHarnessiOSSharedPackageVersion>9.0.0-prerelease.24112.1</MicrosoftDotNetXHarnessiOSSharedPackageVersion>
<!-- Manually updated versions -->
<Emscriptennet7WorkloadVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest80100Version)</Emscriptennet7WorkloadVersion>
<EmscriptenWorkloadVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest80100Version)</EmscriptenWorkloadVersion>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "8.0.103-servicing.24108.7"
"version": "8.0.103-servicing.24112.7"
}
}
1 change: 1 addition & 0 deletions msbuild/ILMerge.targets
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<MergedAssemblies Include="$(OutputPath)/System.Memory.dll" Condition="'$(MergeSystemAssemblies)' == 'true'" />
<MergedAssemblies Include="$(OutputPath)/System.Numerics.Vectors.dll" Condition="'$(MergeSystemAssemblies)' == 'true'" />
<MergedAssemblies Include="$(OutputPath)/System.Reflection.Metadata.dll" Condition="'$(MergeSystemAssemblies)' == 'true'" />
<MergedAssemblies Include="$(OutputPath)/System.Reflection.MetadataLoadContext.dll" Condition="'$(MergeSystemAssemblies)' == 'true'" />
<MergedAssemblies Include="$(OutputPath)/System.Runtime.CompilerServices.Unsafe.dll" Condition="'$(MergeSystemAssemblies)' == 'true'" />
<MergedAssemblies Include="$(OutputPath)/System.Text.Json.dll" Condition="'$(MergeSystemAssemblies)' == 'true'" />
<MergedAssemblies Include="$(OutputPath)/System.Threading.Tasks.Extensions.dll" Condition="'$(MergeSystemAssemblies)' == 'true'" />
Expand Down
62 changes: 28 additions & 34 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/UnpackLibraryResources.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Collections.Generic;

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

using Mono.Cecil;

using Xamarin.Localization.MSBuild;
using Xamarin.Messaging.Build.Client;

#nullable enable

namespace Xamarin.MacDev.Tasks {
public class UnpackLibraryResources : XamarinTask, ITaskCallback, ICancelableTask {
MetadataLoadContext? universe;
List<ITaskItem> unpackedResources = new List<ITaskItem> ();

#region Inputs
Expand All @@ -29,6 +29,9 @@ public class UnpackLibraryResources : XamarinTask, ITaskCallback, ICancelableTas
[Required]
public string IntermediateOutputPath { get; set; } = string.Empty;

[Required]
public ITaskItem [] ReferenceAssemblies { get; set; } = Array.Empty<ITaskItem> ();

[Required]
public ITaskItem [] ReferencedLibraries { get; set; } = Array.Empty<ITaskItem> ();

Expand All @@ -48,6 +51,15 @@ public class UnpackLibraryResources : XamarinTask, ITaskCallback, ICancelableTas
#endregion

public override bool Execute ()
{
try {
return ExecuteImpl ();
} finally {
universe?.Dispose ();
}
}

bool ExecuteImpl ()
{
if (ShouldExecuteRemotely ()) {
var result = new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
Expand Down Expand Up @@ -168,26 +180,6 @@ IEnumerable<ITaskItem> ExtractContentAssembly (string assembly, string intermedi
yield break;
}

// FIXME: Using cecil for now, due to not having IKVM available in the mtbserver build.
// Eventually, we will want to prefer IKVM over cecil if we can work out the build in a sane way.
/*
static IEnumerable<ManifestResource> GetAssemblyManifestResources (string fileName)
{
using (var universe = new IKVM.Reflection.Universe ()) {
IKVM.Reflection.Assembly assembly;
try {
assembly = universe.LoadFile (fileName);
} catch {
yield break;
}
foreach (var _r in assembly.GetManifestResourceNames ()) {
var r = _r;
yield return new ManifestResource (r, () => assembly.GetManifestResourceStream (r));
}
}
}
*/

static string UnmangleResource (string mangled)
{
var unmangled = new StringBuilder (mangled.Length);
Expand Down Expand Up @@ -263,20 +255,22 @@ public bool ShouldCopyToBuildServer (ITaskItem item)

IEnumerable<ManifestResource> GetAssemblyManifestResources (string fileName)
{
AssemblyDefinition? assembly = null;
if (universe is null)
universe = new MetadataLoadContext (new PathAssemblyResolver (ReferenceAssemblies.Select (v => v.ItemSpec)));

Assembly assembly;
try {
try {
assembly = AssemblyDefinition.ReadAssembly (fileName);
} catch {
yield break;
}
assembly = universe.LoadFromAssemblyPath (fileName);
} catch (Exception e) {
Log.LogMessage (MessageImportance.Low, $"Unable to load the assembly '{fileName}: {e}");
yield break;
}

foreach (var _r in assembly.MainModule.Resources.OfType<EmbeddedResource> ()) {
var r = _r;
yield return new ManifestResource (r.Name, r.GetResourceStream);
}
} finally {
assembly?.Dispose ();
foreach (var resourceName in assembly.GetManifestResourceNames ()) {
var info = assembly.GetManifestResourceInfo (resourceName);
if (!info.ResourceLocation.HasFlag (ResourceLocation.Embedded))
continue;
yield return new ManifestResource (resourceName, () => assembly.GetManifestResourceStream (resourceName));
}
}
}
Expand Down
1 change: 1 addition & 0 deletions msbuild/Xamarin.MacDev.Tasks/Xamarin.MacDev.Tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="4.7.0" />
<PackageReference Include="Mono.Cecil" Version="$(MonoCecilPackageVersion)" />
<!-- Compile against Microsoft.Build* NuGet refs, but do not copy to OutputDir. -->
Expand Down
1 change: 1 addition & 0 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
NoOverwrite="@(_BundleResourceWithLogicalName)"
IntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
TargetFrameworkDirectory="$(TargetFrameworkDirectory)"
ReferenceAssemblies="@(ReferencePath);@(ReferenceDependencyPaths)"
ReferencedLibraries="@(_UnpackLibraryResourceItems)">
<Output TaskParameter="BundleResourcesWithLogicalNames" ItemName="_BundleResourceWithLogicalName" />
</UnpackLibraryResources>
Expand Down
21 changes: 21 additions & 0 deletions src/uikit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15912,14 +15912,35 @@ interface UITextView : UITextInput, NSCoding, UIContentSizeCategoryAdjusting, UI
[Export ("clearsOnInsertion")]
bool ClearsOnInsertion { get; set; }

#if !XAMCORE_5_0
[EditorBrowsable (EditorBrowsableState.Never)]
[Obsolete ("Use 'TypingAttributes2' instead, because this property will return null instead of an empty dictionary.")]
#endif
[NullAllowed] // by default this property is null
[Export ("typingAttributes", ArgumentSemantic.Copy)]
NSDictionary TypingAttributes {
#if !XAMCORE_5_0
// this avoids a crash (see unit tests) and behave like UITextField does (return null)
// however, it's un-intuitive and causes other problems (https://github.com/xamarin/xamarin-macios/issues/12709), so remove it the next time we can make a breaking change.
[PreSnippet ("if (SelectedRange.Length == 0) return null;", Optimizable = true)]
#endif
get;
set;
}

#if !XAMCORE_6_0
[NullAllowed] // by default this property is null
[Export ("typingAttributes", ArgumentSemantic.Copy)]
#if XAMCORE_5_0
[Obsolete ("Use 'TypingAttributes' instead.")
[EditorBrowsable (EditorBrowsableState.Never)]
#endif
[Sealed]
NSDictionary TypingAttributes2 {
get;
set;
}
#endif // XAMCORE_6_0

[Export ("selectable")]
bool Selectable { [Bind ("isSelectable")] get; set; }
Expand Down
19 changes: 19 additions & 0 deletions tests/monotouch-test/UIKit/TextViewTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public void EmptySelection ()
{
using (UITextView tv = new UITextView ()) {
Assert.That (tv.SelectedRange.Length, Is.EqualTo ((nint) 0), "SelectedRange");
#if XAMCORE_5_0
Assert.IsNotNull (tv.TypingAttributes, "default");
tv.TypingAttributes = new NSDictionary ();
Assert.IsNotNull (tv.TypingAttributes, "assigned");
#else
Assert.IsNull (tv.TypingAttributes, "default");
// ^ without a [PreSnippet] attribute this would crash like:
// 7 monotouchtest 0x00006340 mono_sigill_signal_handler + 64
Expand All @@ -40,8 +45,22 @@ public void EmptySelection ()
tv.TypingAttributes = new NSDictionary ();
// Assert.IsNotNull (tv.TypingAttributes, "assigned");
// ^ this would still crash
#endif
}
}

#if !XAMCORE_6_0
[Test]
public void EmptySelection2 ()
{
using (UITextView tv = new UITextView ()) {
Assert.That (tv.SelectedRange.Length, Is.EqualTo ((nint) 0), "SelectedRange");
Assert.IsNotNull (tv.TypingAttributes2, "default");
tv.TypingAttributes = new NSDictionary ();
Assert.IsNotNull (tv.TypingAttributes2, "assigned");
}
}
#endif // !XAMCORE_6_0

[Test]
public void NonEmptySelection ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<Reference Include="Microsoft.Build.Utilities.Core" HintPath="$(MSBuildBinPath)\Microsoft.Build.Utilities.Core.dll" />
<Reference Include="Xamarin.iOS.Tasks" HintPath="..\..\..\msbuild\Xamarin.iOS.Tasks\bin\$(Configuration)\netstandard2.0\Xamarin.iOS.Tasks.dll" />
<Reference Include="Xamarin.Localization.MSBuild" HintPath="..\..\..\msbuild\Xamarin.iOS.Tasks\bin\$(Configuration)\netstandard2.0\Xamarin.Localization.MSBuild.dll" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.11.1" />
<PackageReference Include="NUnit.Extension.NUnitV2ResultWriter" Version="3.6.0" />
Expand Down
51 changes: 32 additions & 19 deletions tests/xharness/Harness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,28 +153,41 @@ string SdkRoot {
}
}

bool TryGetMlaunchDotnetPath (out string value)
{
value = null;

if (!ENABLE_DOTNET)
return false;

ApplePlatform platform;
if (INCLUDE_IOS) {
platform = ApplePlatform.iOS;
} else if (INCLUDE_TVOS) {
platform = ApplePlatform.TVOS;
} else {
return false;
}

var sdkPlatform = platform.AsString ().ToUpperInvariant ();
var sdkName = GetVariable ($"{sdkPlatform}_NUGET_SDK_NAME");
// there is a diff between getting the path for the current platform when running on CI or off CI. The config files in the CI do not
// contain the correct workload version, the reason for this is that the workload is built in a different machine which means that
// the Make.config will use the wrong version. The CI set the version in the environment variable {platform}_WORKLOAD_VERSION via a script.
var workloadVersion = GetVariable ($"{sdkPlatform}_WORKLOAD_VERSION");
var sdkVersion = GetVariable ($"{sdkPlatform}_NUGET_VERSION_NO_METADATA");
value = Path.Combine (DOTNET_DIR, "packs", sdkName, string.IsNullOrEmpty (workloadVersion) ? sdkVersion : workloadVersion, "tools", "bin", "mlaunch");
return true;
}

string MlaunchPath {
get {
if (ENABLE_DOTNET) {
ApplePlatform platform;
if (INCLUDE_IOS) {
platform = ApplePlatform.iOS;
} else if (INCLUDE_TVOS) {
platform = ApplePlatform.TVOS;
} else {
return $"Not building any mobile platform, so can't provide a location to mlaunch.";
}
var sdkPlatform = platform.AsString ().ToUpperInvariant ();
var sdkName = GetVariable ($"{sdkPlatform}_NUGET_SDK_NAME");
// there is a diff between getting the path for the current platform when running on CI or off CI. The config files in the CI do not
// contain the correct workload version, the reason for this is that the workload is built in a different machine which means that
// the Make.config will use the wrong version. The CI set the version in the environment variable {platform}_WORKLOAD_VERSION via a script.
var workloadVersion = GetVariable ($"{sdkPlatform}_WORKLOAD_VERSION");
var sdkVersion = GetVariable ($"{sdkPlatform}_NUGET_VERSION_NO_METADATA");
return Path.Combine (DOTNET_DIR, "packs", sdkName, string.IsNullOrEmpty (workloadVersion) ? sdkVersion : workloadVersion, "tools", "bin", "mlaunch");
} else if (INCLUDE_XAMARIN_LEGACY && INCLUDE_IOS) {
if (TryGetMlaunchDotnetPath (out var mlaunch))
return mlaunch;

if (INCLUDE_XAMARIN_LEGACY && (INCLUDE_IOS || INCLUDE_TVOS || INCLUDE_WATCH))
return Path.Combine (IOS_DESTDIR, "Library", "Frameworks", "Xamarin.iOS.framework", "Versions", "Current", "bin", "mlaunch");
}

return $"Not building any mobile platform, so can't provide a location to mlaunch.";
}
}
Expand Down
2 changes: 2 additions & 0 deletions tools/devops/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ device-tests-provisioning.csx: device-tests-provisioning.csx.in Makefile $(TOP)/
-e 's#@MIN_SHARPIE_URL@#$(MIN_SHARPIE_URL)#g' \
-e 's#@INCLUDE_MAC@#$(INCLUDE_MAC)#g' \
-e 's#@INCLUDE_IOS@#$(INCLUDE_IOS)#g' \
-e 's#@INCLUDE_TVOS@#$(INCLUDE_TVOS)#g' \
-e 's#@INCLUDE_WATCH@#$(INCLUDE_WATCH)#g' \
-e 's#@INCLUDE_XAMARIN_LEGACY@#$(INCLUDE_XAMARIN_LEGACY)#g' \
$< > $@;
@echo "Generated $@:"
Expand Down
44 changes: 44 additions & 0 deletions tools/devops/automation/scripts/Governance.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
class APIScanConfiguration {
[string[]] $enabledPlatforms

APIScanConfiguration (
[string[]] $enabledPlatforms) {
$this.enabledPlatforms = $enabledPlatforms
}

[string] Create() {
$vars = [ordered]@{}
Write-Host "enabledPlatforms: $($this.enabledPlatforms)"

foreach ($platform in $this.enabledPlatforms) {
# dictionary with the secrets needed by each matrix
$platformVars = [ordered]@{
CLIENT_ID = $Env:API_SCAN_CLIENT_ID;
TENANT = $Env:API_SCAN_TENANT;
SECRET = "`$(API_SCAN_SECRET_$($platform.ToUpper()))";
PLATFORM = $platform.ToUpper();
}
$vars[$platform] = $platformVars
}

return $vars | ConvertTo-Json
}

}

function Get-APIScanConfiguration {
param
(
[Parameter(Mandatory)]
[string]
[AllowEmptyString()]
$EnabledPlatforms
)

$arrEnabledPlatforms = -split $EnabledPlatforms
$config = [APIScanConfiguration]::new($arrEnabledPlatforms)
return $config.Create()
}

# export public functions, other functions are private and should not be used outside the module.
Export-ModuleMember -Function Get-APIScanConfiguration
1 change: 1 addition & 0 deletions tools/devops/automation/scripts/MaciosCI.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ ScriptsToProcess = @(
NestedModules = @(
'Artifacts.psm1',
'GitHub.psm1',
'Governance.psm1',
'MLaunch.psm1',
'RemoteMac.psm1',
'StaticPages.psm1',
Expand Down
Loading

0 comments on commit cc0fb84

Please sign in to comment.