private void AssertValidTypeForTarget(Type type, Type target) { if (type.IsGenericTypeDefinition) { throw new GeneratorException(string.Format("Can not create proxy for type {0} because type {1} is an open generic type.", target.GetBestName(), type.GetBestName())); } if (ProxyUtil.IsAccessibleType(type) == false) { throw new GeneratorException(ExceptionMessageBuilder.CreateMessageForInaccessibleType(type, target)); } foreach (var typeArgument in type.GetGenericArguments()) { AssertValidTypeForTarget(typeArgument, target); } }
private void AssertValidTypeForTarget(Type type, Type target, string paramName) { if (type.IsGenericTypeDefinition) { throw new ArgumentException( $"Can not create proxy for type {target.GetBestName()} because type {type.GetBestName()} is an open generic type.", paramName); } if (ProxyUtil.IsAccessibleType(type) == false) { throw new ArgumentException(ExceptionMessageBuilder.CreateMessageForInaccessibleType(type, target), paramName); } foreach (var typeArgument in type.GetGenericArguments()) { AssertValidTypeForTarget(typeArgument, target, paramName); } }