From c970afe77a87cb9a570c5a1f41f9397f981ffbf5 Mon Sep 17 00:00:00 2001 From: June Rhodes Date: Wed, 15 Jan 2025 13:57:59 +1100 Subject: [PATCH] Fix remaining .NET 9.0 issues --- .../Helpers/QueryStringExtensions.cs | 6 ++++-- UET/uet/Commands/AppleCert/AppleCertFinalizeCommand.cs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/UET/Lib/Redpoint.ThirdParty.Docker.Registry.DotNet/Helpers/QueryStringExtensions.cs b/UET/Lib/Redpoint.ThirdParty.Docker.Registry.DotNet/Helpers/QueryStringExtensions.cs index b0a9aa1f..7539eb54 100644 --- a/UET/Lib/Redpoint.ThirdParty.Docker.Registry.DotNet/Helpers/QueryStringExtensions.cs +++ b/UET/Lib/Redpoint.ThirdParty.Docker.Registry.DotNet/Helpers/QueryStringExtensions.cs @@ -1,6 +1,7 @@ namespace Docker.Registry.DotNet.Helpers { using System; + using System.Diagnostics.CodeAnalysis; using System.Reflection; using Docker.Registry.DotNet.QueryParameters; @@ -16,12 +17,13 @@ internal static class QueryStringExtensions /// /// /// - internal static void AddFromObjectWithQueryParameters(this QueryString queryString, [NotNull] T instance) + internal static void AddFromObjectWithQueryParameters<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(this QueryString queryString, [JetBrains.Annotations.NotNull] T instance) where T : class { if (instance == null) throw new ArgumentNullException(nameof(instance)); + if (instance.GetType() != typeof(T)) throw new ArgumentException("Expected instance to exactly match T type.", nameof(instance)); - var propertyInfos = instance.GetType().GetProperties(); + var propertyInfos = typeof(T).GetProperties(); foreach (var p in propertyInfos) { diff --git a/UET/uet/Commands/AppleCert/AppleCertFinalizeCommand.cs b/UET/uet/Commands/AppleCert/AppleCertFinalizeCommand.cs index 032558fe..b91fc365 100644 --- a/UET/uet/Commands/AppleCert/AppleCertFinalizeCommand.cs +++ b/UET/uet/Commands/AppleCert/AppleCertFinalizeCommand.cs @@ -106,7 +106,7 @@ public async Task ExecuteAsync(InvocationContext context) } // Import the signed certificate from Apple. - var publicCertificate = new X509Certificate2(Path.Combine(storagePath.FullName, $"{name}.cer"), (string?)null, X509KeyStorageFlags.Exportable); + var publicCertificate = X509CertificateLoader.LoadCertificateFromFile(Path.Combine(storagePath.FullName, $"{name}.cer")); // Attach the private key to the public certificate. publicCertificate = publicCertificate.CopyWithPrivateKey(privateKey); @@ -126,7 +126,7 @@ public async Task ExecuteAsync(InvocationContext context) { var bytes = new byte[embeddedResourceStream.Length]; embeddedResourceStream.ReadExactly(bytes); - intermediateCertificates.Add(new X509Certificate2(bytes, (string?)null)); + intermediateCertificates.Add(X509CertificateLoader.LoadCertificate(bytes)); } } }