/// <summary> /// Checks Assembly to see if it has the possibility to contain an ExceptionMappingAttribute. Does this by matching the Version and PublicKeyToken /// with the current executing assembly. /// </summary> /// <param name="assembly"></param> /// <returns></returns> private static bool DoesAssemblyQualify(Assembly assembly) { if (s_currentAssemblyPublicKeyToken == null || s_currentAssemblyVersion == null) { // cache these so we don't have to recompute every time we check an assembly AssemblyName thisAssemblyName = typeof(WrappedException).GetTypeInfo().Assembly.GetName(); s_currentAssemblyPublicKeyToken = thisAssemblyName.GetPublicKeyToken(); s_currentAssemblyVersion = thisAssemblyName.Version; } AssemblyName assemblyName = assembly.GetName(); if (assemblyName.Version.Major != s_currentAssemblyVersion.Major) { return(false); } byte[] assemblyPublicKeyToken = assemblyName.GetPublicKeyToken(); // Allow the test code public key token as well, because we have an L0 test which declares an exception // that has ExceptionMappingAttribute. return(ArrayUtility.Equals(s_currentAssemblyPublicKeyToken, assemblyPublicKeyToken) || ArrayUtility.Equals(s_testCodePublicKeyToken, assemblyPublicKeyToken)); }