Ejemplo n.º 1
0
        private static string CreateMessageForInaccessibleMethod(MethodBase inaccessibleMethod)
        {
            var containingType = inaccessibleMethod.DeclaringType;
            var targetAssembly = containingType.GetTypeInfo().Assembly;

            var messageFormat = "Can not create proxy for method {0} because it is not accessible. ";

            var message = string.Format(messageFormat,
                                        inaccessibleMethod);

            var instructions = InternalsUtil.CreateInstructionsToMakeVisible(targetAssembly);

            return(message + instructions);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a message to inform clients that a proxy couldn't be created due to reliance on an
        /// inaccessible type (perhaps itself).
        /// </summary>
        /// <param name="inaccessibleType">the inaccessible type that prevents proxy creation</param>
        /// <param name="typeToProxy">the type that couldn't be proxied</param>
        public static string CreateMessageForInaccessibleType(Type inaccessibleType, Type typeToProxy)
        {
            var targetAssembly = typeToProxy.GetTypeInfo().Assembly;

            string inaccessibleTypeDescription = inaccessibleType == typeToProxy
                ? "it"
                : "type " + inaccessibleType.GetBestName();

            var messageFormat = "Can not create proxy for type {0} because {1} is not accessible. ";

            var message = string.Format(messageFormat,
                                        typeToProxy.GetBestName(),
                                        inaccessibleTypeDescription);

            var instructions = InternalsUtil.CreateInstructionsToMakeVisible(targetAssembly);

            return(message + instructions);
        }