Skip to content

Commit

Permalink
Fix platform analyzer attribute order for MacCatalyst (#105410)
Browse files Browse the repository at this point in the history
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<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, Span<byte>, ReadOnlySpan<byte>)' is only supported on: 'maccatalyst' 13.0 and later.

Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
  • Loading branch information
github-actions[bot] and akoeplinger authored Jul 24, 2024
1 parent 416e54c commit 48e5bd6
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ private static ref readonly byte GetSwiftRef(ReadOnlySpan<byte> b)

[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
[SupportedOSPlatform("ios13.0")]
[SupportedOSPlatform("tvos13.0")]
[SupportedOSPlatform("maccatalyst")]
internal static unsafe void ChaCha20Poly1305Encrypt(
ReadOnlySpan<byte> key,
ReadOnlySpan<byte> nonce,
Expand Down Expand Up @@ -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<byte> key,
ReadOnlySpan<byte> nonce,
Expand Down Expand Up @@ -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<byte> key,
ReadOnlySpan<byte> nonce,
Expand Down Expand Up @@ -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<byte> key,
ReadOnlySpan<byte> nonce,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ private static IEnumerable<Measurement<long>> GetGarbageCollectionCounts()
}
}

[SupportedOSPlatform("maccatalyst")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("browser")]
[SupportedOSPlatform("maccatalyst")]
private static IEnumerable<Measurement<double>> GetCpuTime()
{
Debug.Assert(s_processCpuTime is not null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
[SupportedOSPlatform("maccatalyst")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("browser")]
[SupportedOSPlatform("maccatalyst")]
public static ProcessCpuUsage CpuUsage
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
[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) ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}")]
Expand Down Expand Up @@ -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) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 48e5bd6

Please sign in to comment.