properly escape backslashes in class and method directives