private static bool GrantsFriendAccessTo(this ModuleDesc module, ModuleDesc friendModule)
        {
            var assembly = module.ToEcmaAssembly();

            if (assembly != null)
            {
                var friendAssembly = friendModule.ToEcmaAssembly();
                if (assembly == friendAssembly)
                {
                    return(true);
                }
                var friendName = friendAssembly.GetName();

                foreach (var attribute in assembly.GetDecodedCustomAttributes("System.Runtime.CompilerServices", "InternalsVisibleToAttribute"))
                {
                    AssemblyName friendAttributeName = new AssemblyName((string)attribute.FixedArguments[0].Value);
                    if (!friendName.Name.Equals(friendAttributeName.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    // Comparing PublicKeyToken, since GetPublicKey returns null due to a bug
                    if (IsSamePublicKey(friendAttributeName.GetPublicKeyToken(), friendName.GetPublicKeyToken()))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }