diff --git a/Directory.Build.props b/Directory.Build.props index 3e88500497..a26b191823 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,6 +10,7 @@ true false + true diff --git a/Directory.Packages.props b/Directory.Packages.props index d523737aa9..dfb0f023f4 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -56,8 +56,8 @@ - - + + diff --git a/LibsAndSamples.sln b/LibsAndSamples.sln index a968596645..16af8a830b 100644 --- a/LibsAndSamples.sln +++ b/LibsAndSamples.sln @@ -554,7 +554,6 @@ Global {24D2AF71-A01E-4450-8C3F-B9923A81134B}.Debug + MobileApps|x86.ActiveCfg = Debug + MobileApps|Any CPU {24D2AF71-A01E-4450-8C3F-B9923A81134B}.Debug + MobileApps|x86.Build.0 = Debug + MobileApps|Any CPU {24D2AF71-A01E-4450-8C3F-B9923A81134B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {24D2AF71-A01E-4450-8C3F-B9923A81134B}.Debug|Any CPU.Build.0 = Debug|Any CPU {24D2AF71-A01E-4450-8C3F-B9923A81134B}.Debug|ARM.ActiveCfg = Debug|Any CPU {24D2AF71-A01E-4450-8C3F-B9923A81134B}.Debug|ARM.Build.0 = Debug|Any CPU {24D2AF71-A01E-4450-8C3F-B9923A81134B}.Debug|ARM64.ActiveCfg = Debug|Any CPU @@ -609,7 +608,6 @@ Global {959A47D9-07E7-4BF3-A0F7-6D9CD42A2C46}.Debug|x86.ActiveCfg = Debug|Any CPU {959A47D9-07E7-4BF3-A0F7-6D9CD42A2C46}.Debug|x86.Build.0 = Debug|Any CPU {959A47D9-07E7-4BF3-A0F7-6D9CD42A2C46}.Release|Any CPU.ActiveCfg = Release|Any CPU - {959A47D9-07E7-4BF3-A0F7-6D9CD42A2C46}.Release|Any CPU.Build.0 = Release|Any CPU {959A47D9-07E7-4BF3-A0F7-6D9CD42A2C46}.Release|ARM.ActiveCfg = Release|Any CPU {959A47D9-07E7-4BF3-A0F7-6D9CD42A2C46}.Release|ARM.Build.0 = Release|Any CPU {959A47D9-07E7-4BF3-A0F7-6D9CD42A2C46}.Release|ARM64.ActiveCfg = Release|Any CPU @@ -721,7 +719,6 @@ Global {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Debug + MobileApps|x86.ActiveCfg = Debug + MobileApps|Any CPU {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Debug + MobileApps|x86.Build.0 = Debug + MobileApps|Any CPU {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Debug|Any CPU.Build.0 = Debug|Any CPU {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Debug|ARM.ActiveCfg = Debug|Any CPU {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Debug|ARM.Build.0 = Debug|Any CPU {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Debug|ARM64.ActiveCfg = Debug|Any CPU @@ -735,7 +732,6 @@ Global {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Debug|x86.ActiveCfg = Debug|Any CPU {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Debug|x86.Build.0 = Debug|Any CPU {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Release|Any CPU.Build.0 = Release|Any CPU {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Release|ARM.ActiveCfg = Release|Any CPU {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Release|ARM.Build.0 = Release|Any CPU {E7EB3226-D0F5-4A93-87DC-FAAC9A24D684}.Release|ARM64.ActiveCfg = Release|Any CPU @@ -763,7 +759,6 @@ Global {339E0B2B-4408-4947-B134-E8C5AAB11286}.Debug + MobileApps|x86.ActiveCfg = Debug + MobileApps|Any CPU {339E0B2B-4408-4947-B134-E8C5AAB11286}.Debug + MobileApps|x86.Build.0 = Debug + MobileApps|Any CPU {339E0B2B-4408-4947-B134-E8C5AAB11286}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {339E0B2B-4408-4947-B134-E8C5AAB11286}.Debug|Any CPU.Build.0 = Debug|Any CPU {339E0B2B-4408-4947-B134-E8C5AAB11286}.Debug|ARM.ActiveCfg = Debug|Any CPU {339E0B2B-4408-4947-B134-E8C5AAB11286}.Debug|ARM.Build.0 = Debug|Any CPU {339E0B2B-4408-4947-B134-E8C5AAB11286}.Debug|ARM64.ActiveCfg = Debug|Any CPU @@ -777,7 +772,6 @@ Global {339E0B2B-4408-4947-B134-E8C5AAB11286}.Debug|x86.ActiveCfg = Debug|Any CPU {339E0B2B-4408-4947-B134-E8C5AAB11286}.Debug|x86.Build.0 = Debug|Any CPU {339E0B2B-4408-4947-B134-E8C5AAB11286}.Release|Any CPU.ActiveCfg = Release|Any CPU - {339E0B2B-4408-4947-B134-E8C5AAB11286}.Release|Any CPU.Build.0 = Release|Any CPU {339E0B2B-4408-4947-B134-E8C5AAB11286}.Release|ARM.ActiveCfg = Release|Any CPU {339E0B2B-4408-4947-B134-E8C5AAB11286}.Release|ARM.Build.0 = Release|Any CPU {339E0B2B-4408-4947-B134-E8C5AAB11286}.Release|ARM64.ActiveCfg = Release|Any CPU @@ -805,7 +799,6 @@ Global {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Debug + MobileApps|x86.ActiveCfg = Debug + MobileApps|Any CPU {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Debug + MobileApps|x86.Build.0 = Debug + MobileApps|Any CPU {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Debug|Any CPU.Build.0 = Debug|Any CPU {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Debug|ARM.ActiveCfg = Debug|Any CPU {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Debug|ARM.Build.0 = Debug|Any CPU {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Debug|ARM64.ActiveCfg = Debug|Any CPU @@ -819,7 +812,6 @@ Global {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Debug|x86.ActiveCfg = Debug|Any CPU {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Debug|x86.Build.0 = Debug|Any CPU {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Release|Any CPU.Build.0 = Release|Any CPU {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Release|ARM.ActiveCfg = Release|Any CPU {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Release|ARM.Build.0 = Release|Any CPU {2AF48872-DD47-4DA1-A153-DF4DA13882C2}.Release|ARM64.ActiveCfg = Release|Any CPU @@ -1014,7 +1006,6 @@ Global {998D38B3-344C-4F19-833E-6181B0834AF6}.Debug + MobileApps|x86.ActiveCfg = Debug + MobileApps|Any CPU {998D38B3-344C-4F19-833E-6181B0834AF6}.Debug + MobileApps|x86.Build.0 = Debug + MobileApps|Any CPU {998D38B3-344C-4F19-833E-6181B0834AF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {998D38B3-344C-4F19-833E-6181B0834AF6}.Debug|Any CPU.Build.0 = Debug|Any CPU {998D38B3-344C-4F19-833E-6181B0834AF6}.Debug|ARM.ActiveCfg = Debug|Any CPU {998D38B3-344C-4F19-833E-6181B0834AF6}.Debug|ARM.Build.0 = Debug|Any CPU {998D38B3-344C-4F19-833E-6181B0834AF6}.Debug|ARM64.ActiveCfg = Debug|Any CPU @@ -1182,7 +1173,6 @@ Global {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Debug + MobileApps|x86.ActiveCfg = Debug|Any CPU {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Debug + MobileApps|x86.Build.0 = Debug|Any CPU {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Debug|Any CPU.Build.0 = Debug|Any CPU {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Debug|ARM.ActiveCfg = Debug|Any CPU {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Debug|ARM.Build.0 = Debug|Any CPU {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Debug|ARM64.ActiveCfg = Debug|Any CPU @@ -1196,7 +1186,6 @@ Global {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Debug|x86.ActiveCfg = Debug|Any CPU {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Debug|x86.Build.0 = Debug|Any CPU {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Release|Any CPU.Build.0 = Release|Any CPU {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Release|ARM.ActiveCfg = Release|Any CPU {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Release|ARM.Build.0 = Release|Any CPU {3A2042E9-8B03-4F2D-A2B7-EA4BEC36340C}.Release|ARM64.ActiveCfg = Release|Any CPU @@ -1231,8 +1220,6 @@ Global {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Debug + MobileApps|x86.Build.0 = Debug|x86 {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Debug + MobileApps|x86.Deploy.0 = Debug|x86 {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Debug|ARM.ActiveCfg = Debug|ARM {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Debug|ARM.Build.0 = Debug|ARM {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Debug|ARM.Deploy.0 = Debug|ARM @@ -1252,8 +1239,6 @@ Global {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Debug|x86.Build.0 = Debug|x86 {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Debug|x86.Deploy.0 = Debug|x86 {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Release|Any CPU.Build.0 = Release|Any CPU - {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Release|Any CPU.Deploy.0 = Release|Any CPU {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Release|ARM.ActiveCfg = Release|ARM {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Release|ARM.Build.0 = Release|ARM {34E323E8-E706-4DF4-B916-D614FC8CFCEB}.Release|ARM.Deploy.0 = Release|ARM @@ -1371,7 +1356,6 @@ Global {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Debug + MobileApps|x86.ActiveCfg = Debug|Any CPU {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Debug + MobileApps|x86.Build.0 = Debug|Any CPU {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Debug|Any CPU.Build.0 = Debug|Any CPU {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Debug|ARM.ActiveCfg = Debug|Any CPU {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Debug|ARM.Build.0 = Debug|Any CPU {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Debug|ARM64.ActiveCfg = Debug|Any CPU @@ -1385,7 +1369,6 @@ Global {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Debug|x86.ActiveCfg = Debug|Any CPU {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Debug|x86.Build.0 = Debug|Any CPU {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Release|Any CPU.Build.0 = Release|Any CPU {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Release|ARM.ActiveCfg = Release|Any CPU {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Release|ARM.Build.0 = Release|Any CPU {B381269F-44DA-4E46-8F51-1F1DF7D1F61D}.Release|ARM64.ActiveCfg = Release|Any CPU @@ -1413,7 +1396,6 @@ Global {4EA542D2-D4C9-403C-B615-0047D0A62790}.Debug + MobileApps|x86.ActiveCfg = Debug|Any CPU {4EA542D2-D4C9-403C-B615-0047D0A62790}.Debug + MobileApps|x86.Build.0 = Debug|Any CPU {4EA542D2-D4C9-403C-B615-0047D0A62790}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4EA542D2-D4C9-403C-B615-0047D0A62790}.Debug|Any CPU.Build.0 = Debug|Any CPU {4EA542D2-D4C9-403C-B615-0047D0A62790}.Debug|ARM.ActiveCfg = Debug|Any CPU {4EA542D2-D4C9-403C-B615-0047D0A62790}.Debug|ARM.Build.0 = Debug|Any CPU {4EA542D2-D4C9-403C-B615-0047D0A62790}.Debug|ARM64.ActiveCfg = Debug|Any CPU @@ -1427,7 +1409,6 @@ Global {4EA542D2-D4C9-403C-B615-0047D0A62790}.Debug|x86.ActiveCfg = Debug|Any CPU {4EA542D2-D4C9-403C-B615-0047D0A62790}.Debug|x86.Build.0 = Debug|Any CPU {4EA542D2-D4C9-403C-B615-0047D0A62790}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4EA542D2-D4C9-403C-B615-0047D0A62790}.Release|Any CPU.Build.0 = Release|Any CPU {4EA542D2-D4C9-403C-B615-0047D0A62790}.Release|ARM.ActiveCfg = Release|Any CPU {4EA542D2-D4C9-403C-B615-0047D0A62790}.Release|ARM.Build.0 = Release|Any CPU {4EA542D2-D4C9-403C-B615-0047D0A62790}.Release|ARM64.ActiveCfg = Release|Any CPU @@ -1455,7 +1436,6 @@ Global {1B047736-9325-4F59-906B-89A3E12AC8FB}.Debug + MobileApps|x86.ActiveCfg = Debug|Any CPU {1B047736-9325-4F59-906B-89A3E12AC8FB}.Debug + MobileApps|x86.Build.0 = Debug|Any CPU {1B047736-9325-4F59-906B-89A3E12AC8FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1B047736-9325-4F59-906B-89A3E12AC8FB}.Debug|Any CPU.Build.0 = Debug|Any CPU {1B047736-9325-4F59-906B-89A3E12AC8FB}.Debug|ARM.ActiveCfg = Debug|Any CPU {1B047736-9325-4F59-906B-89A3E12AC8FB}.Debug|ARM.Build.0 = Debug|Any CPU {1B047736-9325-4F59-906B-89A3E12AC8FB}.Debug|ARM64.ActiveCfg = Debug|Any CPU diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 46bfce3c44..d2054177b4 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -25,6 +25,7 @@ true AnyCPU + diff --git a/src/client/Microsoft.Identity.Client.Extensions.Msal/MsalCachePersistenceException.cs b/src/client/Microsoft.Identity.Client.Extensions.Msal/MsalCachePersistenceException.cs index a61839b33a..47d81564a5 100644 --- a/src/client/Microsoft.Identity.Client.Extensions.Msal/MsalCachePersistenceException.cs +++ b/src/client/Microsoft.Identity.Client.Extensions.Msal/MsalCachePersistenceException.cs @@ -41,6 +41,7 @@ public MsalCachePersistenceException(string message, Exception innerException) : /// /// /// + [Obsolete] protected MsalCachePersistenceException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/client/Microsoft.Identity.Client/Platforms/Android/Broker/AndroidAccountManagerBroker.cs b/src/client/Microsoft.Identity.Client/Platforms/Android/Broker/AndroidAccountManagerBroker.cs index b94dbf31c8..21176836e7 100644 --- a/src/client/Microsoft.Identity.Client/Platforms/Android/Broker/AndroidAccountManagerBroker.cs +++ b/src/client/Microsoft.Identity.Client/Platforms/Android/Broker/AndroidAccountManagerBroker.cs @@ -151,7 +151,9 @@ private Intent CreateIntentFromInteractiveBundle(Bundle accountManagerResult, Br _logger.Info("[Android broker] Android account manager didn't return any results for interactive broker request. "); } +#pragma warning disable CA1422 // Validate platform compatibility Intent interactiveIntent = (Intent)accountManagerResult?.GetParcelable(AccountManager.KeyIntent); +#pragma warning restore CA1422 // Validate platform compatibility // Validate that the intent was created successfully. if (interactiveIntent != null) diff --git a/src/client/Microsoft.Identity.Client/Platforms/Android/Broker/AndroidBrokerHelper.cs b/src/client/Microsoft.Identity.Client/Platforms/Android/Broker/AndroidBrokerHelper.cs index 560b78627d..3784ea8edc 100644 --- a/src/client/Microsoft.Identity.Client/Platforms/Android/Broker/AndroidBrokerHelper.cs +++ b/src/client/Microsoft.Identity.Client/Platforms/Android/Broker/AndroidBrokerHelper.cs @@ -210,6 +210,7 @@ private string GetRedirectUriForBroker() return string.Empty; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1422:Validate platform compatibility", Justification = "")] private string GetCurrentSignatureForPackage(string packageName) { try @@ -347,6 +348,7 @@ private void VerifyCertificateChain(List certificates) } } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1422:Validate platform compatibility", Justification = "")] private List ReadCertDataForBrokerApp(string brokerPackageName) { #pragma warning disable CS0618 // Type or member is obsolete https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/1854 diff --git a/src/client/Microsoft.Identity.Client/Platforms/Android/EmbeddedWebview/AuthenticationAgentActivity.cs b/src/client/Microsoft.Identity.Client/Platforms/Android/EmbeddedWebview/AuthenticationAgentActivity.cs index 49b0b29bc0..3cb4e573eb 100644 --- a/src/client/Microsoft.Identity.Client/Platforms/Android/EmbeddedWebview/AuthenticationAgentActivity.cs +++ b/src/client/Microsoft.Identity.Client/Platforms/Android/EmbeddedWebview/AuthenticationAgentActivity.cs @@ -90,7 +90,9 @@ public override void OnLoadResource(WebView view, string url) } [Obsolete] // because parent is obsolete +#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member public override bool ShouldOverrideUrlLoading(WebView view, string url) +#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member { Uri uri = new Uri(url); if (url.StartsWith(BrokerConstants.BrowserExtPrefix, StringComparison.OrdinalIgnoreCase)) diff --git a/src/client/Microsoft.Identity.Client/Platforms/iOS/Broker/iOSBroker.cs b/src/client/Microsoft.Identity.Client/Platforms/iOS/Broker/iOSBroker.cs index 3e5177daa8..f5be2a9da0 100644 --- a/src/client/Microsoft.Identity.Client/Platforms/iOS/Broker/iOSBroker.cs +++ b/src/client/Microsoft.Identity.Client/Platforms/iOS/Broker/iOSBroker.cs @@ -178,6 +178,7 @@ private Dictionary CreateBrokerRequestDictionary( return brokerRequest; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1422:Validate platform compatibility", Justification = "")] public void HandleInstallUrl(string appLink) { DispatchQueue.MainQueue.DispatchAsync(() => UIApplication.SharedApplication.OpenUrl(new NSUrl(appLink))); diff --git a/src/client/Microsoft.Identity.Client/Platforms/iOS/CoreCustomUrlProtocol.cs b/src/client/Microsoft.Identity.Client/Platforms/iOS/CoreCustomUrlProtocol.cs index 3b0d10aafc..ce6dc888ee 100644 --- a/src/client/Microsoft.Identity.Client/Platforms/iOS/CoreCustomUrlProtocol.cs +++ b/src/client/Microsoft.Identity.Client/Platforms/iOS/CoreCustomUrlProtocol.cs @@ -22,7 +22,7 @@ public static bool canInitWithRequest(NSUrlRequest request) } [Export("canonicalRequestForRequest:")] - public new static NSUrlRequest GetCanonicalRequest(NSUrlRequest request) + public static new NSUrlRequest GetCanonicalRequest(NSUrlRequest request) { return request; } @@ -45,7 +45,9 @@ public override void StartLoading() NSMutableUrlRequest mutableRequest = (NSMutableUrlRequest)Request.MutableCopy(); SetProperty(new NSString("YES"), "ADURLProtocol", mutableRequest); +#pragma warning disable CA1422 // Validate platform compatibility connection = new NSUrlConnection(mutableRequest, new CoreCustomConnectionDelegate(this), true); +#pragma warning restore CA1422 // Validate platform compatibility } public override void StopLoading() diff --git a/src/client/Microsoft.Identity.Client/Platforms/iOS/EmbeddedWebview/EmbeddedWebUI.cs b/src/client/Microsoft.Identity.Client/Platforms/iOS/EmbeddedWebview/EmbeddedWebUI.cs index 0979932ff6..39ac1aa7aa 100644 --- a/src/client/Microsoft.Identity.Client/Platforms/iOS/EmbeddedWebview/EmbeddedWebUI.cs +++ b/src/client/Microsoft.Identity.Client/Platforms/iOS/EmbeddedWebview/EmbeddedWebUI.cs @@ -17,7 +17,7 @@ internal class EmbeddedWebUI : WebviewBase public RequestContext RequestContext { get; internal set; } public CoreUIParent CoreUIParent { get; set; } - public async override Task AcquireAuthorizationAsync( + public override async Task AcquireAuthorizationAsync( Uri authorizationUri, Uri redirectUri, RequestContext requestContext, @@ -46,7 +46,9 @@ public void Authenticate(Uri authorizationUri, Uri redirectUri, RequestContext r UIViewController viewController = null; InvokeOnMainThread(() => { +#pragma warning disable CA1422 // Validate platform compatibility UIWindow window = UIApplication.SharedApplication.KeyWindow; +#pragma warning restore CA1422 // Validate platform compatibility viewController = CoreUIParent.FindCurrentViewController(window.RootViewController); }); diff --git a/src/client/Microsoft.Identity.Client/Platforms/iOS/EmbeddedWebview/WKWebNavigationDelegate.cs b/src/client/Microsoft.Identity.Client/Platforms/iOS/EmbeddedWebview/WKWebNavigationDelegate.cs index 529f8ef790..8518a4a36f 100644 --- a/src/client/Microsoft.Identity.Client/Platforms/iOS/EmbeddedWebview/WKWebNavigationDelegate.cs +++ b/src/client/Microsoft.Identity.Client/Platforms/iOS/EmbeddedWebview/WKWebNavigationDelegate.cs @@ -41,8 +41,10 @@ public override void DecidePolicy(WKWebView webView, WKNavigationAction navigati }; requestUrlString = httpsUrlBuilder.Uri.AbsoluteUri; +#pragma warning disable CA1422 // Validate platform compatibility DispatchQueue.MainQueue.DispatchAsync( () => UIApplication.SharedApplication.OpenUrl(new NSUrl(requestUrlString))); +#pragma warning restore CA1422 // Validate platform compatibility _authenticationAgentUIViewController.DismissViewController(true, null); decisionHandler(WKNavigationActionPolicy.Cancel); return; diff --git a/src/client/Microsoft.Identity.Client/Platforms/iOS/SystemWebview/ASWebAuthenticationPresentationContextProviderWindow.cs b/src/client/Microsoft.Identity.Client/Platforms/iOS/SystemWebview/ASWebAuthenticationPresentationContextProviderWindow.cs index f887fd0147..e2cbbe7594 100644 --- a/src/client/Microsoft.Identity.Client/Platforms/iOS/SystemWebview/ASWebAuthenticationPresentationContextProviderWindow.cs +++ b/src/client/Microsoft.Identity.Client/Platforms/iOS/SystemWebview/ASWebAuthenticationPresentationContextProviderWindow.cs @@ -10,7 +10,9 @@ internal class ASWebAuthenticationPresentationContextProviderWindow : NSObject, { public UIWindow GetPresentationAnchor(ASWebAuthenticationSession session) { +#pragma warning disable CA1422 // Validate platform compatibility return UIApplication.SharedApplication.KeyWindow; +#pragma warning restore CA1422 // Validate platform compatibility } } } diff --git a/src/client/Microsoft.Identity.Client/Platforms/iOS/SystemWebview/SystemWebUI.cs b/src/client/Microsoft.Identity.Client/Platforms/iOS/SystemWebview/SystemWebUI.cs index 319976123d..457fdb46f9 100644 --- a/src/client/Microsoft.Identity.Client/Platforms/iOS/SystemWebview/SystemWebUI.cs +++ b/src/client/Microsoft.Identity.Client/Platforms/iOS/SystemWebview/SystemWebUI.cs @@ -34,7 +34,9 @@ public override async Task AcquireAuthorizationAsync( s_viewController = null; InvokeOnMainThread(() => { +#pragma warning disable CA1422 // Validate platform compatibility UIWindow window = UIApplication.SharedApplication.KeyWindow; +#pragma warning restore CA1422 // Validate platform compatibility s_viewController = CoreUIParent.FindCurrentViewController(window.RootViewController); }); @@ -59,6 +61,7 @@ public void Authenticate(Uri authorizationUri, Uri redirectUri, RequestContext r { if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0)) { +#pragma warning disable CA1422 // Validate platform compatibility asWebAuthenticationSession = new AuthenticationServices.ASWebAuthenticationSession(new NSUrl(authorizationUri.AbsoluteUri), redirectUri.Scheme, (callbackUrl, error) => { @@ -71,6 +74,7 @@ public void Authenticate(Uri authorizationUri, Uri redirectUri, RequestContext r ContinueAuthentication(callbackUrl.ToString(), RequestContext.Logger); } }); +#pragma warning restore CA1422 // Validate platform compatibility asWebAuthenticationSession.BeginInvokeOnMainThread(() => { diff --git a/src/client/Microsoft.Identity.Client/Platforms/iOS/iOSLegacyCachePersistance.cs b/src/client/Microsoft.Identity.Client/Platforms/iOS/iOSLegacyCachePersistance.cs index 27f22d22e2..d55f8cdf35 100644 --- a/src/client/Microsoft.Identity.Client/Platforms/iOS/iOSLegacyCachePersistance.cs +++ b/src/client/Microsoft.Identity.Client/Platforms/iOS/iOSLegacyCachePersistance.cs @@ -38,6 +38,7 @@ byte[] ILegacyCachePersistence.LoadCache() try { SecStatusCode res; +#pragma warning disable CA1422 // Validate platform compatibility var rec = new SecRecord(SecKind.GenericPassword) { Generic = NSData.FromString(LocalSettingsContainerName), @@ -48,6 +49,7 @@ byte[] ILegacyCachePersistence.LoadCache() Comment = NAME + " Cache", Description = "Storage for cache" }; +#pragma warning restore CA1422 // Validate platform compatibility if (_keychainGroup != null) { @@ -73,6 +75,7 @@ void ILegacyCachePersistence.WriteCache(byte[] serializedCache) { try { +#pragma warning disable CA1422 // Validate platform compatibility var s = new SecRecord(SecKind.GenericPassword) { Generic = NSData.FromString(LocalSettingsContainerName), @@ -83,6 +86,7 @@ void ILegacyCachePersistence.WriteCache(byte[] serializedCache) Comment = NAME + " Cache", Description = "Storage for cache" }; +#pragma warning restore CA1422 // Validate platform compatibility if (_keychainGroup != null) { diff --git a/src/client/Microsoft.Identity.Client/Platforms/iOS/iOSTokenCacheAccessor.cs b/src/client/Microsoft.Identity.Client/Platforms/iOS/iOSTokenCacheAccessor.cs index 1121735ba6..47dddc5cdb 100644 --- a/src/client/Microsoft.Identity.Client/Platforms/iOS/iOSTokenCacheAccessor.cs +++ b/src/client/Microsoft.Identity.Client/Platforms/iOS/iOSTokenCacheAccessor.cs @@ -43,12 +43,14 @@ public void SetiOSKeychainSecurityGroup(string keychainSecurityGroup) private string GetTeamId() { +#pragma warning disable CA1422 // Validate platform compatibility var queryRecord = new SecRecord(SecKind.GenericPassword) { Service = "", Account = TeamIdKey, Accessible = SecAccessible.Always }; +#pragma warning restore CA1422 // Validate platform compatibility SecRecord match = SecKeyChain.QueryAsRecord(queryRecord, out SecStatusCode resultCode); diff --git a/src/client/Microsoft.Identity.Client/PublicApi/net462/PublicAPI.Shipped.txt b/src/client/Microsoft.Identity.Client/PublicApi/net462/PublicAPI.Shipped.txt index 9adb851e13..b1abb73154 100644 --- a/src/client/Microsoft.Identity.Client/PublicApi/net462/PublicAPI.Shipped.txt +++ b/src/client/Microsoft.Identity.Client/PublicApi/net462/PublicAPI.Shipped.txt @@ -365,8 +365,6 @@ Microsoft.Identity.Client.AuthenticationResultMetadata.RegionDetails.get -> Micr Microsoft.Identity.Client.AuthenticationResultMetadata.RegionDetails.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.Telemetry.get -> string Microsoft.Identity.Client.AuthenticationResultMetadata.Telemetry.set -> void -Microsoft.Identity.Client.AuthenticationResultMetadata.TelemetryTokenType.get -> int -Microsoft.Identity.Client.AuthenticationResultMetadata.TelemetryTokenType.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.TokenEndpoint.get -> string Microsoft.Identity.Client.AuthenticationResultMetadata.TokenEndpoint.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.TokenSource.get -> Microsoft.Identity.Client.TokenSource diff --git a/src/client/Microsoft.Identity.Client/PublicApi/net472/PublicAPI.Shipped.txt b/src/client/Microsoft.Identity.Client/PublicApi/net472/PublicAPI.Shipped.txt index 9adb851e13..b1abb73154 100644 --- a/src/client/Microsoft.Identity.Client/PublicApi/net472/PublicAPI.Shipped.txt +++ b/src/client/Microsoft.Identity.Client/PublicApi/net472/PublicAPI.Shipped.txt @@ -365,8 +365,6 @@ Microsoft.Identity.Client.AuthenticationResultMetadata.RegionDetails.get -> Micr Microsoft.Identity.Client.AuthenticationResultMetadata.RegionDetails.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.Telemetry.get -> string Microsoft.Identity.Client.AuthenticationResultMetadata.Telemetry.set -> void -Microsoft.Identity.Client.AuthenticationResultMetadata.TelemetryTokenType.get -> int -Microsoft.Identity.Client.AuthenticationResultMetadata.TelemetryTokenType.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.TokenEndpoint.get -> string Microsoft.Identity.Client.AuthenticationResultMetadata.TokenEndpoint.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.TokenSource.get -> Microsoft.Identity.Client.TokenSource diff --git a/src/client/Microsoft.Identity.Client/PublicApi/net8.0-android/PublicAPI.Shipped.txt b/src/client/Microsoft.Identity.Client/PublicApi/net8.0-android/PublicAPI.Shipped.txt index 35b6b0f84a..803a599f94 100644 --- a/src/client/Microsoft.Identity.Client/PublicApi/net8.0-android/PublicAPI.Shipped.txt +++ b/src/client/Microsoft.Identity.Client/PublicApi/net8.0-android/PublicAPI.Shipped.txt @@ -366,8 +366,6 @@ Microsoft.Identity.Client.AuthenticationResultMetadata.RegionDetails.get -> Micr Microsoft.Identity.Client.AuthenticationResultMetadata.RegionDetails.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.Telemetry.get -> string Microsoft.Identity.Client.AuthenticationResultMetadata.Telemetry.set -> void -Microsoft.Identity.Client.AuthenticationResultMetadata.TelemetryTokenType.get -> int -Microsoft.Identity.Client.AuthenticationResultMetadata.TelemetryTokenType.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.TokenEndpoint.get -> string Microsoft.Identity.Client.AuthenticationResultMetadata.TokenEndpoint.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.TokenSource.get -> Microsoft.Identity.Client.TokenSource diff --git a/src/client/Microsoft.Identity.Client/PublicApi/net8.0-ios/PublicAPI.Shipped.txt b/src/client/Microsoft.Identity.Client/PublicApi/net8.0-ios/PublicAPI.Shipped.txt index 05c745d913..eacc22c5ca 100644 --- a/src/client/Microsoft.Identity.Client/PublicApi/net8.0-ios/PublicAPI.Shipped.txt +++ b/src/client/Microsoft.Identity.Client/PublicApi/net8.0-ios/PublicAPI.Shipped.txt @@ -370,8 +370,6 @@ Microsoft.Identity.Client.AuthenticationResultMetadata.RegionDetails.get -> Micr Microsoft.Identity.Client.AuthenticationResultMetadata.RegionDetails.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.Telemetry.get -> string Microsoft.Identity.Client.AuthenticationResultMetadata.Telemetry.set -> void -Microsoft.Identity.Client.AuthenticationResultMetadata.TelemetryTokenType.get -> int -Microsoft.Identity.Client.AuthenticationResultMetadata.TelemetryTokenType.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.TokenEndpoint.get -> string Microsoft.Identity.Client.AuthenticationResultMetadata.TokenEndpoint.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.TokenSource.get -> Microsoft.Identity.Client.TokenSource diff --git a/src/client/Microsoft.Identity.Client/PublicApi/net8.0/PublicAPI.Shipped.txt b/src/client/Microsoft.Identity.Client/PublicApi/net8.0/PublicAPI.Shipped.txt index ee3ecd7359..7296019d5d 100644 --- a/src/client/Microsoft.Identity.Client/PublicApi/net8.0/PublicAPI.Shipped.txt +++ b/src/client/Microsoft.Identity.Client/PublicApi/net8.0/PublicAPI.Shipped.txt @@ -362,8 +362,6 @@ Microsoft.Identity.Client.AuthenticationResultMetadata.RegionDetails.get -> Micr Microsoft.Identity.Client.AuthenticationResultMetadata.RegionDetails.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.Telemetry.get -> string Microsoft.Identity.Client.AuthenticationResultMetadata.Telemetry.set -> void -Microsoft.Identity.Client.AuthenticationResultMetadata.TelemetryTokenType.get -> int -Microsoft.Identity.Client.AuthenticationResultMetadata.TelemetryTokenType.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.TokenEndpoint.get -> string Microsoft.Identity.Client.AuthenticationResultMetadata.TokenEndpoint.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.TokenSource.get -> Microsoft.Identity.Client.TokenSource diff --git a/src/client/Microsoft.Identity.Client/PublicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/client/Microsoft.Identity.Client/PublicApi/netstandard2.0/PublicAPI.Shipped.txt index 20837e021c..bbcea292de 100644 --- a/src/client/Microsoft.Identity.Client/PublicApi/netstandard2.0/PublicAPI.Shipped.txt +++ b/src/client/Microsoft.Identity.Client/PublicApi/netstandard2.0/PublicAPI.Shipped.txt @@ -362,8 +362,6 @@ Microsoft.Identity.Client.AuthenticationResultMetadata.RegionDetails.get -> Micr Microsoft.Identity.Client.AuthenticationResultMetadata.RegionDetails.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.Telemetry.get -> string Microsoft.Identity.Client.AuthenticationResultMetadata.Telemetry.set -> void -Microsoft.Identity.Client.AuthenticationResultMetadata.TelemetryTokenType.get -> int -Microsoft.Identity.Client.AuthenticationResultMetadata.TelemetryTokenType.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.TokenEndpoint.get -> string Microsoft.Identity.Client.AuthenticationResultMetadata.TokenEndpoint.set -> void Microsoft.Identity.Client.AuthenticationResultMetadata.TokenSource.get -> Microsoft.Identity.Client.TokenSource diff --git a/src/client/Microsoft.Identity.Client/json/.editorconfig b/src/client/Microsoft.Identity.Client/json/.editorconfig index 2400220bc0..903c3bb67f 100644 --- a/src/client/Microsoft.Identity.Client/json/.editorconfig +++ b/src/client/Microsoft.Identity.Client/json/.editorconfig @@ -29,5 +29,4 @@ dotnet_diagnostic.IDE0036.severity = none dotnet_diagnostic.VSTHRD200.severity = none -dotnet_diagnostic.SYSLIB0050.severity = none -dotnet_diagnostic.SYSLIB0051.severity = none +dotnet_diagnostic.RS0017.severity = error diff --git a/src/client/Microsoft.Identity.Client/json/JsonException.cs b/src/client/Microsoft.Identity.Client/json/JsonException.cs index ba4a2c89f9..48116a50e5 100644 --- a/src/client/Microsoft.Identity.Client/json/JsonException.cs +++ b/src/client/Microsoft.Identity.Client/json/JsonException.cs @@ -77,7 +77,9 @@ public JsonException(string message, Exception? innerException) /// The parameter is null. /// The class name is null or is zero (0). public JsonException(SerializationInfo info, StreamingContext context) +#pragma warning disable SYSLIB0051 // Type or member is obsolete : base(info, context) +#pragma warning restore SYSLIB0051 // Type or member is obsolete { } #endif @@ -89,4 +91,4 @@ internal static JsonException Create(IJsonLineInfo lineInfo, string path, string return new JsonException(message); } } -} \ No newline at end of file +} diff --git a/src/client/Microsoft.Identity.Client/json/Serialization/FormatterConverter.cs b/src/client/Microsoft.Identity.Client/json/Serialization/FormatterConverter.cs index ab953a2f67..9bfc661ce5 100644 --- a/src/client/Microsoft.Identity.Client/json/Serialization/FormatterConverter.cs +++ b/src/client/Microsoft.Identity.Client/json/Serialization/FormatterConverter.cs @@ -8,7 +8,9 @@ namespace Microsoft.Identity.Json.Serialization { +#pragma warning disable SYSLIB0050 // Type or member is obsolete internal class FormatterConverter : IFormatterConverter +#pragma warning restore SYSLIB0050 // Type or member is obsolete { public object Convert(object value, Type type) { @@ -114,4 +116,4 @@ public ulong ToUInt64(object value) } } -#endif \ No newline at end of file +#endif diff --git a/src/client/Microsoft.Identity.Client/json/Serialization/JsonFormatterConverter.cs b/src/client/Microsoft.Identity.Client/json/Serialization/JsonFormatterConverter.cs index 80db8aa775..09417194ed 100644 --- a/src/client/Microsoft.Identity.Client/json/Serialization/JsonFormatterConverter.cs +++ b/src/client/Microsoft.Identity.Client/json/Serialization/JsonFormatterConverter.cs @@ -32,7 +32,9 @@ namespace Microsoft.Identity.Json.Serialization { +#pragma warning disable SYSLIB0050 // Type or member is obsolete internal class JsonFormatterConverter : IFormatterConverter +#pragma warning restore SYSLIB0050 // Type or member is obsolete { private readonly JsonSerializerInternalReader _reader; private readonly JsonISerializableContract _contract; @@ -154,4 +156,4 @@ public ulong ToUInt64(object value) } } -#endif \ No newline at end of file +#endif diff --git a/src/client/Microsoft.Identity.Client/json/Serialization/JsonObjectContract.cs b/src/client/Microsoft.Identity.Client/json/Serialization/JsonObjectContract.cs index 75369510a0..12a490e6eb 100644 --- a/src/client/Microsoft.Identity.Client/json/Serialization/JsonObjectContract.cs +++ b/src/client/Microsoft.Identity.Client/json/Serialization/JsonObjectContract.cs @@ -192,8 +192,10 @@ internal object GetUninitializedObject() throw new JsonException("Insufficient permissions. Creating an uninitialized '{0}' type requires full trust.".FormatWith(CultureInfo.InvariantCulture, NonNullableUnderlyingType)); } +#pragma warning disable SYSLIB0050 // Type or member is obsolete return FormatterServices.GetUninitializedObject(NonNullableUnderlyingType); +#pragma warning restore SYSLIB0050 // Type or member is obsolete } #endif } -} \ No newline at end of file +} diff --git a/src/client/Microsoft.Identity.Client/json/Serialization/JsonSerializerInternalReader.cs b/src/client/Microsoft.Identity.Client/json/Serialization/JsonSerializerInternalReader.cs index eb4f517a0c..e545a0a8a4 100644 --- a/src/client/Microsoft.Identity.Client/json/Serialization/JsonSerializerInternalReader.cs +++ b/src/client/Microsoft.Identity.Client/json/Serialization/JsonSerializerInternalReader.cs @@ -1743,7 +1743,9 @@ private object CreateISerializable(JsonReader reader, JsonISerializableContract TraceWriter.Trace(TraceLevel.Info, JsonPosition.FormatMessage(reader as IJsonLineInfo, reader.Path, "Deserializing {0} using ISerializable constructor.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType)), null); } +#pragma warning disable SYSLIB0050 // Type or member is obsolete SerializationInfo serializationInfo = new SerializationInfo(contract.UnderlyingType, new JsonFormatterConverter(this, contract, member)); +#pragma warning restore SYSLIB0050 // Type or member is obsolete bool finished = false; do diff --git a/src/client/Microsoft.Identity.Client/json/Serialization/JsonSerializerInternalWriter.cs b/src/client/Microsoft.Identity.Client/json/Serialization/JsonSerializerInternalWriter.cs index e93b072d1a..cc20276521 100644 --- a/src/client/Microsoft.Identity.Client/json/Serialization/JsonSerializerInternalWriter.cs +++ b/src/client/Microsoft.Identity.Client/json/Serialization/JsonSerializerInternalWriter.cs @@ -869,8 +869,10 @@ private void SerializeISerializable(JsonWriter writer, ISerializable value, Json WriteObjectStart(writer, value, contract, member, collectionContract, containerProperty); +#pragma warning disable SYSLIB0050 // Type or member is obsolete SerializationInfo serializationInfo = new SerializationInfo(contract.UnderlyingType, new FormatterConverter()); value.GetObjectData(serializationInfo, Serializer._context); +#pragma warning restore SYSLIB0050 // Type or member is obsolete foreach (SerializationEntry serializationEntry in serializationInfo) { @@ -1241,4 +1243,4 @@ private bool IsSpecified(JsonWriter writer, JsonProperty property, object target return isSpecified; } } -} \ No newline at end of file +} diff --git a/src/client/Microsoft.Identity.Client/json/Serialization/JsonTypeReflector.cs b/src/client/Microsoft.Identity.Client/json/Serialization/JsonTypeReflector.cs index 8498a8e73f..a64dac73e1 100644 --- a/src/client/Microsoft.Identity.Client/json/Serialization/JsonTypeReflector.cs +++ b/src/client/Microsoft.Identity.Client/json/Serialization/JsonTypeReflector.cs @@ -396,10 +396,12 @@ public static bool IsNonSerializable(object provider) // no inheritance return (ReflectionUtils.GetAttribute(provider, false) != null); #else +#pragma warning disable SYSLIB0050 // Type or member is obsolete if (provider is FieldInfo fieldInfo && (fieldInfo.Attributes & FieldAttributes.NotSerialized) == FieldAttributes.NotSerialized) { return true; } +#pragma warning restore SYSLIB0050 // Type or member is obsolete return false; #endif @@ -413,10 +415,12 @@ public static bool IsSerializable(object provider) // no inheritance return (ReflectionUtils.GetAttribute(provider, false) != null); #else +#pragma warning disable SYSLIB0050 // Type or member is obsolete if (provider is Type type && (type.GetTypeInfo().Attributes & TypeAttributes.Serializable) == TypeAttributes.Serializable) { return true; } +#pragma warning restore SYSLIB0050 // Type or member is obsolete return false; #endif diff --git a/tests/Microsoft.Identity.Test.Common/Core/Mocks/MockHttpMessageHandler.cs b/tests/Microsoft.Identity.Test.Common/Core/Mocks/MockHttpMessageHandler.cs index 1b25c4cb14..e9161b4da7 100644 --- a/tests/Microsoft.Identity.Test.Common/Core/Mocks/MockHttpMessageHandler.cs +++ b/tests/Microsoft.Identity.Test.Common/Core/Mocks/MockHttpMessageHandler.cs @@ -38,7 +38,7 @@ internal class MockHttpMessageHandler : HttpClientHandler public HttpRequestHeaders ActualRequestHeaders { get; private set; } public X509Certificate2 ExpectedMtlsBindingCertificate { get; set; } - protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { ActualRequestMessage = request; @@ -66,7 +66,7 @@ protected override Task SendAsync(HttpRequestMessage reques ValidateQueryParams(uri); - ValidatePostDataAsync(request); + await ValidatePostDataAsync(request).ConfigureAwait(false); ValidateNotExpectedPostData(); @@ -74,7 +74,7 @@ protected override Task SendAsync(HttpRequestMessage reques AdditionalRequestValidation?.Invoke(request); - return new TaskFactory().StartNew(() => ResponseMessage, cancellationToken); + return ResponseMessage; } private void ValidateQueryParams(Uri uri) diff --git a/tests/Microsoft.Identity.Test.Unit/BrokerTests/BrokerRequestTests.cs b/tests/Microsoft.Identity.Test.Unit/BrokerTests/BrokerRequestTests.cs index fb14ef463c..86e89599ab 100644 --- a/tests/Microsoft.Identity.Test.Unit/BrokerTests/BrokerRequestTests.cs +++ b/tests/Microsoft.Identity.Test.Unit/BrokerTests/BrokerRequestTests.cs @@ -517,7 +517,6 @@ public async Task NullBroker_AcquireSilentInteractive_Async() var app = builder.BuildConcrete(); builder.Config.BrokerCreatorFunc = (_, _, logger) => { return new NullBroker(logger); }; - // Act try { @@ -618,7 +617,6 @@ public async Task BrokerGetAccountsWithBrokerInstalledTestAsync() Assert.AreSame(expectedAccount, actualAccount.Single()); } - [TestMethod] public async Task SilentAuthStrategyFallbackTestAsync() { @@ -653,7 +651,7 @@ public async Task SilentAuthStrategyFallbackTestAsync() var noTokensException = new MsalClientException(MsalError.NoTokensFoundError); mockBrokerStrategy.ExecuteAsync(default).Returns(brokerAuthenticationResult); - mockClientStrategy.ExecuteAsync(default).Throws(invalidGrantException); + mockClientStrategy.ExecuteAsync(default).Returns(Task.FromException(invalidGrantException)); _acquireTokenSilentParameters.Account = new Account("a.b", "user", "lmo"); //Execute silent request with invalid grant @@ -669,14 +667,14 @@ public async Task SilentAuthStrategyFallbackTestAsync() //Execute silent request with no accounts exception mockClientStrategy = Substitute.For(); - mockClientStrategy.ExecuteAsync(new CancellationToken()).Throws(noAccountException); + mockClientStrategy.ExecuteAsync(new CancellationToken()).Returns(Task.FromException(noAccountException)); silentRequest = new SilentRequest(harness.ServiceBundle, _parameters, _acquireTokenSilentParameters, mockClientStrategy, mockBrokerStrategy); result = silentRequest.ExecuteTestAsync(new CancellationToken()).Result; Assert.AreEqual(result, brokerAuthenticationResult); //Execute silent request with no tokens exception mockClientStrategy = Substitute.For(); - mockClientStrategy.ExecuteAsync(new CancellationToken()).Throws(noTokensException); + mockClientStrategy.ExecuteAsync(new CancellationToken()).Returns(Task.FromException(noTokensException)); silentRequest = new SilentRequest(harness.ServiceBundle, _parameters, _acquireTokenSilentParameters, mockClientStrategy, mockBrokerStrategy); result = silentRequest.ExecuteTestAsync(new CancellationToken()).Result; Assert.AreEqual(result, brokerAuthenticationResult); @@ -702,8 +700,8 @@ public void SpecialAccount_CallsBrokerSilentAuth() var mockBrokerStrategy = Substitute.For(); var ar = new AuthenticationResult(); - mockClientStrategy.ExecuteAsync(default).ThrowsForAnyArgs( - new MsalUiRequiredException(MsalError.CurrentBrokerAccount, "msg")); + mockClientStrategy.ExecuteAsync(default).ReturnsForAnyArgs( + Task.FromException(new MsalUiRequiredException(MsalError.CurrentBrokerAccount, "msg"))); mockBrokerStrategy.ExecuteAsync(default).Returns(ar); _acquireTokenSilentParameters.Account = PublicClientApplication.OperatingSystemAccount; var silentRequest = new SilentRequest( @@ -844,10 +842,8 @@ public async Task MultiCloud_WithBroker_Async() builder.Config.BrokerCreatorFunc = (_, _, _) => broker; - var globalPca = builder.BuildConcrete(); - // Setup the broker to return AuthorityUrl in the MsalTokenResponse as different cloud broker.IsBrokerInstalledAndInvokable(AuthorityType.Aad).Returns(true); diff --git a/tests/Microsoft.Identity.Test.Unit/CacheTests/CacheFallbackOperationsTests.cs b/tests/Microsoft.Identity.Test.Unit/CacheTests/CacheFallbackOperationsTests.cs index 95a1105de0..c04a02fc9e 100644 --- a/tests/Microsoft.Identity.Test.Unit/CacheTests/CacheFallbackOperationsTests.cs +++ b/tests/Microsoft.Identity.Test.Unit/CacheTests/CacheFallbackOperationsTests.cs @@ -413,8 +413,6 @@ public void RemoveAdalUser_RemovesUserNoClientInfo_And_NoDisplayName() // Assert AssertCacheEntryCount(6); - - _logger.Received().Error(Arg.Is(MsalErrorMessage.InternalErrorCacheEmptyUsername)); } [TestMethod] @@ -493,9 +491,6 @@ public void WriteAdalRefreshToken_ErrorLog() "scope1"); // Assert - _logger.Received().Error(Arg.Is(CacheFallbackOperations.DifferentAuthorityError)); - - _logger.Received().Error(Arg.Is(CacheFallbackOperations.DifferentEnvError)); } [TestMethod] diff --git a/tests/Microsoft.Identity.Test.Unit/PublicApiTests/AuthenticationOperationTests.cs b/tests/Microsoft.Identity.Test.Unit/PublicApiTests/AuthenticationOperationTests.cs index 735e9d5f7c..c72ca62deb 100644 --- a/tests/Microsoft.Identity.Test.Unit/PublicApiTests/AuthenticationOperationTests.cs +++ b/tests/Microsoft.Identity.Test.Unit/PublicApiTests/AuthenticationOperationTests.cs @@ -166,8 +166,6 @@ public async Task WrongTokenType_Async() authScheme.AuthorizationHeaderPrefix.Returns("BearToken"); authScheme.KeyId.Returns("keyid"); authScheme.GetTokenRequestParams().Returns(new Dictionary() { { "tokenParam", "tokenParamValue" } }); - // When FormatResult is called, change the AccessToken property - authScheme.WhenForAnyArgs(x => x.FormatResult(default)).Do(x => x[0] = "enhanced_secret_" + ((AuthenticationResult)x[0]).AccessToken); using (var httpManager = new MockHttpManager()) { diff --git a/tests/Microsoft.Identity.Test.Unit/RequestsTests/InteractiveRequestOrchestrationTests.cs b/tests/Microsoft.Identity.Test.Unit/RequestsTests/InteractiveRequestOrchestrationTests.cs index 395ee07140..b3415b3b4e 100644 --- a/tests/Microsoft.Identity.Test.Unit/RequestsTests/InteractiveRequestOrchestrationTests.cs +++ b/tests/Microsoft.Identity.Test.Unit/RequestsTests/InteractiveRequestOrchestrationTests.cs @@ -83,18 +83,14 @@ public async Task NoBroker_WebUiOnly_Async() Assert.AreEqual(1, cache.Accessor.GetAllAccessTokens().Count); // Assert - orchestration -#pragma warning disable VSTHRD101 // Avoid unsupported async delegates - Received.InOrder(async () => + Received.InOrder(() => { - await _authCodeRequestComponentOverride - .FetchAuthCodeAndPkceVerifierAsync(default) - .ConfigureAwait(false); + _authCodeRequestComponentOverride + .FetchAuthCodeAndPkceVerifierAsync(default); - await _authCodeExchangeComponentOverride - .FetchTokensAsync(default) - .ConfigureAwait(false); + _authCodeExchangeComponentOverride + .FetchTokensAsync(default); }); -#pragma warning restore VSTHRD101 // Avoid unsupported async delegates await _brokerExchangeComponentOverride .DidNotReceiveWithAnyArgs() @@ -214,22 +210,17 @@ public async Task Broker_Configured_But_Not_Installed_Async() // Assert - orchestration // Assert - orchestration -#pragma warning disable VSTHRD101 // Avoid unsupported async delegates - Received.InOrder(async () => + Received.InOrder(() => { - await _brokerExchangeComponentOverride - .FetchTokensAsync(default) - .ConfigureAwait(false); + _brokerExchangeComponentOverride + .FetchTokensAsync(default); - await _authCodeRequestComponentOverride - .FetchAuthCodeAndPkceVerifierAsync(default) - .ConfigureAwait(false); + _authCodeRequestComponentOverride + .FetchAuthCodeAndPkceVerifierAsync(default); - await _authCodeExchangeComponentOverride - .FetchTokensAsync(default) - .ConfigureAwait(false); + _authCodeExchangeComponentOverride + .FetchTokensAsync(default); }); -#pragma warning restore VSTHRD101 // Avoid unsupported async delegates } } @@ -281,17 +272,13 @@ public async Task Broker_Not_Configured_But_Installed_EvoWantsBroker_Async() Assert.AreEqual(1, cache.Accessor.GetAllAccessTokens().Count); // Assert - orchestration -#pragma warning disable VSTHRD101 // Avoid unsupported async delegates - Received.InOrder(async () => + Received.InOrder(() => { - await _authCodeRequestComponentOverride - .FetchAuthCodeAndPkceVerifierAsync(default) - .ConfigureAwait(false); - await _brokerExchangeComponentOverride - .FetchTokensAsync(default) - .ConfigureAwait(false); + _authCodeRequestComponentOverride + .FetchAuthCodeAndPkceVerifierAsync(default); + _brokerExchangeComponentOverride + .FetchTokensAsync(default); }); -#pragma warning restore VSTHRD101 // Avoid unsupported async delegates await _authCodeExchangeComponentOverride .DidNotReceiveWithAnyArgs() diff --git a/tests/Microsoft.Identity.Test.Unit/TelemetryTests/HttpTelemetryTests.cs b/tests/Microsoft.Identity.Test.Unit/TelemetryTests/HttpTelemetryTests.cs index a0fc353f09..486feaff16 100644 --- a/tests/Microsoft.Identity.Test.Unit/TelemetryTests/HttpTelemetryTests.cs +++ b/tests/Microsoft.Identity.Test.Unit/TelemetryTests/HttpTelemetryTests.cs @@ -572,8 +572,8 @@ private enum AcquireTokenInteractiveOutcome var ui = Substitute.For(); ui.UpdateRedirectUri(Arg.Any()).Returns(new Uri("http://localhost:1234")); - ui.AcquireAuthorizationAsync(null, null, null, default).ThrowsForAnyArgs( - new MsalClientException("user_cancelled")); + ui.AcquireAuthorizationAsync(null, null, null, default).ReturnsForAnyArgs( + Task.FromException(new MsalClientException("user_cancelled"))); _app.ServiceBundle.ConfigureMockWebUI(ui); var ex = await AssertException.TaskThrowsAsync(() => diff --git a/tests/devapps/Directory.Packages.props b/tests/devapps/Directory.Packages.props index d936a70e9d..d45b64b040 100644 --- a/tests/devapps/Directory.Packages.props +++ b/tests/devapps/Directory.Packages.props @@ -2,6 +2,8 @@ false + false + diff --git a/tests/devapps/Managed Identity apps/MSIHelperService/AzureFunction/AquireToken.cs b/tests/devapps/Managed Identity apps/MSIHelperService/AzureFunction/AquireToken.cs index ff189ae7fb..b45f9cd702 100644 --- a/tests/devapps/Managed Identity apps/MSIHelperService/AzureFunction/AquireToken.cs +++ b/tests/devapps/Managed Identity apps/MSIHelperService/AzureFunction/AquireToken.cs @@ -32,7 +32,7 @@ public static async Task Run(HttpRequest req, ILogger log) try { - log.LogInformation("uri : ", uri); + log.LogInformation("uri: {uri}", uri); //set the http get method and the required headers for a web app var requestMessage = new HttpRequestMessage(HttpMethod.Get, uri); diff --git a/tests/devapps/Managed Identity apps/MSIHelperService/AzureFunction/GetEnvironmentVariables.cs b/tests/devapps/Managed Identity apps/MSIHelperService/AzureFunction/GetEnvironmentVariables.cs index a42da2180a..55e45db4ac 100644 --- a/tests/devapps/Managed Identity apps/MSIHelperService/AzureFunction/GetEnvironmentVariables.cs +++ b/tests/devapps/Managed Identity apps/MSIHelperService/AzureFunction/GetEnvironmentVariables.cs @@ -31,7 +31,7 @@ public static IActionResult Run(HttpRequest req, ILogger log) string? name = req.Query["variableName"]; - log.LogInformation("Querystring value for variableName is : ", name); + log.LogInformation("Querystring value for variableName is : {variableName}", name); if (string.IsNullOrEmpty(name)) { @@ -46,7 +46,7 @@ public static IActionResult Run(HttpRequest req, ILogger log) else { string? responseMessage = Environment.GetEnvironmentVariable(name); - log.LogInformation("Returning Environment Variable Based on the variable name : ", name); + log.LogInformation("Returning Environment Variable Based on the variable name : {variableName}", name); return new OkObjectResult(responseMessage); } } diff --git a/tests/devapps/WAM/WAMMauiApp/WAMMauiApp/AppShell.xaml.cs b/tests/devapps/WAM/WAMMauiApp/WAMMauiApp/AppShell.xaml.cs index e6c00d597c..7d0db88f71 100644 --- a/tests/devapps/WAM/WAMMauiApp/WAMMauiApp/AppShell.xaml.cs +++ b/tests/devapps/WAM/WAMMauiApp/WAMMauiApp/AppShell.xaml.cs @@ -1,4 +1,7 @@ -namespace WAMMauiApp; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace WAMMauiApp; public partial class AppShell : Shell { diff --git a/tests/devapps/WAM/WAMMauiApp/WAMMauiApp/WAMMauiApp.csproj b/tests/devapps/WAM/WAMMauiApp/WAMMauiApp/WAMMauiApp.csproj index aa63a846a2..13228bb603 100644 --- a/tests/devapps/WAM/WAMMauiApp/WAMMauiApp/WAMMauiApp.csproj +++ b/tests/devapps/WAM/WAMMauiApp/WAMMauiApp/WAMMauiApp.csproj @@ -1,10 +1,9 @@  - net6.0-windows10.0.19041.0 + net8.0-windows10.0.19041.0 Exe WAMMauiApp - true true enable @@ -45,6 +44,7 @@ + diff --git a/tests/devapps/WebApi/Misc/TestSize.cs b/tests/devapps/WebApi/Misc/TestSize.cs deleted file mode 100644 index fec73eeb6e..0000000000 --- a/tests/devapps/WebApi/Misc/TestSize.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; - -namespace WebApi.Misc -{ - class TestSize - { - // as per https://github.com/CyberSaving/MemoryUsage/blob/master/Main/Program.cs - static private int SizeOfObj(Type T, object thevalue) - { - var type = T; - int returnval = 0; - if (type.IsValueType) - { - var nulltype = Nullable.GetUnderlyingType(type); - returnval = System.Runtime.InteropServices.Marshal.SizeOf(nulltype ?? type); - } - else if (thevalue == null) - return 0; - else if (thevalue is string stringValue) - returnval = Encoding.Default.GetByteCount(stringValue); - else if (type.IsArray && type.GetElementType().IsValueType) - { - returnval = ((Array)thevalue).GetLength(0) * System.Runtime.InteropServices.Marshal.SizeOf(type.GetElementType()); - } - else if (thevalue is Stream streamValue) - { - returnval = (int)streamValue.Length; - } - else if (type.IsSerializable) - { - try - { - returnval = JsonSerializer.SerializeToUtf8Bytes(thevalue).Length; - } - catch { } - } - else - { - var fields = type.GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); - for (int i = 0; i < fields.Length; i++) - { - Type t = fields[i].FieldType; - Object v = fields[i].GetValue(thevalue); - returnval += 4 + SizeOfObj(t, v); - } - } - if (returnval == 0) - try - { - returnval = System.Runtime.InteropServices.Marshal.SizeOf(thevalue); - } - catch { } - return returnval; - } - static public int SizeOf(T value) - { - return SizeOfObj(typeof(T), value); - } - } -}