From 48e5bd614bee90d4bca09ad30ba66ca17c2dd480 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:40:13 -0700 Subject: [PATCH] Fix platform analyzer attribute order for MacCatalyst (#105410) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to make sure the attribute for MacCatalyst comes _after_ the iOS one due to how MacCatalyst is a superset of iOS: https://learn.microsoft.com/en-us/dotnet/standard/analyzers/platform-compat-analyzer#platform-inclusion This caused an error in aspnetcore in the latest dependency flow because the analyzer thought AesGcm is _only_ supported on MacCatalyst: > error CA1416: (NETCORE_ENGINEERING_TELEMETRY=Build) This call site is reachable on all platforms. 'AesGcm.Decrypt(ReadOnlySpan, ReadOnlySpan, ReadOnlySpan, Span, ReadOnlySpan)' is only supported on: 'maccatalyst' 13.0 and later. Co-authored-by: Alexander Köplinger --- .../Interop.Aead.cs | 8 ++++---- .../src/System/Diagnostics/Metrics/RuntimeMetrics.cs | 2 +- .../src/System/Environment.UnixOrBrowser.cs | 2 +- .../src/System/Environment.Windows.cs | 2 +- .../ref/System.Security.Cryptography.cs | 4 ++-- .../src/System/Security/Cryptography/AesGcm.cs | 2 +- .../src/System/Security/Cryptography/ChaCha20Poly1305.cs | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Aead.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Aead.cs index 2216415d61873..29d8877142c5e 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Aead.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Aead.cs @@ -30,9 +30,9 @@ private static ref readonly byte GetSwiftRef(ReadOnlySpan b) [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] - [SupportedOSPlatform("maccatalyst")] [SupportedOSPlatform("ios13.0")] [SupportedOSPlatform("tvos13.0")] + [SupportedOSPlatform("maccatalyst")] internal static unsafe void ChaCha20Poly1305Encrypt( ReadOnlySpan key, ReadOnlySpan nonce, @@ -68,9 +68,9 @@ internal static unsafe void ChaCha20Poly1305Encrypt( [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] - [SupportedOSPlatform("maccatalyst")] [SupportedOSPlatform("ios13.0")] [SupportedOSPlatform("tvos13.0")] + [SupportedOSPlatform("maccatalyst")] internal static unsafe void ChaCha20Poly1305Decrypt( ReadOnlySpan key, ReadOnlySpan nonce, @@ -113,9 +113,9 @@ internal static unsafe void ChaCha20Poly1305Decrypt( [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] - [SupportedOSPlatform("maccatalyst")] [SupportedOSPlatform("ios13.0")] [SupportedOSPlatform("tvos13.0")] + [SupportedOSPlatform("maccatalyst")] internal static unsafe void AesGcmEncrypt( ReadOnlySpan key, ReadOnlySpan nonce, @@ -151,9 +151,9 @@ internal static unsafe void AesGcmEncrypt( [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] - [SupportedOSPlatform("maccatalyst")] [SupportedOSPlatform("ios13.0")] [SupportedOSPlatform("tvos13.0")] + [SupportedOSPlatform("maccatalyst")] internal static unsafe void AesGcmDecrypt( ReadOnlySpan key, ReadOnlySpan nonce, diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/RuntimeMetrics.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/RuntimeMetrics.cs index 2857c9538ed04..4af7755b21266 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/RuntimeMetrics.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/RuntimeMetrics.cs @@ -191,10 +191,10 @@ private static IEnumerable> GetGarbageCollectionCounts() } } - [SupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("browser")] + [SupportedOSPlatform("maccatalyst")] private static IEnumerable> GetCpuTime() { Debug.Assert(s_processCpuTime is not null); diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.UnixOrBrowser.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.UnixOrBrowser.cs index eefd1120cb571..6dbbfe272b25b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.UnixOrBrowser.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.UnixOrBrowser.cs @@ -75,10 +75,10 @@ private static int CheckedSysConf(Interop.Sys.SysConfName name) /// Get the CPU usage, including the process time spent running the application code, the process time spent running the operating system code, /// and the total time spent running both the application and operating system code. /// - [SupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("browser")] + [SupportedOSPlatform("maccatalyst")] public static ProcessCpuUsage CpuUsage { get diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs index 2d4e82dca8874..bd2cb5b10ff3f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs @@ -364,10 +364,10 @@ private static unsafe string[] SegmentCommandLine(char* cmdLine) /// Get the CPU usage, including the process time spent running the application code, the process time spent running the operating system code, /// and the total time spent running both the application and operating system code. /// - [SupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("browser")] + [SupportedOSPlatform("maccatalyst")] public static ProcessCpuUsage CpuUsage { get => Interop.Kernel32.GetProcessTimes(Interop.Kernel32.GetCurrentProcess(), out _, out _, out long procKernelTime, out long procUserTime) ? diff --git a/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs b/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs index b38f79b645052..1442fb8fca356 100644 --- a/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs +++ b/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs @@ -121,9 +121,9 @@ public override void GenerateKey() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] - [System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")] [System.Runtime.Versioning.SupportedOSPlatform("ios13.0")] [System.Runtime.Versioning.SupportedOSPlatform("tvos13.0")] + [System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")] public sealed partial class AesGcm : System.IDisposable { [System.ObsoleteAttribute("AesGcm should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size.", DiagnosticId="SYSLIB0053", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] @@ -287,9 +287,9 @@ public AuthenticationTagMismatchException(string? message, System.Exception? inn [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] - [System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")] [System.Runtime.Versioning.SupportedOSPlatform("ios13.0")] [System.Runtime.Versioning.SupportedOSPlatform("tvos13.0")] + [System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")] public sealed partial class ChaCha20Poly1305 : System.IDisposable { public ChaCha20Poly1305(byte[] key) { } diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesGcm.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesGcm.cs index 0a17baea87156..52aa45ebb6d1e 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesGcm.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesGcm.cs @@ -10,9 +10,9 @@ namespace System.Security.Cryptography [UnsupportedOSPlatform("browser")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] - [SupportedOSPlatform("maccatalyst")] [SupportedOSPlatform("ios13.0")] [SupportedOSPlatform("tvos13.0")] + [SupportedOSPlatform("maccatalyst")] public sealed partial class AesGcm : IDisposable { private const int NonceSize = 12; diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ChaCha20Poly1305.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ChaCha20Poly1305.cs index 7e16d9a7aeebb..8cbf36bd73b54 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ChaCha20Poly1305.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ChaCha20Poly1305.cs @@ -9,9 +9,9 @@ namespace System.Security.Cryptography [UnsupportedOSPlatform("browser")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] - [SupportedOSPlatform("maccatalyst")] [SupportedOSPlatform("ios13.0")] [SupportedOSPlatform("tvos13.0")] + [SupportedOSPlatform("maccatalyst")] public sealed partial class ChaCha20Poly1305 : IDisposable { // Per https://tools.ietf.org/html/rfc7539, ChaCha20Poly1305 AEAD requires a 256-bit key and 96-bit nonce,