Skip to content

Commit 7445b52

Browse files
authored
[Smoke Tests] MSAL Native Interop Fix (Azure#31864)
* [Smoke Tests] MSAL Native Interop Fix The focus of these changes is to correct an issue loading the MSAL native interop assembly introduced with the new Azure.Identity.BrokeredAuthentication library. Going forward, assemblies named to indicate native interoperability will no longer be loaded/type sniffed. * Adding reflection rule for partial implementation assemblies * Fixing condition; the top-level exception does not have details.
1 parent 49d5765 commit 7445b52

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

common/SmokeTests/SmokeTest/Program.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7+
using System.Linq;
78
using System.Reflection;
89
using System.Runtime.InteropServices;
910
using System.Text;
@@ -53,6 +54,11 @@
5354
ProcessType(type);
5455
}
5556
}
57+
catch (ReflectionTypeLoadException ex) when (ex.LoaderExceptions.All(lex => lex.Message.Contains("does not have an implementation")))
58+
{
59+
// Expected for some assemblies that serve as runtime shims or type-forwarding
60+
// assemblies.
61+
}
5662
catch (ReflectionTypeLoadException) when (assembly.FullName.StartsWith("System."))
5763
{
5864
// Not expected, but not impactful. System assemblies aren't indicative of
@@ -247,7 +253,7 @@ IEnumerable<Assembly> LoadAssemblies(Assembly rootAssembly, string assemblyFileM
247253
{
248254
var assembly = assembliesToProcess.Pop();
249255

250-
if ((!assembly.FullName.StartsWith("System.")) && (!processedAssemblies.Contains(assembly.FullName)))
256+
if ((ShouldLoadAssembly(assembly)) && (!processedAssemblies.Contains(assembly.FullName)))
251257
{
252258
processedAssemblies.Add(assembly.FullName);
253259
yield return assembly;
@@ -291,3 +297,10 @@ _ when (ex.Message.ToLower().Contains("operation is not supported")) => true,
291297
// By default, do not ignore.
292298
_ => false
293299
};
300+
301+
bool ShouldLoadAssembly(Assembly assembly) => assembly.FullName switch
302+
{
303+
string name when name.StartsWith("System.") => false,
304+
string name when name.Contains("NativeInterop") => false,
305+
_ => true
306+
};

0 commit comments

Comments
 (0)