Example #1
0
        /// <summary>
        /// Initializes a new instance of CSharpCodeNamingFramework.
        /// </summary>
        public CodeNamerJv()
        {
            // List retrieved from
            // http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
            ReservedWords.AddRange(new []
            {
                "abstract", "assert", "boolean", "break", "byte",
                "case", "catch", "char", "class", "const",
                "continue", "default", "do", "double", "else",
                "enum", "extends", "false", "final", "finally",
                "float", "for", "goto", "if", "implements",
                "import", "int", "long", "interface", "instanceof",
                "native", "new", "null", "package", "private",
                "protected", "public", "return", "short", "static",
                "strictfp", "super", "switch", "synchronized", "this",
                "throw", "throws", "transient", "true", "try",
                "void", "volatile", "while", "date", "datetime",
                "period", "stream", "string", "object", "header"
            });

            PrimaryTypes = new HashSet <string>();
            new HashSet <string>
            {
                "int", "Integer",
                "long", "Long",
                "object", "Object",
                "bool", "Boolean",
                "double", "Double",
                "float", "Float",
                "byte", "Byte",
                "byte[]", "Byte[]",
                "String",
                "LocalDate",
                "DateTime",
                "DateTimeRfc1123",
                "Duration",
                "Period",
                "BigDecimal",
                "InputStream"
            }.ForEach(s => PrimaryTypes.Add(s));
            new HashSet <string>
            {
                "int",
                "long",
                "bool",
                "double",
                "float",
                "byte",
                "byte[]"
            }.ForEach(s => PrimaryTypes.Add(s));
        }
 /// <summary>
 ///     Initializes a new instance of TypeScriptCodeNamingFramework.
 /// </summary>
 public CodeNamerTS()
 {
     ReservedWords.AddRange(new[]
     {
         "arguments", "array", "await", "abstract", "boolean", "buffer",
         "break", "byte", "case", "catch", "char", "class",
         "const", "continue", "debugger", "default", "delete",
         "do", "double", "date", "else", "enum", "error",
         "export", "extends", "false", "final", "finally",
         "float", "for", "function", "goto", "if", "implements",
         "import", "in", "int", "interface", "instanceof",
         "let", "long", "native", "new", "null", "package",
         "private", "protected", "public", "return", "short",
         "static", "super", "switch", "synchronized", "this",
         "throw", "transient", "true", "try", "typeof", "util",
         "var", "void", "volatile", "while", "with", "yield", "pipeline"
     });
 }
Example #3
0
 /// <summary>
 ///     Initializes a new instance of Python's CodeNamer.
 /// </summary>
 public CodeNamerPy()
 {
     // List retrieved from
     // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords
     ReservedWords.AddRange(
         new[]
     {
         "and", "as", "assert", "break", "class", "continue",
         "def", "del", "elif", "else", "except", "exec",
         "finally", "for", "from", "global", "if", "import",
         "in", "is", "lambda", "not", "or", "pass",
         "print", "raise", "return", "try", "while", "with",
         "yield",
         // Though the following word is not python keyword, but it will cause trouble if we use them as variable, field, etc.
         "int", "bool", "bytearray", "date", "datetime", "float",
         "long", "object", "decimal", "str", "timedelta"
     });
 }
        /// <summary>
        /// Initializes a new instance of CSharpCodeNamingFramework.
        /// </summary>
        public CodeNamerOc()
        {
            // List retrieved from
            // http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
            ReservedWords.AddRange(new []
            {
                "if", "else", "switch", "case", "default", "break", "int", "float", "char", "double", "long", "for", "while", "do",
                "void", "goto", "auto", "signed", "const", "extern", "register", "unsigned", "return", "continue", "enum", "sizeof",
                "struct", "typedef", "union", "volatile",
                "description", "id"
            });

            PrimaryTypes = new HashSet <string>
            {
                "int",
                "long",
                "double",
                "float",
                "byte",
                "byte[]"
            };
        }
Example #5
0
 /// <summary>
 ///     Initializes a new instance of CSharpCodeNamingFramework.
 /// </summary>
 public CodeNamerCs()
 {
     ReservedWords.AddRange(
         new[]
     {
         "abstract", "as", "async", "await", "base",
         "bool", "break", "byte", "case", "catch",
         "char", "checked", "class", "const", "continue",
         "decimal", "default", "delegate", "do", "double",
         "dynamic", "else", "enum", "event", "explicit",
         "extern", "false", "finally", "fixed", "float",
         "for", "foreach", "from", "global", "goto",
         "if", "implicit", "in", "int", "interface",
         "internal", "is", "lock", "long", "namespace",
         "new", "null", "object", "operator", "out",
         "override", "params", "private", "protected", "public",
         "readonly", "ref", "return", "sbyte", "sealed",
         "short", "sizeof", "stackalloc", "static", "string",
         "struct", "switch", "this", "throw", "true",
         "try", "typeof", "uint", "ulong", "unchecked",
         "unsafe", "ushort", "using", "virtual", "void",
         "volatile", "while", "yield", "var"
     });
 }
        /// <summary>
        /// Initializes a new instance of CodeNamerGo.
        /// </summary>
        public CodeNamerGo()
        {
            // Create a map from HttpStatusCode to the appropriate Go http.StatusXxxxx string.
            // -- Go does not have constants for the full HttpStatusCode enumeration; this set taken from http://golang.org/pkg/net/http/
            const HttpStatusCode tooManyRequests  = (HttpStatusCode)429;
            const HttpStatusCode failedDependency = (HttpStatusCode)424;
            var statusCodeMap = new Dictionary <HttpStatusCode, string>();

            foreach (var sc in new HttpStatusCode[] {
                HttpStatusCode.Continue,
                HttpStatusCode.SwitchingProtocols,

                HttpStatusCode.OK,
                HttpStatusCode.Created,
                HttpStatusCode.Accepted,
                HttpStatusCode.NonAuthoritativeInformation,
                HttpStatusCode.NoContent,
                HttpStatusCode.ResetContent,
                HttpStatusCode.PartialContent,

                HttpStatusCode.MultipleChoices,
                HttpStatusCode.MovedPermanently,
                HttpStatusCode.Found,
                HttpStatusCode.SeeOther,
                HttpStatusCode.NotModified,
                HttpStatusCode.UseProxy,
                HttpStatusCode.TemporaryRedirect,

                HttpStatusCode.BadRequest,
                HttpStatusCode.Unauthorized,
                HttpStatusCode.PaymentRequired,
                HttpStatusCode.Forbidden,
                HttpStatusCode.NotFound,
                HttpStatusCode.MethodNotAllowed,
                HttpStatusCode.NotAcceptable,
                HttpStatusCode.ProxyAuthenticationRequired,
                HttpStatusCode.RequestTimeout,
                HttpStatusCode.Conflict,
                HttpStatusCode.Gone,
                HttpStatusCode.LengthRequired,
                HttpStatusCode.PreconditionFailed,
                HttpStatusCode.RequestEntityTooLarge,
                HttpStatusCode.RequestUriTooLong,
                HttpStatusCode.UnsupportedMediaType,
                HttpStatusCode.RequestedRangeNotSatisfiable,
                HttpStatusCode.ExpectationFailed,
                failedDependency,
                tooManyRequests,

                HttpStatusCode.InternalServerError,
                HttpStatusCode.NotImplemented,
                HttpStatusCode.BadGateway,
                HttpStatusCode.ServiceUnavailable,
                HttpStatusCode.GatewayTimeout,
                HttpStatusCode.HttpVersionNotSupported
            })
            {
                statusCodeMap.Add(sc, string.Format("http.Status{0}", sc));
            }

            // Go names some constants slightly differently than the HttpStatusCode enumeration -- correct those
            statusCodeMap[HttpStatusCode.Redirect] = "http.StatusFound";
            statusCodeMap[HttpStatusCode.NonAuthoritativeInformation] = "http.StatusNonAuthoritativeInfo";
            statusCodeMap[HttpStatusCode.ProxyAuthenticationRequired] = "http.StatusProxyAuthRequired";
            statusCodeMap[HttpStatusCode.RequestUriTooLong]           = "http.StatusRequestURITooLong";
            statusCodeMap[failedDependency] = "http.StatusFailedDependency";
            statusCodeMap[tooManyRequests]  = "http.StatusTooManyRequests";
            statusCodeMap[HttpStatusCode.HttpVersionNotSupported] = "http.StatusHTTPVersionNotSupported";

            // Add the status which are not in the System.Net.HttpStatusCode enumeration
            statusCodeMap[(HttpStatusCode)207] = "http.StatusMultiStatus";

            StatusCodeToGoString = statusCodeMap;

            ReservedWords.AddRange(
                new[]
            {
                // Reserved keywords -- list retrieved from http://golang.org/ref/spec#Keywords
                "break", "default", "func", "interface", "select",
                "case", "defer", "go", "map", "struct",
                "chan", "else", "goto", "package", "switch",
                "const", "fallthrough", "if", "range", "type",
                "continue", "for", "import", "return", "var",

                // Reserved predeclared identifiers -- list retrieved from http://golang.org/ref/spec#Predeclared_identifiers
                "bool", "byte",
                "complex64", "complex128",
                "error",
                "float32", "float64",
                "int", "int8", "int16", "int32", "int64",
                "rune", "string",
                "uint", "uint8", "uint16", "uint32", "uint64",
                "uintptr",

                "true", "false", "iota",

                "nil",

                "append", "cap", "close", "complex", "copy", "delete", "imag", "len", "make", "new", "panic", "print", "println", "real", "recover",


                // Reserved packages -- list retrieved from http://golang.org/pkg/
                // -- Since package names serve as partial identifiers, exclude the standard library
                "archive", "tar", "zip",
                "bufio",
                "builtin",
                "bytes",
                "compress", "bzip2", "flate", "gzip", "lzw", "zlib",
                "container", "heap", "list", "ring",
                "crypto", "aes", "cipher", "des", "dsa", "ecdsa", "elliptic", "hmac", "md5", "rand", "rc4", "rsa", "sha1", "sha256", "sha512", "subtle", "tls", "x509", "pkix",
                "database", "sql", "driver",
                "debug", "dwarf", "elf", "gosym", "macho", "pe", "plan9obj",
                "encoding", "ascii85", "asn1", "base32", "base64", "binary", "csv", "gob", "hex", "json", "pem", "xml",
                "errors",
                "expvar",
                "flag",
                "fmt",
                "go", "ast", "build", "constant", "doc", "format", "importer", "parser", "printer", "scanner", "token", "types",
                "hash", "adler32", "crc32", "crc64", "fnv",
                "html", "template",
                "image", "color", "palette", "draw", "gif", "jpeg", "png",
                "index", "suffixarray",
                "io", "ioutil",
                "log", "syslog",
                "math", "big", "cmplx", "rand",
                "mime", "multipart", "quotedprintable",
                "net", "http", "cgi", "cookiejar", "fcgi", "httptest", "httputil", "pprof", "mail", "rpc", "jsonrpc", "smtp", "textproto", "url",
                "os", "exec", "signal", "user",
                "path", "filepath",
                "reflect",
                "regexp", "syntax",
                "runtime", "cgo", "debug", "pprof", "race", "trace",
                "sort",
                "strconv",
                "strings",
                "sync", "atomic",
                "syscall",
                "testing", "iotest", "quick",
                "text", "scanner", "tabwriter", "template", "parse",
                "time",
                "unicode", "utf16", "utf8",
                "unsafe",

                // Other reserved names and packages (defined by the base libraries this code uses)
                "autorest", "client", "date", "err", "req", "resp", "result", "sender", "to", "validation", "m", "v", "k", "objectMap",

                // reserved method names
                "Send"
            });
        }
Example #7
0
 /// <summary>
 /// Adds many reserved words to the list
 /// </summary>
 /// <param name="list">List of reserved words</param>
 protected void AddReservedWords(params string[] list)
 {
     ReservedWords.AddRange(list);
 }