From 4a8fe072be00c55f6e16418912efb50c806bf298 Mon Sep 17 00:00:00 2001 From: Nick Karnik Date: Sun, 31 Mar 2013 21:18:49 -0700 Subject: [PATCH 01/35] Added support for Node-Restify --- .../Node.Core/Network/HttpServerRequest.cs | 4 +- .../Node.Core/Network/HttpServerResponse.cs | 4 +- .../Node/Node.Restify/BunyanLogger.cs | 18 ++ .../Node/Node.Restify/Node.Restify.csproj | 82 +++++ .../Node/Node.Restify/Node.Restify.vsdoc | 7 + .../Node.Restify/Properties/AssemblyInfo.cs | 11 + .../Node.Restify/Properties/ScriptInfo.txt | 10 + src/Libraries/Node/Node.Restify/Restify.cs | 80 +++++ .../Node/Node.Restify/RestifyCallback.cs | 9 + .../Node/Node.Restify/RestifyChain.cs | 26 ++ .../Node/Node.Restify/RestifyClient.cs | 14 + .../Node/Node.Restify/RestifyError.cs | 14 + .../Node/Node.Restify/RestifyHandler.cs | 18 ++ .../Node/Node.Restify/RestifyHttpClient.cs | 17 ++ .../Node/Node.Restify/RestifyJsonClient.cs | 21 ++ .../Node.Restify/RestifyJsonClientOptions.cs | 70 +++++ .../Node/Node.Restify/RestifyRequest.cs | 148 +++++++++ .../Node/Node.Restify/RestifyResponse.cs | 124 ++++++++ .../Node/Node.Restify/RestifyRoute.cs | 17 ++ .../Node/Node.Restify/RestifyServer.cs | 283 ++++++++++++++++++ .../Node.Restify/RestifyServerGetOptions.cs | 20 ++ .../Node/Node.Restify/RestifyServerOptions.cs | 74 +++++ .../Node/Node.Restify/RestifyStringClient.cs | 58 ++++ .../Node.Restify/RestifyThrottleOptions.cs | 83 +++++ src/ScriptSharp.sln | 15 + 25 files changed, 1223 insertions(+), 4 deletions(-) create mode 100644 src/Libraries/Node/Node.Restify/BunyanLogger.cs create mode 100644 src/Libraries/Node/Node.Restify/Node.Restify.csproj create mode 100644 src/Libraries/Node/Node.Restify/Node.Restify.vsdoc create mode 100644 src/Libraries/Node/Node.Restify/Properties/AssemblyInfo.cs create mode 100644 src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt create mode 100644 src/Libraries/Node/Node.Restify/Restify.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyCallback.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyChain.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyClient.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyError.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyHandler.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyHttpClient.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyJsonClient.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyRequest.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyResponse.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyRoute.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyServer.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyServerOptions.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyStringClient.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs diff --git a/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs b/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs index 22ead043e..ac8358a3a 100644 --- a/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs +++ b/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs @@ -11,9 +11,9 @@ namespace NodeApi.Network { [ScriptImport] [ScriptIgnoreNamespace] - public sealed class HttpServerRequest : ReadableStream, IEventEmitter { + public class HttpServerRequest : ReadableStream, IEventEmitter { - private HttpServerRequest() { + protected HttpServerRequest() { } [ScriptField] diff --git a/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs b/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs index f8d9355d7..d9422dcf1 100644 --- a/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs +++ b/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs @@ -12,9 +12,9 @@ namespace NodeApi.Network { [ScriptImport] [ScriptIgnoreNamespace] - public sealed class HttpServerResponse : WritableStream, IEventEmitter { + public class HttpServerResponse : WritableStream, IEventEmitter { - private HttpServerResponse() { + protected HttpServerResponse() { } [ScriptField] diff --git a/src/Libraries/Node/Node.Restify/BunyanLogger.cs b/src/Libraries/Node/Node.Restify/BunyanLogger.cs new file mode 100644 index 000000000..9475d6c22 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/BunyanLogger.cs @@ -0,0 +1,18 @@ +// BunyanLogger.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Collections; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class BunyanLogger { + + public void Debug(Dictionary options, string format, params string[] formatArguments) { + } + } +} \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/Node.Restify.csproj b/src/Libraries/Node/Node.Restify/Node.Restify.csproj new file mode 100644 index 000000000..22c848ba8 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/Node.Restify.csproj @@ -0,0 +1,82 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {1ECC689C-2542-4EE8-8A86-7627E63F44F8} + Library + Properties + NodeApi.Restify + Script.Node.Restify + True + true + ..\..\..\ScriptSharp.snk + v2.0 + 512 + + + + ..\..\..\..\bin\Debug\ + false + DEBUG + prompt + 4 + ..\..\..\..\bin\Debug\Script.Node.Restify.xml + 1591, 0661, 0660, 1684 + true + + + none + false + true + ..\..\..\..\bin\Release\ + TRACE + prompt + 4 + ..\..\..\..\bin\Release\Script.Node.Restify.xml + 1591, 0661, 0660, 1684 + true + + + + Properties\ScriptSharp.cs + + + + + + + + + + + + + + + + + + + + + + + + {36d4b098-a21c-4725-acd3-400922885f38} + CoreLib + + + {4a9f7ce9-5a45-4b28-ad01-05528709b6e4} + Node.Core + + + + + + + + + \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/Node.Restify.vsdoc b/src/Libraries/Node/Node.Restify/Node.Restify.vsdoc new file mode 100644 index 000000000..9ffff5e7f --- /dev/null +++ b/src/Libraries/Node/Node.Restify/Node.Restify.vsdoc @@ -0,0 +1,7 @@ + + + + default + + + diff --git a/src/Libraries/Node/Node.Restify/Properties/AssemblyInfo.cs b/src/Libraries/Node/Node.Restify/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..d1497e2e9 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// AssemblyInfo.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Reflection; + +[assembly: AssemblyTitle("Script.Node.Restify")] +[assembly: AssemblyDescription("Script# NodeJS Restify Module API")] +[assembly: ScriptAssembly("restify")] diff --git a/src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt b/src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt new file mode 100644 index 000000000..018207ec7 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt @@ -0,0 +1,10 @@ +Node Express Module +=============================================================================== + +This assembly provides access to Restify Module APIs for NodeJS applications. +This is only meant for use at development time, so you can reference and compile +your c# code against restify APIs. + +More information is on http://mcavage.github.com/node-restify/. + +------------------------------------------------------------------------------- diff --git a/src/Libraries/Node/Node.Restify/Restify.cs b/src/Libraries/Node/Node.Restify/Restify.cs new file mode 100644 index 000000000..91af39826 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/Restify.cs @@ -0,0 +1,80 @@ +// Restify.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + [ScriptName("restify")] + public sealed class Restify { + + public static RestifyChainedHandler[] AcceptParser(string[] serverAcceptable) { + return null; + } + + public static RestifyChainedHandler[] AuthorizationParser() { + return null; + } + + public static RestifyChainedHandler[] BodyParser() { + return null; + } + + public static RestifyChainedHandler[] ConditionalRequest() { + return null; + } + + public static RestifyHttpClient CreateHttpClient() { + return null; + } + + public static RestifyJsonClient CreateJsonClient() { + return null; + } + + public static RestifyJsonClient CreateJsonClient(RestifyJsonClientOptions options) { + return null; + } + + public static RestifyServer CreateServer() { + return null; + } + + public static RestifyServer CreateServer(RestifyServerOptions rs) { + return null; + } + + public static RestifyStringClient CreateStringClient() { + return null; + } + + public static RestifyChainedHandler[] DateParser() { + return null; + } + + public static RestifyChainedHandler[] GZipResponse() { + return null; + } + + public static RestifyChainedHandler[] JsonBodyParser() { + return null; + } + + public static RestifyChainedHandler[] Jsonp() { + return null; + } + + public static RestifyChainedHandler QueryParser() { + return null; + } + + public static RestifyChainedHandler[] Throttle(RestifyThrottleOptions options) { + return null; + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyCallback.cs b/src/Libraries/Node/Node.Restify/RestifyCallback.cs new file mode 100644 index 000000000..3f6dbcd0e --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyCallback.cs @@ -0,0 +1,9 @@ +// RestifyCallback.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +namespace NodeApi.Restify { + + public delegate void RestifyCallback(RestifyError error, RestifyRequest request, RestifyResponse response, object content); +} \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/RestifyChain.cs b/src/Libraries/Node/Node.Restify/RestifyChain.cs new file mode 100644 index 000000000..98823c17b --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyChain.cs @@ -0,0 +1,26 @@ +// RestifyChain.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyChain { + + private RestifyChain() { + } + + [ScriptSkip] + public void Continue() { + } + + [ScriptSkip] + public void Error(Exception error) { + } + } +} \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/RestifyClient.cs b/src/Libraries/Node/Node.Restify/RestifyClient.cs new file mode 100644 index 000000000..7ffc461a9 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyClient.cs @@ -0,0 +1,14 @@ +// RestifyClient.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + public class RestifyClient { + } +} \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/RestifyError.cs b/src/Libraries/Node/Node.Restify/RestifyError.cs new file mode 100644 index 000000000..7b8a72e87 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyError.cs @@ -0,0 +1,14 @@ +// RestifyError.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyError { + } +} \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/RestifyHandler.cs b/src/Libraries/Node/Node.Restify/RestifyHandler.cs new file mode 100644 index 000000000..111182019 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyHandler.cs @@ -0,0 +1,18 @@ +// RestifyHandler.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + public delegate void RestifyHandler(RestifyRequest request, RestifyResponse response); + + [ScriptImport] + [ScriptIgnoreNamespace] + public delegate RestifyChainedHandler RestifyChainedHandler(RestifyRequest request, RestifyResponse response, Func next); +} diff --git a/src/Libraries/Node/Node.Restify/RestifyHttpClient.cs b/src/Libraries/Node/Node.Restify/RestifyHttpClient.cs new file mode 100644 index 000000000..5c6b84542 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyHttpClient.cs @@ -0,0 +1,17 @@ +// RestifyHttpClient.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class RestifyHttpClient : RestifyStringClient { + + private RestifyHttpClient() { + } + } +} \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/RestifyJsonClient.cs b/src/Libraries/Node/Node.Restify/RestifyJsonClient.cs new file mode 100644 index 000000000..eb29d693d --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyJsonClient.cs @@ -0,0 +1,21 @@ +// RestifyJsonClient.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Collections; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + /// + /// sends and expects application/json + /// + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class RestifyJsonClient : RestifyStringClient { + + private RestifyJsonClient() { + } + } +} \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs b/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs new file mode 100644 index 000000000..ddda8cfbd --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs @@ -0,0 +1,70 @@ +// RestifyJsonClientOptions.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class RestifyJsonClientOptions { + + /// + /// Accept header to send + /// + public string Accept; + + /// + /// Amount of time to wait for a socket + /// + public int ConnectTimeout; + + /// + /// node-dtrace-provider handle + /// + public object Dtrace; + + /// + /// Will compress data when sent using content-encoding: gzip + /// + public object Gzip; + + /// + /// HTTP headers to set in all requests + /// + public object Headers; + + /// + /// bunyan instance + /// + public BunyanLogger Log; + + /// + /// options to provide to node-retry; defaults to 3 retries + /// + public object Retry; + + /// + /// synchronous callback for interposing headers before request is sent + /// + public Action SignRequest; + + /// + /// Fully-qualified URL to connect to + /// + public string Url; + + /// + /// user-agent string to use; restify inserts one, but you can override it + /// + public string UserAgent; + + /// + /// semver string to set the accept-version + /// + public string Version; + } +} \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/RestifyRequest.cs b/src/Libraries/Node/Node.Restify/RestifyRequest.cs new file mode 100644 index 000000000..e24c88202 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyRequest.cs @@ -0,0 +1,148 @@ +// RestifyRequest.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using NodeApi.Network; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyRequest : HttpServerRequest { + + private RestifyRequest() { + } + + /// + /// short hand for the header content-length + /// + [ScriptField] + public int ContentLength { + get { + return 0; + } + } + + /// + /// short hand for the header content-type + /// + [ScriptField] + public string ContentType { + get { + return String.Empty; + } + } + + /// + /// url.parse(req.url) href + /// + [ScriptField] + public string Href { + get { + return String.Empty; + } + } + + /// + /// A unique request id (x-request-id) + /// + [ScriptField] + public string Id { + get { + return String.Empty; + } + } + + /// + /// bunyan logger you can piggyback on + /// + [ScriptField] + public BunyanLogger Log { + get { + return null; + } + } + + [ScriptField] + [ScriptName("params")] + public Dictionary Parameters { + get { + return null; + } + } + + /// + /// cleaned up URL path + /// + [ScriptField] + public string Path { + get { + return String.Empty; + } + } + + /// + /// the query string only + /// + [ScriptField] + public string Query { + get { + return String.Empty; + } + } + + /// + /// Whether this was an SSL request + /// + [ScriptField] + public bool Secure { + get { + return true; + } + } + + /// + /// the time when this request arrived (ms since epoch) + /// + [ScriptField] + [ScriptName("time")] + public int TimeInMs { + get { + return 0; + } + } + + [ScriptName("accepts")] + public string AcceptsContentType(string type) { + return null; + } + + [ScriptName("accepts")] + public string AcceptsContentType(string[] types) { + return null; + } + + [ScriptName("header")] + public string GetHeader(string name) { + return String.Empty; + } + + [ScriptName("header")] + public string GetHeader(string key, string defaultValue) { + return String.Empty; + } + + public BunyanLogger GetLogger(string name) { + return null; + } + + [ScriptName("is")] + public string IsContentType(string type) { + return null; + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyResponse.cs b/src/Libraries/Node/Node.Restify/RestifyResponse.cs new file mode 100644 index 000000000..f1b1616fa --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyResponse.cs @@ -0,0 +1,124 @@ +// RestifyResponse.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections; +using System.Runtime.CompilerServices; +using NodeApi.Network; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyResponse : HttpServerResponse { + + private RestifyResponse() { + } + + /// + /// In conjunction with contentType, you can explicitly set the charSet to be written in the content-type header + /// + [ScriptField] + public string CharSet { + get { + return String.Empty; + } + } + + /// + /// short hand for the header content-length + /// + [ScriptField] + public int ContentLength { + get { + return 0; + } + } + + /// + /// short hand for the header content-type + /// + [ScriptField] + public string ContentType { + get { + return String.Empty; + } + } + + /// + /// response headers + /// + [ScriptField] + public object Headers { + get { + return null; + } + } + + /// + /// HTTP status code + /// + [ScriptName("code")] + [ScriptField] + public int HttpStatusCode { + get { + return 0; + } + } + + /// + /// A unique request id (x-request-id) + /// + [ScriptField] + public string Id { + get { + return String.Empty; + } + } + + /// + /// Short-hand for: + /// res.contentType = 'json'; + /// res.send({hello: 'world'}); + /// + /// Status code + /// content + public void Json(HttpStatusCode code, Dictionary body) { + } + + public void Send(string message) { + } + + public void Send(Dictionary message) { + } + + public void Send(int errorCode, RestifyError message) { + } + + /// + /// Sets the cache-control header. + /// + /// type defaults to _public_ + /// options currently only takes maxAge. + public void SetCache(string type, Dictionary options) { + } + + /// + /// Sets the response statusCode. + /// + /// Status code + public void Status(HttpStatusCode code) { + } + + /// + /// You can use send() to wrap up all the usual writeHead(), write(), end() calls on the HTTP API of node. + /// When you call send(), restify figures out how to format the response (see content-negotiation, above), and does that. + /// + /// Status Code + /// body can be an Object, a Buffer, or an Error. + public void Status(HttpStatusCode code, object body) { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyRoute.cs b/src/Libraries/Node/Node.Restify/RestifyRoute.cs new file mode 100644 index 000000000..7b28b1e03 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyRoute.cs @@ -0,0 +1,17 @@ +// RestifyRoute.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyRoute { + + private RestifyRoute() { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyServer.cs b/src/Libraries/Node/Node.Restify/RestifyServer.cs new file mode 100644 index 000000000..c3007a16e --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyServer.cs @@ -0,0 +1,283 @@ + // RestifyServer.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyServer { + + private RestifyServer() { + } + + /// + /// list of content-types this server can respond with + /// + [ScriptField] + public String[] Acceptable { + get { + return null; + } + } + + /// + /// bunyan instance + /// + [ScriptField] + public BunyanLogger Log { + get { + return null; + } + } + + /// + /// name of the server + /// + [ScriptField] + public string Name { + get { + return null; + } + } + + /// + /// Once listen() is called, this will be filled in with where the server is running + /// + [ScriptField] + public string Url { + get { + return null; + } + } + + /// + /// default version to use in all routes + /// + [ScriptField] + public string Version { + get { + return null; + } + } + + [ScriptEvent("on", "removeListener")] + public event Action After { + add { + } + remove { + } + } + + [ScriptEvent("on", "removeListener")] + [ScriptName("MethodNotAllowed")] + public event Action MethodNotAllowed { + add { + } + remove { + } + } + + [ScriptEvent("on", "removeListener")] + [ScriptName("NotFound")] + public event Action NotFound { + add { + } + remove { + } + } + + [ScriptEvent("on", "removeListener")] + public event Action UncaughtException { + add { + } + remove { + } + } + + [ScriptEvent("on", "removeListener")] + [ScriptName("UnsupportedMediaType")] + public event Action UnsupportedMediaType { + add { + } + remove { + } + } + + [ScriptEvent("on", "removeListener")] + [ScriptName("VersionNotAllowed")] + public event Action VersionNotAllowed { + add { + } + remove { + } + } + + public RestifyChainedHandler[] AcceptParser(string[] acceptable) { + return null; + } + + public Dictionary Address() { + return null; + } + + public RestifyChainedHandler[] AuditLogger(Dictionary options) { + return null; + } + + public RestifyChainedHandler[] AuthorizationParser() { + return null; + } + + public RestifyChainedHandler[] BodyParser() { + return null; + } + + public void Close(Action callback) { + } + + public RestifyChainedHandler[] ConditionalRequest() { + return null; + } + + public RestifyServer CreateServer() { + return null; + } + + public RestifyServer CreateServer(Dictionary options) { + return null; + } + + public RestifyServer CreateServer(RestifyServerOptions options) { + return null; + } + + public RestifyChainedHandler[] DateParser() { + return null; + } + + [ScriptName("del")] + public void Delete(string path, RestifyChainedHandler handler) { + } + + [ScriptName("del")] + public void Delete(string path, RestifyChainedHandler[] handlers) { + } + + [ScriptName("del")] + public void Delete(RegExp pathPattern, RestifyChainedHandler handler) { + } + + [ScriptName("del")] + public void Delete(RegExp pathPattern, RestifyChainedHandler[] handlers) { + } + + public void Get(string path, RestifyChainedHandler handler) { + } + + public void Get(string path, RestifyChainedHandler[] handlers) { + } + + public void Get(RestifyServerGetOptions options, RestifyChainedHandler handler) { + } + + public void Get(RestifyServerGetOptions options, RestifyChainedHandler[] handlers) { + } + + public void Get(RegExp pathPattern, RestifyChainedHandler handler) { + } + + public void Get(RegExp pathPattern, RestifyChainedHandler[] handlers) { + } + + public void Get(Dictionary options, RestifyChainedHandler handler) { + } + + public void Get(Dictionary options, RestifyChainedHandler[] handlers) { + } + + public RestifyChainedHandler[] GzipResponse() { + return null; + } + + public void Head(string path, RestifyChainedHandler handler) { + } + + public void Head(string path, RestifyChainedHandler[] handlers) { + } + + public void Head(RegExp pathPattern, RestifyChainedHandler handler) { + } + + public void Head(RegExp pathPattern, RestifyChainedHandler[] handlers) { + } + + public void Listen(int port, Action callback) { + } + + public void Listen(object handle, Action callback) { + } + + public void Listen(string path, Action callback) { + } + + public void Post(string path, RestifyChainedHandler handler) { + } + + public void Post(string path, RestifyChainedHandler[] handlers) { + } + + public void Post(RegExp pathPattern, RestifyChainedHandler handler) { + } + + public void Post(RegExp pathPattern, RestifyChainedHandler[] handlers) { + } + + public void Pre(RestifyChainedHandler handler) { + } + + public void Pre(RestifyChainedHandler[] handlers) { + } + + public RestifyChainedHandler[] QueryParser() { + return null; + } + + public RestifyChainedHandler[] RequestLogger() { + return null; + } + + public RestifyChainedHandler[] RequestLogger(Dictionary options) { + return null; + } + + public RestifyChainedHandler[] ServeStatic(Dictionary options) { + return null; + } + + public RestifyChainedHandler[] Throttle(RestifyThrottleOptions options) { + return null; + } + + public RestifyChainedHandler[] Throttle(Dictionary options) { + return null; + } + + /// + /// Restify runs handlers in the order they are registered on a server, + /// so if you want some common handlers to run before any of your routes, + /// issue calls to use() before defining routes. + /// + public void Use(RestifyChainedHandler handlers) { + } + + public void Use(RestifyChainedHandler[] handlers) { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs b/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs new file mode 100644 index 000000000..6441e3354 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs @@ -0,0 +1,20 @@ +// RestifyServerGetOptions.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + [ScriptName("Object")] + public sealed class RestifyServerGetOptions { + + public string Path; + + public string Version; + } +} \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs b/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs new file mode 100644 index 000000000..1bb0a1af3 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs @@ -0,0 +1,74 @@ +// RestifyServerOptions.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + [ScriptName("Object")] + public sealed class RestifyServerOptions { + public string Test; + + /// + /// If you want to create an HTTPS server, pass in the PEM-encoded certificate and key + /// + public string Certificate; + + /// + /// Custom response formatters for res.send() + /// + public object Formatters; + + /// + /// If you want to create an HTTPS server, pass in the PEM-encoded certificate and key + /// + public string Key; + + /// + /// You can optionally pass in a bunyan (https://github.com/trentm/node-bunyan) instance; not required + /// + public BunyanLogger Log; + + /// + /// By default, this will be set in the Server response header, default is restify + /// + public string Name; + + /// + /// Any options accepted by node-spdy (https://github.com/indutny/node-spdy) + /// + public string Spdy; + + /// + /// Allows you to apply formatting to the value of the header. + /// The duration is passed as an argument in number of milliseconds to execute. + /// + /// + /// + /// app = module.exports = restify.createServer({ + /// name: 'restify', + /// version: '1.0.0', + /// responseTimeHeader: 'X-Runtime', + /// responseTimeFormatter: function(durationInMilliseconds) { + /// return durationInMilliseconds / 1000; + /// } + /// }); + /// + public string ResponseTimeFormatter; + + /// + /// By default, this will be X-Response-Time + /// + public string ResponseTimeHeader; + + /// + /// A default version to set for all routes + /// + public string Version; + } +} \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/RestifyStringClient.cs b/src/Libraries/Node/Node.Restify/RestifyStringClient.cs new file mode 100644 index 000000000..a4cbb9117 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyStringClient.cs @@ -0,0 +1,58 @@ +// RestifyStringClient.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Collections; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + public class RestifyStringClient { + + protected RestifyStringClient() { + } + + public void BasicAuth(string login, string password) { + } + + /// + /// del doesn't take content, since you know, it should't: + /// + public void Del(string path, Dictionary content, RestifyCallback callback) { + } + + /// + /// Performs an HTTP get; if no payload was returned, obj defaults to {} for you (so you don't get a bunch of null pointer errors). + /// + /// + /// + public void Get(string path, RestifyCallback callback) { + } + + /// + /// Just like get, but without obj: + /// + /// + /// + public void Head(string path, RestifyCallback callback) { + } + + /// + /// Takes a complete object to serialize and send to the server. + /// + /// + /// + /// + public void Post(string path, Dictionary content, RestifyCallback callback) { + } + + /// + /// Just like post: + /// + public void Put(string path, Dictionary content, RestifyCallback callback) { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs b/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs new file mode 100644 index 000000000..4ef837c16 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs @@ -0,0 +1,83 @@ +// RestifyThrottleOptions.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyThrottleOptions { + + /// + /// If available, the amount of requests to burst to + /// + [ScriptField] + public int Burst { + set { + } + } + + /// + /// Do throttling on a /32 (source IP) + /// + [ScriptField] + public bool Ip { + set { + } + } + + /// + /// If using the built-in storage table, the maximum distinct throttling keys to allow at a time + /// + [ScriptField] + public int MaxKeys { + set { + } + } + + /// + /// Per "key" overrides + /// + [ScriptField] + public object Overrides { + set { + } + } + + [ScriptField] + public int Rate { + set { + } + } + + /// + /// Storage engine; must support put/get + /// + [ScriptField] + public object TokensTable { + set { + } + } + + /// + /// Do throttling on req.username + /// + [ScriptField] + public bool Username { + set { + } + } + + /// + /// Do throttling on a /32 (X-Forwarded-For) + /// + [ScriptField] + public bool Xff { + set { + } + } + } +} diff --git a/src/ScriptSharp.sln b/src/ScriptSharp.sln index 04fe50e77..7717665a7 100644 --- a/src/ScriptSharp.sln +++ b/src/ScriptSharp.sln @@ -73,6 +73,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Node.Neo4j", "Libraries\Nod EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deployment", "Tools\Deployment\Deployment.csproj", "{9D59077D-1A05-4D6C-A1A4-FB748D200578}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Node.Restify", "Libraries\Node\Node.Restify\Node.Restify.csproj", "{1ECC689C-2542-4EE8-8A86-7627E63F44F8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET @@ -336,6 +338,18 @@ Global {9D59077D-1A05-4D6C-A1A4-FB748D200578}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {9D59077D-1A05-4D6C-A1A4-FB748D200578}.Release|Mixed Platforms.Build.0 = Release|Any CPU {9D59077D-1A05-4D6C-A1A4-FB748D200578}.Release|x86.ActiveCfg = Release|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Debug|.NET.ActiveCfg = Debug|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Debug|x86.ActiveCfg = Debug|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|.NET.ActiveCfg = Release|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|Any CPU.Build.0 = Release|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -353,6 +367,7 @@ Global {4A9F7CE9-5B45-4B28-AD01-05528709B6E4} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} {4A9F7CE9-5B45-4B28-AD01-05529709B6E4} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} {232445FF-22AA-46F7-BA12-4590C670F2B1} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} + {1ECC689C-2542-4EE8-8A86-7627E63F44F8} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} {1772A38C-7204-42DC-B81D-6C74D17A4F66} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} {BE1E0A21-F6C0-4698-B405-66FC2BB289F4} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} {36D4B098-A21C-4725-ACD3-400922885F38} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} From 1e2da8de477a35ad0738c094978b6baa79de06a6 Mon Sep 17 00:00:00 2001 From: Nick Karnik Date: Sun, 14 Apr 2013 14:29:36 -0700 Subject: [PATCH 02/35] Applied changes as suggested in the comments in https://github.com/nikhilk/scriptsharp/pull/353 --- ScriptSharp.sln | 20 ++++++ .../Node.Core/Network/HttpServerRequest.cs | 4 +- .../Node.Core/Network/HttpServerResponse.cs | 4 +- .../Node/Node.Restify/HttpServerRequest.cs | 62 +++++++++++++++++++ .../Node/Node.Restify/HttpServerResponse.cs | 58 +++++++++++++++++ .../Node/Node.Restify/Node.Restify.csproj | 14 ++--- .../Node/Node.Restify/Node.Restify.vsdoc | 7 --- .../{Restify.cs => RestifyApplication.cs} | 2 +- .../Node/Node.Restify/RestifyCallback.cs | 2 +- .../Node/Node.Restify/RestifyChain.cs | 2 +- .../Node/Node.Restify/RestifyClient.cs | 14 ----- .../Node/Node.Restify/RestifyError.cs | 5 +- .../Node/Node.Restify/RestifyHttpClient.cs | 2 +- .../Node/Node.Restify/RestifyJsonClient.cs | 2 +- .../Node.Restify/RestifyJsonClientOptions.cs | 7 ++- .../{BunyanLogger.cs => RestifyLogger.cs} | 4 +- .../Node/Node.Restify/RestifyRequest.cs | 39 +++++++++--- .../Node/Node.Restify/RestifyResponse.cs | 11 ++-- .../Node/Node.Restify/RestifyServer.cs | 48 +++++++++++--- .../Node.Restify/RestifyServerGetOptions.cs | 2 +- .../Node/Node.Restify/RestifyServerOptions.cs | 6 +- .../Node/Node.Restify/RestifyStringClient.cs | 7 +-- .../Node.Restify/RestifyThrottleOptions.cs | 2 + 23 files changed, 248 insertions(+), 76 deletions(-) create mode 100644 ScriptSharp.sln create mode 100644 src/Libraries/Node/Node.Restify/HttpServerRequest.cs create mode 100644 src/Libraries/Node/Node.Restify/HttpServerResponse.cs delete mode 100644 src/Libraries/Node/Node.Restify/Node.Restify.vsdoc rename src/Libraries/Node/Node.Restify/{Restify.cs => RestifyApplication.cs} (97%) delete mode 100644 src/Libraries/Node/Node.Restify/RestifyClient.cs rename src/Libraries/Node/Node.Restify/{BunyanLogger.cs => RestifyLogger.cs} (69%) diff --git a/ScriptSharp.sln b/ScriptSharp.sln new file mode 100644 index 000000000..a1a131da0 --- /dev/null +++ b/ScriptSharp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptSharp", "ScriptSharp\ScriptSharp.csproj", "{54C786E5-FD14-4036-92AE-E9F25B71534B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {54C786E5-FD14-4036-92AE-E9F25B71534B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54C786E5-FD14-4036-92AE-E9F25B71534B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54C786E5-FD14-4036-92AE-E9F25B71534B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54C786E5-FD14-4036-92AE-E9F25B71534B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs b/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs index ac8358a3a..22ead043e 100644 --- a/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs +++ b/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs @@ -11,9 +11,9 @@ namespace NodeApi.Network { [ScriptImport] [ScriptIgnoreNamespace] - public class HttpServerRequest : ReadableStream, IEventEmitter { + public sealed class HttpServerRequest : ReadableStream, IEventEmitter { - protected HttpServerRequest() { + private HttpServerRequest() { } [ScriptField] diff --git a/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs b/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs index d9422dcf1..f8d9355d7 100644 --- a/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs +++ b/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs @@ -12,9 +12,9 @@ namespace NodeApi.Network { [ScriptImport] [ScriptIgnoreNamespace] - public class HttpServerResponse : WritableStream, IEventEmitter { + public sealed class HttpServerResponse : WritableStream, IEventEmitter { - protected HttpServerResponse() { + private HttpServerResponse() { } [ScriptField] diff --git a/src/Libraries/Node/Node.Restify/HttpServerRequest.cs b/src/Libraries/Node/Node.Restify/HttpServerRequest.cs new file mode 100644 index 000000000..0189157d8 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/HttpServerRequest.cs @@ -0,0 +1,62 @@ +// HttpServerRequest.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; +using NodeApi.IO; +using NodeApi.Network; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + public class HttpServerRequest : ReadableStream, IEventEmitter { + + protected HttpServerRequest() { + } + + [ScriptField] + public Socket Connection { + get { + return null; + } + } + + [ScriptField] + public object Headers { + get { + return null; + } + } + + [ScriptField] + public string HttpVersion { + get { + return null; + } + } + + [ScriptField] + public HttpVerb Method { + get { + return HttpVerb.GET; + } + } + + [ScriptField] + public object Trailers { + get { + return null; + } + } + + [ScriptField] + public string Url { + get { + return null; + } + } + } +} diff --git a/src/Libraries/Node/Node.Restify/HttpServerResponse.cs b/src/Libraries/Node/Node.Restify/HttpServerResponse.cs new file mode 100644 index 000000000..754b5f1f3 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/HttpServerResponse.cs @@ -0,0 +1,58 @@ +// HttpServerResponse.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using NodeApi.IO; +using NodeApi.Network; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + public class HttpServerResponse : WritableStream, IEventEmitter { + + protected HttpServerResponse() { + } + + [ScriptField] + public int StatusCode { + get; + set; + } + + public void AddTrailers(Dictionary headers) { + } + + public string GetHeader(string name) { + return null; + } + + public void RemoveHeader(string name) { + } + + public void SendDate() { + } + + public void SetHeader(string name, string value) { + } + + public void WriteContinue() { + } + + public void WriteHead(HttpStatusCode statusCode) { + } + + public void WriteHead(HttpStatusCode statusCode, string reasonPhrase) { + } + + public void WriteHead(HttpStatusCode statusCode, Dictionary headers) { + } + + public void WriteHead(HttpStatusCode statusCode, string reasonPhrase, Dictionary headers) { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/Node.Restify.csproj b/src/Libraries/Node/Node.Restify/Node.Restify.csproj index 22c848ba8..450720736 100644 --- a/src/Libraries/Node/Node.Restify/Node.Restify.csproj +++ b/src/Libraries/Node/Node.Restify/Node.Restify.csproj @@ -1,4 +1,4 @@ - + Debug @@ -28,7 +28,7 @@ true - none + none false true ..\..\..\..\bin\Release\ @@ -43,12 +43,13 @@ Properties\ScriptSharp.cs - + + + - + - @@ -73,10 +74,9 @@ Node.Core - - + \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/Node.Restify.vsdoc b/src/Libraries/Node/Node.Restify/Node.Restify.vsdoc deleted file mode 100644 index 9ffff5e7f..000000000 --- a/src/Libraries/Node/Node.Restify/Node.Restify.vsdoc +++ /dev/null @@ -1,7 +0,0 @@ - - - - default - - - diff --git a/src/Libraries/Node/Node.Restify/Restify.cs b/src/Libraries/Node/Node.Restify/RestifyApplication.cs similarity index 97% rename from src/Libraries/Node/Node.Restify/Restify.cs rename to src/Libraries/Node/Node.Restify/RestifyApplication.cs index 91af39826..101757d08 100644 --- a/src/Libraries/Node/Node.Restify/Restify.cs +++ b/src/Libraries/Node/Node.Restify/RestifyApplication.cs @@ -11,7 +11,7 @@ namespace NodeApi.Restify { [ScriptImport] [ScriptIgnoreNamespace] [ScriptName("restify")] - public sealed class Restify { + public static class RestifyApplication { public static RestifyChainedHandler[] AcceptParser(string[] serverAcceptable) { return null; diff --git a/src/Libraries/Node/Node.Restify/RestifyCallback.cs b/src/Libraries/Node/Node.Restify/RestifyCallback.cs index 3f6dbcd0e..5bc17aadd 100644 --- a/src/Libraries/Node/Node.Restify/RestifyCallback.cs +++ b/src/Libraries/Node/Node.Restify/RestifyCallback.cs @@ -6,4 +6,4 @@ namespace NodeApi.Restify { public delegate void RestifyCallback(RestifyError error, RestifyRequest request, RestifyResponse response, object content); -} \ No newline at end of file +} diff --git a/src/Libraries/Node/Node.Restify/RestifyChain.cs b/src/Libraries/Node/Node.Restify/RestifyChain.cs index 98823c17b..0c61351ad 100644 --- a/src/Libraries/Node/Node.Restify/RestifyChain.cs +++ b/src/Libraries/Node/Node.Restify/RestifyChain.cs @@ -23,4 +23,4 @@ public void Continue() { public void Error(Exception error) { } } -} \ No newline at end of file +} diff --git a/src/Libraries/Node/Node.Restify/RestifyClient.cs b/src/Libraries/Node/Node.Restify/RestifyClient.cs deleted file mode 100644 index 7ffc461a9..000000000 --- a/src/Libraries/Node/Node.Restify/RestifyClient.cs +++ /dev/null @@ -1,14 +0,0 @@ -// RestifyClient.cs -// Script#/Libraries/Node/Restify -// This source code is subject to terms and conditions of the Apache License, Version 2.0. -// - -using System.Runtime.CompilerServices; - -namespace NodeApi.Restify { - - [ScriptImport] - [ScriptIgnoreNamespace] - public class RestifyClient { - } -} \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/RestifyError.cs b/src/Libraries/Node/Node.Restify/RestifyError.cs index 7b8a72e87..6d5f6cec5 100644 --- a/src/Libraries/Node/Node.Restify/RestifyError.cs +++ b/src/Libraries/Node/Node.Restify/RestifyError.cs @@ -10,5 +10,8 @@ namespace NodeApi.Restify { [ScriptIgnoreNamespace] [ScriptImport] public sealed class RestifyError { + + internal RestifyError() { + } } -} \ No newline at end of file +} diff --git a/src/Libraries/Node/Node.Restify/RestifyHttpClient.cs b/src/Libraries/Node/Node.Restify/RestifyHttpClient.cs index 5c6b84542..6e71a5b40 100644 --- a/src/Libraries/Node/Node.Restify/RestifyHttpClient.cs +++ b/src/Libraries/Node/Node.Restify/RestifyHttpClient.cs @@ -14,4 +14,4 @@ public sealed class RestifyHttpClient : RestifyStringClient { private RestifyHttpClient() { } } -} \ No newline at end of file +} diff --git a/src/Libraries/Node/Node.Restify/RestifyJsonClient.cs b/src/Libraries/Node/Node.Restify/RestifyJsonClient.cs index eb29d693d..f97c0f957 100644 --- a/src/Libraries/Node/Node.Restify/RestifyJsonClient.cs +++ b/src/Libraries/Node/Node.Restify/RestifyJsonClient.cs @@ -18,4 +18,4 @@ public sealed class RestifyJsonClient : RestifyStringClient { private RestifyJsonClient() { } } -} \ No newline at end of file +} diff --git a/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs b/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs index ddda8cfbd..1768bf6d7 100644 --- a/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs +++ b/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs @@ -25,7 +25,8 @@ public sealed class RestifyJsonClientOptions { /// /// node-dtrace-provider handle /// - public object Dtrace; + [ScriptName("dtrace")] + public object DTrace; /// /// Will compress data when sent using content-encoding: gzip @@ -40,7 +41,7 @@ public sealed class RestifyJsonClientOptions { /// /// bunyan instance /// - public BunyanLogger Log; + public object Log; /// /// options to provide to node-retry; defaults to 3 retries @@ -67,4 +68,4 @@ public sealed class RestifyJsonClientOptions { /// public string Version; } -} \ No newline at end of file +} diff --git a/src/Libraries/Node/Node.Restify/BunyanLogger.cs b/src/Libraries/Node/Node.Restify/RestifyLogger.cs similarity index 69% rename from src/Libraries/Node/Node.Restify/BunyanLogger.cs rename to src/Libraries/Node/Node.Restify/RestifyLogger.cs index 9475d6c22..53c8604d4 100644 --- a/src/Libraries/Node/Node.Restify/BunyanLogger.cs +++ b/src/Libraries/Node/Node.Restify/RestifyLogger.cs @@ -10,9 +10,9 @@ namespace NodeApi.Restify { [ScriptIgnoreNamespace] [ScriptImport] - public sealed class BunyanLogger { + public sealed class RestifyLogger { - public void Debug(Dictionary options, string format, params string[] formatArguments) { + public void Debug(object options, string format, params string[] formatArguments) { } } } \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/RestifyRequest.cs b/src/Libraries/Node/Node.Restify/RestifyRequest.cs index e24c88202..ea6f050e7 100644 --- a/src/Libraries/Node/Node.Restify/RestifyRequest.cs +++ b/src/Libraries/Node/Node.Restify/RestifyRequest.cs @@ -6,7 +6,6 @@ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; -using NodeApi.Network; namespace NodeApi.Restify { @@ -61,7 +60,7 @@ public string Id { /// bunyan logger you can piggyback on /// [ScriptField] - public BunyanLogger Log { + public RestifyLogger Log { get { return null; } @@ -110,20 +109,30 @@ public bool Secure { /// [ScriptField] [ScriptName("time")] - public int TimeInMs { + public int TimeInMilliseconds { get { return 0; } } + /// + /// Check if the Accept header is present, and includes the given type. + /// + /// + /// [ScriptName("accepts")] - public string AcceptsContentType(string type) { - return null; + public bool AcceptsContentType(string type) { + return true; } + /// + /// Check if the Accept header is present, and includes the given types. + /// + /// + /// [ScriptName("accepts")] - public string AcceptsContentType(string[] types) { - return null; + public bool AcceptsContentType(string[] types) { + return true; } [ScriptName("header")] @@ -136,13 +145,23 @@ public string GetHeader(string key, string defaultValue) { return String.Empty; } - public BunyanLogger GetLogger(string name) { + /// + /// Shorthand to grab a new bunyan instance that is a child component of the one restify has: + /// + /// + /// + public RestifyLogger GetLogger(string name) { return null; } + /// + /// Check if the incoming request contains the Content-Type header field, and it contains the give mime type. + /// + /// + /// [ScriptName("is")] - public string IsContentType(string type) { - return null; + public bool IsContentType(string type) { + return true; } } } diff --git a/src/Libraries/Node/Node.Restify/RestifyResponse.cs b/src/Libraries/Node/Node.Restify/RestifyResponse.cs index f1b1616fa..895306ee4 100644 --- a/src/Libraries/Node/Node.Restify/RestifyResponse.cs +++ b/src/Libraries/Node/Node.Restify/RestifyResponse.cs @@ -4,7 +4,7 @@ // using System; -using System.Collections; +using System.Collections.Generic; using System.Runtime.CompilerServices; using NodeApi.Network; @@ -85,13 +85,10 @@ public string Id { /// /// Status code /// content - public void Json(HttpStatusCode code, Dictionary body) { + public void Json(HttpStatusCode code, object body) { } - public void Send(string message) { - } - - public void Send(Dictionary message) { + public void Send(object message) { } public void Send(int errorCode, RestifyError message) { @@ -102,7 +99,7 @@ public void Send(int errorCode, RestifyError message) { /// /// type defaults to _public_ /// options currently only takes maxAge. - public void SetCache(string type, Dictionary options) { + public void SetCache(string type, Dictionary options) { } /// diff --git a/src/Libraries/Node/Node.Restify/RestifyServer.cs b/src/Libraries/Node/Node.Restify/RestifyServer.cs index c3007a16e..f7043678f 100644 --- a/src/Libraries/Node/Node.Restify/RestifyServer.cs +++ b/src/Libraries/Node/Node.Restify/RestifyServer.cs @@ -31,7 +31,7 @@ public String[] Acceptable { /// bunyan instance /// [ScriptField] - public BunyanLogger Log { + public RestifyLogger Log { get { return null; } @@ -67,6 +67,13 @@ public string Version { } } + /// + /// Emitted after a route has finished all the handlers you registered. + /// You can use this to write audit logs, etc. The route parameter will be the Route object that ran. + /// Note that when you are using the default 404/405/BadVersion handlers, this event will still be fired, + /// but route will be null. If you have registered your own listeners for those, this event will not be fired + /// unless you invoke the cb argument that is provided with them. + /// [ScriptEvent("on", "removeListener")] public event Action After { add { @@ -75,6 +82,11 @@ public event Action After { } } + /// + /// When a client request is sent for a URL that does exist, but you have not registered a route for that HTTP verb, + /// restify will emit this event. Note that restify checks for listeners on this event, and if there are none, + /// responds with a default 405 handler. It is expected that if you listen for this event, you respond to the client. + /// [ScriptEvent("on", "removeListener")] [ScriptName("MethodNotAllowed")] public event Action MethodNotAllowed { @@ -84,6 +96,11 @@ public event Action MethodNotAllowed { } } + /// + /// When a client request is sent for a URL that does not exist, restify will emit this event. + /// Note that restify checks for listeners on this event, and if there are none, responds with a default 404 handler. + /// It is expected that if you listen for this event, you respond to the client. + /// [ScriptEvent("on", "removeListener")] [ScriptName("NotFound")] public event Action NotFound { @@ -93,6 +110,11 @@ public event Action NotFound { } } + /// + /// Emitted when some handler throws an uncaughtException somewhere in the chain. + /// The default behavior is to just call res.send(error), and let the built-ins in restify handle transforming, + /// but you can override to whatever you want here. + /// [ScriptEvent("on", "removeListener")] public event Action UncaughtException { add { @@ -101,6 +123,11 @@ public event Action UncaughtException { } } + /// + /// When a client request is sent for a route that exist, but has a content-type mismatch, restify will emit this event. + /// Note that restify checks for listeners on this event, and if there are none, responds with a default 415 handler. + /// It is expected that if you listen for this event, you respond to the client. + /// [ScriptEvent("on", "removeListener")] [ScriptName("UnsupportedMediaType")] public event Action UnsupportedMediaType { @@ -110,6 +137,11 @@ public event Action UnsupportedMediaType { } } + /// + /// When a client request is sent for a route that exists, but does not match the version(s) on those routes, + /// restify will emit this event. Note that restify checks for listeners on this event, and if there are none, + /// responds with a default 400 handler. It is expected that if you listen for this event, you respond to the client. + /// [ScriptEvent("on", "removeListener")] [ScriptName("VersionNotAllowed")] public event Action VersionNotAllowed { @@ -123,11 +155,11 @@ public RestifyChainedHandler[] AcceptParser(string[] acceptable) { return null; } - public Dictionary Address() { + public Dictionary Address() { return null; } - public RestifyChainedHandler[] AuditLogger(Dictionary options) { + public RestifyChainedHandler[] AuditLogger(object options) { return null; } @@ -150,7 +182,7 @@ public RestifyServer CreateServer() { return null; } - public RestifyServer CreateServer(Dictionary options) { + public RestifyServer CreateServer(object options) { return null; } @@ -196,10 +228,10 @@ public void Get(RegExp pathPattern, RestifyChainedHandler handler) { public void Get(RegExp pathPattern, RestifyChainedHandler[] handlers) { } - public void Get(Dictionary options, RestifyChainedHandler handler) { + public void Get(object options, RestifyChainedHandler handler) { } - public void Get(Dictionary options, RestifyChainedHandler[] handlers) { + public void Get(object options, RestifyChainedHandler[] handlers) { } public RestifyChainedHandler[] GzipResponse() { @@ -253,11 +285,11 @@ public RestifyChainedHandler[] RequestLogger() { return null; } - public RestifyChainedHandler[] RequestLogger(Dictionary options) { + public RestifyChainedHandler[] RequestLogger(object options) { return null; } - public RestifyChainedHandler[] ServeStatic(Dictionary options) { + public RestifyChainedHandler[] ServeStatic(object options) { return null; } diff --git a/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs b/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs index 6441e3354..abcc8b875 100644 --- a/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs +++ b/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs @@ -17,4 +17,4 @@ public sealed class RestifyServerGetOptions { public string Version; } -} \ No newline at end of file +} diff --git a/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs b/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs index 1bb0a1af3..87c49f74f 100644 --- a/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs +++ b/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs @@ -32,7 +32,7 @@ public sealed class RestifyServerOptions { /// /// You can optionally pass in a bunyan (https://github.com/trentm/node-bunyan) instance; not required /// - public BunyanLogger Log; + public object Log; /// /// By default, this will be set in the Server response header, default is restify @@ -59,7 +59,7 @@ public sealed class RestifyServerOptions { /// } /// }); /// - public string ResponseTimeFormatter; + public Func ResponseTimeFormatter; /// /// By default, this will be X-Response-Time @@ -71,4 +71,4 @@ public sealed class RestifyServerOptions { /// public string Version; } -} \ No newline at end of file +} diff --git a/src/Libraries/Node/Node.Restify/RestifyStringClient.cs b/src/Libraries/Node/Node.Restify/RestifyStringClient.cs index a4cbb9117..94c687b64 100644 --- a/src/Libraries/Node/Node.Restify/RestifyStringClient.cs +++ b/src/Libraries/Node/Node.Restify/RestifyStringClient.cs @@ -3,7 +3,6 @@ // This source code is subject to terms and conditions of the Apache License, Version 2.0. // -using System.Collections; using System.Runtime.CompilerServices; namespace NodeApi.Restify { @@ -21,7 +20,7 @@ public void BasicAuth(string login, string password) { /// /// del doesn't take content, since you know, it should't: /// - public void Del(string path, Dictionary content, RestifyCallback callback) { + public void Del(string path, object content, RestifyCallback callback) { } /// @@ -46,13 +45,13 @@ public void Head(string path, RestifyCallback callback) { /// /// /// - public void Post(string path, Dictionary content, RestifyCallback callback) { + public void Post(string path, object content, RestifyCallback callback) { } /// /// Just like post: /// - public void Put(string path, Dictionary content, RestifyCallback callback) { + public void Put(string path, object content, RestifyCallback callback) { } } } diff --git a/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs b/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs index 4ef837c16..9f97ff5dc 100644 --- a/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs +++ b/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs @@ -3,12 +3,14 @@ // This source code is subject to terms and conditions of the Apache License, Version 2.0. // +using System; using System.Runtime.CompilerServices; namespace NodeApi.Restify { [ScriptIgnoreNamespace] [ScriptImport] + [ScriptName("Object")] public sealed class RestifyThrottleOptions { /// From 01c53b8688aea0a0d65362e61aabfd7f3c906eeb Mon Sep 17 00:00:00 2001 From: Nick Karnik Date: Sun, 14 Apr 2013 14:54:27 -0700 Subject: [PATCH 03/35] # This is a combination of 2 commits. # The first commit's message is: Applied changes as suggested in the comments in https://github.com/nikhilk/scriptsharp/pull/353 # This is the 2nd commit message: Added support for Node-Restify --- src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs | 4 ++-- src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs | 4 ++-- src/Libraries/Node/Node.Restify/Node.Restify.csproj | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs b/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs index 22ead043e..ac8358a3a 100644 --- a/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs +++ b/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs @@ -11,9 +11,9 @@ namespace NodeApi.Network { [ScriptImport] [ScriptIgnoreNamespace] - public sealed class HttpServerRequest : ReadableStream, IEventEmitter { + public class HttpServerRequest : ReadableStream, IEventEmitter { - private HttpServerRequest() { + protected HttpServerRequest() { } [ScriptField] diff --git a/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs b/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs index f8d9355d7..d9422dcf1 100644 --- a/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs +++ b/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs @@ -12,9 +12,9 @@ namespace NodeApi.Network { [ScriptImport] [ScriptIgnoreNamespace] - public sealed class HttpServerResponse : WritableStream, IEventEmitter { + public class HttpServerResponse : WritableStream, IEventEmitter { - private HttpServerResponse() { + protected HttpServerResponse() { } [ScriptField] diff --git a/src/Libraries/Node/Node.Restify/Node.Restify.csproj b/src/Libraries/Node/Node.Restify/Node.Restify.csproj index 450720736..7ccd7ba56 100644 --- a/src/Libraries/Node/Node.Restify/Node.Restify.csproj +++ b/src/Libraries/Node/Node.Restify/Node.Restify.csproj @@ -1,4 +1,4 @@ - + Debug From 1f510d1b67def883824b2adb01b764dcf97c9038 Mon Sep 17 00:00:00 2001 From: Nick Karnik Date: Tue, 16 Apr 2013 17:10:17 -0700 Subject: [PATCH 04/35] Additional fixes to initial Node-restify library port --- .../Node.Restify/RestifyJsonClientOptions.cs | 7 +++ .../Node/Node.Restify/RestifyLogger.cs | 5 ++ .../Node/Node.Restify/RestifyRequest.cs | 47 ++++++++++++++++++- .../Node/Node.Restify/RestifyResponse.cs | 42 ++++++++++++++++- .../Node.Restify/RestifyServerGetOptions.cs | 6 +++ .../Node/Node.Restify/RestifyServerOptions.cs | 9 +++- .../Node.Restify/RestifyThrottleOptions.cs | 6 +++ 7 files changed, 116 insertions(+), 6 deletions(-) diff --git a/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs b/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs index 1768bf6d7..082f1e5ba 100644 --- a/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs +++ b/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs @@ -10,8 +10,15 @@ namespace NodeApi.Restify { [ScriptImport] [ScriptIgnoreNamespace] + [ScriptName("Object")] public sealed class RestifyJsonClientOptions { + public RestifyJsonClientOptions() { + } + + public RestifyJsonClientOptions(params object[] nameValuePairs) { + } + /// /// Accept header to send /// diff --git a/src/Libraries/Node/Node.Restify/RestifyLogger.cs b/src/Libraries/Node/Node.Restify/RestifyLogger.cs index 53c8604d4..f98dc8245 100644 --- a/src/Libraries/Node/Node.Restify/RestifyLogger.cs +++ b/src/Libraries/Node/Node.Restify/RestifyLogger.cs @@ -3,6 +3,7 @@ // This source code is subject to terms and conditions of the Apache License, Version 2.0. // +using System; using System.Collections; using System.Runtime.CompilerServices; @@ -10,8 +11,12 @@ namespace NodeApi.Restify { [ScriptIgnoreNamespace] [ScriptImport] + [ScriptName("Object")] public sealed class RestifyLogger { + private RestifyLogger() { + } + public void Debug(object options, string format, params string[] formatArguments) { } } diff --git a/src/Libraries/Node/Node.Restify/RestifyRequest.cs b/src/Libraries/Node/Node.Restify/RestifyRequest.cs index ea6f050e7..a982abe2f 100644 --- a/src/Libraries/Node/Node.Restify/RestifyRequest.cs +++ b/src/Libraries/Node/Node.Restify/RestifyRequest.cs @@ -6,16 +6,24 @@ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; +using NodeApi.Network; namespace NodeApi.Restify { [ScriptIgnoreNamespace] [ScriptImport] - public sealed class RestifyRequest : HttpServerRequest { + public sealed class RestifyRequest { private RestifyRequest() { } + [ScriptField] + public Socket Connection { + get { + return null; + } + } + /// /// short hand for the header content-length /// @@ -36,6 +44,13 @@ public string ContentType { } } + [ScriptField] + public object Headers { + get { + return null; + } + } + /// /// url.parse(req.url) href /// @@ -46,6 +61,13 @@ public string Href { } } + [ScriptField] + public string HttpVersion { + get { + return null; + } + } + /// /// A unique request id (x-request-id) /// @@ -66,6 +88,13 @@ public RestifyLogger Log { } } + [ScriptField] + public HttpVerb Method { + get { + return HttpVerb.GET; + } + } + [ScriptField] [ScriptName("params")] public Dictionary Parameters { @@ -103,7 +132,7 @@ public bool Secure { return true; } } - + /// /// the time when this request arrived (ms since epoch) /// @@ -115,6 +144,20 @@ public int TimeInMilliseconds { } } + [ScriptField] + public object Trailers { + get { + return null; + } + } + + [ScriptField] + public string Url { + get { + return null; + } + } + /// /// Check if the Accept header is present, and includes the given type. /// diff --git a/src/Libraries/Node/Node.Restify/RestifyResponse.cs b/src/Libraries/Node/Node.Restify/RestifyResponse.cs index 895306ee4..ddb2bb85b 100644 --- a/src/Libraries/Node/Node.Restify/RestifyResponse.cs +++ b/src/Libraries/Node/Node.Restify/RestifyResponse.cs @@ -12,7 +12,7 @@ namespace NodeApi.Restify { [ScriptIgnoreNamespace] [ScriptImport] - public sealed class RestifyResponse : HttpServerResponse { + public sealed class RestifyResponse { private RestifyResponse() { } @@ -51,7 +51,7 @@ public string ContentType { /// response headers /// [ScriptField] - public object Headers { + public Dictionary Headers { get { return null; } @@ -78,6 +78,19 @@ public string Id { } } + [ScriptField] + public int StatusCode { + get; + set; + } + + public void AddTrailers(Dictionary headers) { + } + + public string GetHeader(string name) { + return null; + } + /// /// Short-hand for: /// res.contentType = 'json'; @@ -88,12 +101,19 @@ public string Id { public void Json(HttpStatusCode code, object body) { } + public void RemoveHeader(string name) { + } + + public void Send(object message) { } public void Send(int errorCode, RestifyError message) { } + public void SendDate() { + } + /// /// Sets the cache-control header. /// @@ -102,6 +122,9 @@ public void Send(int errorCode, RestifyError message) { public void SetCache(string type, Dictionary options) { } + public void SetHeader(string name, string value) { + } + /// /// Sets the response statusCode. /// @@ -117,5 +140,20 @@ public void Status(HttpStatusCode code) { /// body can be an Object, a Buffer, or an Error. public void Status(HttpStatusCode code, object body) { } + + public void WriteContinue() { + } + + public void WriteHead(HttpStatusCode statusCode) { + } + + public void WriteHead(HttpStatusCode statusCode, string reasonPhrase) { + } + + public void WriteHead(HttpStatusCode statusCode, Dictionary headers) { + } + + public void WriteHead(HttpStatusCode statusCode, string reasonPhrase, Dictionary headers) { + } } } diff --git a/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs b/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs index abcc8b875..70f4edbf2 100644 --- a/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs +++ b/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs @@ -13,6 +13,12 @@ namespace NodeApi.Restify { [ScriptName("Object")] public sealed class RestifyServerGetOptions { + public RestifyServerGetOptions() { + } + + public RestifyServerGetOptions(params object[] nameValuePairs) { + } + public string Path; public string Version; diff --git a/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs b/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs index 87c49f74f..e25086916 100644 --- a/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs +++ b/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs @@ -12,7 +12,12 @@ namespace NodeApi.Restify { [ScriptImport] [ScriptName("Object")] public sealed class RestifyServerOptions { - public string Test; + + public RestifyServerOptions() { + } + + public RestifyServerOptions(params object[] nameValuePairs) { + } /// /// If you want to create an HTTPS server, pass in the PEM-encoded certificate and key @@ -59,7 +64,7 @@ public sealed class RestifyServerOptions { /// } /// }); /// - public Func ResponseTimeFormatter; + public Func ResponseTimeFormatter; /// /// By default, this will be X-Response-Time diff --git a/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs b/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs index 9f97ff5dc..5d312cb7c 100644 --- a/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs +++ b/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs @@ -13,6 +13,12 @@ namespace NodeApi.Restify { [ScriptName("Object")] public sealed class RestifyThrottleOptions { + public RestifyThrottleOptions() { + } + + public RestifyThrottleOptions(params object[] nameValuePairs) { + } + /// /// If available, the amount of requests to burst to /// From 48673d0a4d94d68bcb1bf599059314fa072b40ba Mon Sep 17 00:00:00 2001 From: Nick Karnik Date: Tue, 16 Apr 2013 17:12:58 -0700 Subject: [PATCH 05/35] Removing files for initial node-restify commit Removing files for initial node-restify commit --- ScriptSharp.sln | 20 ------ .../Node/Node.Restify/HttpServerRequest.cs | 62 ------------------- .../Node/Node.Restify/HttpServerResponse.cs | 58 ----------------- .../Node/Node.Restify/Node.Restify.csproj | 4 +- 4 files changed, 1 insertion(+), 143 deletions(-) delete mode 100644 ScriptSharp.sln delete mode 100644 src/Libraries/Node/Node.Restify/HttpServerRequest.cs delete mode 100644 src/Libraries/Node/Node.Restify/HttpServerResponse.cs diff --git a/ScriptSharp.sln b/ScriptSharp.sln deleted file mode 100644 index a1a131da0..000000000 --- a/ScriptSharp.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptSharp", "ScriptSharp\ScriptSharp.csproj", "{54C786E5-FD14-4036-92AE-E9F25B71534B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {54C786E5-FD14-4036-92AE-E9F25B71534B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {54C786E5-FD14-4036-92AE-E9F25B71534B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {54C786E5-FD14-4036-92AE-E9F25B71534B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {54C786E5-FD14-4036-92AE-E9F25B71534B}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/Libraries/Node/Node.Restify/HttpServerRequest.cs b/src/Libraries/Node/Node.Restify/HttpServerRequest.cs deleted file mode 100644 index 0189157d8..000000000 --- a/src/Libraries/Node/Node.Restify/HttpServerRequest.cs +++ /dev/null @@ -1,62 +0,0 @@ -// HttpServerRequest.cs -// Script#/Libraries/Node/Restify -// This source code is subject to terms and conditions of the Apache License, Version 2.0. -// - -using System; -using System.Runtime.CompilerServices; -using NodeApi.IO; -using NodeApi.Network; - -namespace NodeApi.Restify { - - [ScriptImport] - [ScriptIgnoreNamespace] - public class HttpServerRequest : ReadableStream, IEventEmitter { - - protected HttpServerRequest() { - } - - [ScriptField] - public Socket Connection { - get { - return null; - } - } - - [ScriptField] - public object Headers { - get { - return null; - } - } - - [ScriptField] - public string HttpVersion { - get { - return null; - } - } - - [ScriptField] - public HttpVerb Method { - get { - return HttpVerb.GET; - } - } - - [ScriptField] - public object Trailers { - get { - return null; - } - } - - [ScriptField] - public string Url { - get { - return null; - } - } - } -} diff --git a/src/Libraries/Node/Node.Restify/HttpServerResponse.cs b/src/Libraries/Node/Node.Restify/HttpServerResponse.cs deleted file mode 100644 index 754b5f1f3..000000000 --- a/src/Libraries/Node/Node.Restify/HttpServerResponse.cs +++ /dev/null @@ -1,58 +0,0 @@ -// HttpServerResponse.cs -// Script#/Libraries/Node/Restify -// This source code is subject to terms and conditions of the Apache License, Version 2.0. -// - -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using NodeApi.IO; -using NodeApi.Network; - -namespace NodeApi.Restify { - - [ScriptImport] - [ScriptIgnoreNamespace] - public class HttpServerResponse : WritableStream, IEventEmitter { - - protected HttpServerResponse() { - } - - [ScriptField] - public int StatusCode { - get; - set; - } - - public void AddTrailers(Dictionary headers) { - } - - public string GetHeader(string name) { - return null; - } - - public void RemoveHeader(string name) { - } - - public void SendDate() { - } - - public void SetHeader(string name, string value) { - } - - public void WriteContinue() { - } - - public void WriteHead(HttpStatusCode statusCode) { - } - - public void WriteHead(HttpStatusCode statusCode, string reasonPhrase) { - } - - public void WriteHead(HttpStatusCode statusCode, Dictionary headers) { - } - - public void WriteHead(HttpStatusCode statusCode, string reasonPhrase, Dictionary headers) { - } - } -} diff --git a/src/Libraries/Node/Node.Restify/Node.Restify.csproj b/src/Libraries/Node/Node.Restify/Node.Restify.csproj index 7ccd7ba56..6c800093b 100644 --- a/src/Libraries/Node/Node.Restify/Node.Restify.csproj +++ b/src/Libraries/Node/Node.Restify/Node.Restify.csproj @@ -1,4 +1,4 @@ - + Debug @@ -44,8 +44,6 @@ Properties\ScriptSharp.cs - - From 13e42d695b9200db5f445dbb84d19ff400fb1c98 Mon Sep 17 00:00:00 2001 From: Nick Karnik Date: Sun, 31 Mar 2013 21:18:49 -0700 Subject: [PATCH 06/35] Added support for Node-Restify Applied changes as suggested in the comments in https://github.com/nikhilk/scriptsharp/pull/353 Applied changes as suggested in the comments in https://github.com/nikhilk/scriptsharp/pull/353 Added support for Node-Restify Additional fixes to initial Node-restify library port Removing files for initial node-restify commit Removing files for initial node-restify commit Created node-restify stubs for s# --- .../Node.Core/Network/HttpServerRequest.cs | 4 +- .../Node.Core/Network/HttpServerResponse.cs | 4 +- .../Node/Node.Restify/Node.Restify.csproj | 80 +++++ .../Node.Restify/Properties/AssemblyInfo.cs | 11 + .../Node.Restify/Properties/ScriptInfo.txt | 10 + .../Node/Node.Restify/RestifyApplication.cs | 80 +++++ .../Node/Node.Restify/RestifyCallback.cs | 9 + .../Node/Node.Restify/RestifyChain.cs | 26 ++ .../Node/Node.Restify/RestifyError.cs | 17 + .../Node/Node.Restify/RestifyHandler.cs | 18 + .../Node/Node.Restify/RestifyHttpClient.cs | 17 + .../Node/Node.Restify/RestifyJsonClient.cs | 21 ++ .../Node.Restify/RestifyJsonClientOptions.cs | 78 +++++ .../Node/Node.Restify/RestifyLogger.cs | 23 ++ .../Node/Node.Restify/RestifyRequest.cs | 210 ++++++++++++ .../Node/Node.Restify/RestifyResponse.cs | 159 +++++++++ .../Node/Node.Restify/RestifyRoute.cs | 17 + .../Node/Node.Restify/RestifyServer.cs | 315 ++++++++++++++++++ .../Node.Restify/RestifyServerGetOptions.cs | 26 ++ .../Node/Node.Restify/RestifyServerOptions.cs | 79 +++++ .../Node/Node.Restify/RestifyStringClient.cs | 57 ++++ .../Node.Restify/RestifyThrottleOptions.cs | 91 +++++ src/ScriptSharp.sln | 15 + 23 files changed, 1363 insertions(+), 4 deletions(-) create mode 100644 src/Libraries/Node/Node.Restify/Node.Restify.csproj create mode 100644 src/Libraries/Node/Node.Restify/Properties/AssemblyInfo.cs create mode 100644 src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt create mode 100644 src/Libraries/Node/Node.Restify/RestifyApplication.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyCallback.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyChain.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyError.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyHandler.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyHttpClient.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyJsonClient.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyLogger.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyRequest.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyResponse.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyRoute.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyServer.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyServerOptions.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyStringClient.cs create mode 100644 src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs diff --git a/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs b/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs index 22ead043e..ac8358a3a 100644 --- a/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs +++ b/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs @@ -11,9 +11,9 @@ namespace NodeApi.Network { [ScriptImport] [ScriptIgnoreNamespace] - public sealed class HttpServerRequest : ReadableStream, IEventEmitter { + public class HttpServerRequest : ReadableStream, IEventEmitter { - private HttpServerRequest() { + protected HttpServerRequest() { } [ScriptField] diff --git a/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs b/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs index f8d9355d7..d9422dcf1 100644 --- a/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs +++ b/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs @@ -12,9 +12,9 @@ namespace NodeApi.Network { [ScriptImport] [ScriptIgnoreNamespace] - public sealed class HttpServerResponse : WritableStream, IEventEmitter { + public class HttpServerResponse : WritableStream, IEventEmitter { - private HttpServerResponse() { + protected HttpServerResponse() { } [ScriptField] diff --git a/src/Libraries/Node/Node.Restify/Node.Restify.csproj b/src/Libraries/Node/Node.Restify/Node.Restify.csproj new file mode 100644 index 000000000..6c800093b --- /dev/null +++ b/src/Libraries/Node/Node.Restify/Node.Restify.csproj @@ -0,0 +1,80 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {1ECC689C-2542-4EE8-8A86-7627E63F44F8} + Library + Properties + NodeApi.Restify + Script.Node.Restify + True + true + ..\..\..\ScriptSharp.snk + v2.0 + 512 + + + + ..\..\..\..\bin\Debug\ + false + DEBUG + prompt + 4 + ..\..\..\..\bin\Debug\Script.Node.Restify.xml + 1591, 0661, 0660, 1684 + true + + + none + false + true + ..\..\..\..\bin\Release\ + TRACE + prompt + 4 + ..\..\..\..\bin\Release\Script.Node.Restify.xml + 1591, 0661, 0660, 1684 + true + + + + Properties\ScriptSharp.cs + + + + + + + + + + + + + + + + + + + + + + + {36d4b098-a21c-4725-acd3-400922885f38} + CoreLib + + + {4a9f7ce9-5a45-4b28-ad01-05528709b6e4} + Node.Core + + + + + + + + \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/Properties/AssemblyInfo.cs b/src/Libraries/Node/Node.Restify/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..d1497e2e9 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// AssemblyInfo.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Reflection; + +[assembly: AssemblyTitle("Script.Node.Restify")] +[assembly: AssemblyDescription("Script# NodeJS Restify Module API")] +[assembly: ScriptAssembly("restify")] diff --git a/src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt b/src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt new file mode 100644 index 000000000..018207ec7 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt @@ -0,0 +1,10 @@ +Node Express Module +=============================================================================== + +This assembly provides access to Restify Module APIs for NodeJS applications. +This is only meant for use at development time, so you can reference and compile +your c# code against restify APIs. + +More information is on http://mcavage.github.com/node-restify/. + +------------------------------------------------------------------------------- diff --git a/src/Libraries/Node/Node.Restify/RestifyApplication.cs b/src/Libraries/Node/Node.Restify/RestifyApplication.cs new file mode 100644 index 000000000..101757d08 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyApplication.cs @@ -0,0 +1,80 @@ +// Restify.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + [ScriptName("restify")] + public static class RestifyApplication { + + public static RestifyChainedHandler[] AcceptParser(string[] serverAcceptable) { + return null; + } + + public static RestifyChainedHandler[] AuthorizationParser() { + return null; + } + + public static RestifyChainedHandler[] BodyParser() { + return null; + } + + public static RestifyChainedHandler[] ConditionalRequest() { + return null; + } + + public static RestifyHttpClient CreateHttpClient() { + return null; + } + + public static RestifyJsonClient CreateJsonClient() { + return null; + } + + public static RestifyJsonClient CreateJsonClient(RestifyJsonClientOptions options) { + return null; + } + + public static RestifyServer CreateServer() { + return null; + } + + public static RestifyServer CreateServer(RestifyServerOptions rs) { + return null; + } + + public static RestifyStringClient CreateStringClient() { + return null; + } + + public static RestifyChainedHandler[] DateParser() { + return null; + } + + public static RestifyChainedHandler[] GZipResponse() { + return null; + } + + public static RestifyChainedHandler[] JsonBodyParser() { + return null; + } + + public static RestifyChainedHandler[] Jsonp() { + return null; + } + + public static RestifyChainedHandler QueryParser() { + return null; + } + + public static RestifyChainedHandler[] Throttle(RestifyThrottleOptions options) { + return null; + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyCallback.cs b/src/Libraries/Node/Node.Restify/RestifyCallback.cs new file mode 100644 index 000000000..5bc17aadd --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyCallback.cs @@ -0,0 +1,9 @@ +// RestifyCallback.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +namespace NodeApi.Restify { + + public delegate void RestifyCallback(RestifyError error, RestifyRequest request, RestifyResponse response, object content); +} diff --git a/src/Libraries/Node/Node.Restify/RestifyChain.cs b/src/Libraries/Node/Node.Restify/RestifyChain.cs new file mode 100644 index 000000000..0c61351ad --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyChain.cs @@ -0,0 +1,26 @@ +// RestifyChain.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyChain { + + private RestifyChain() { + } + + [ScriptSkip] + public void Continue() { + } + + [ScriptSkip] + public void Error(Exception error) { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyError.cs b/src/Libraries/Node/Node.Restify/RestifyError.cs new file mode 100644 index 000000000..6d5f6cec5 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyError.cs @@ -0,0 +1,17 @@ +// RestifyError.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyError { + + internal RestifyError() { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyHandler.cs b/src/Libraries/Node/Node.Restify/RestifyHandler.cs new file mode 100644 index 000000000..111182019 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyHandler.cs @@ -0,0 +1,18 @@ +// RestifyHandler.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + public delegate void RestifyHandler(RestifyRequest request, RestifyResponse response); + + [ScriptImport] + [ScriptIgnoreNamespace] + public delegate RestifyChainedHandler RestifyChainedHandler(RestifyRequest request, RestifyResponse response, Func next); +} diff --git a/src/Libraries/Node/Node.Restify/RestifyHttpClient.cs b/src/Libraries/Node/Node.Restify/RestifyHttpClient.cs new file mode 100644 index 000000000..6e71a5b40 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyHttpClient.cs @@ -0,0 +1,17 @@ +// RestifyHttpClient.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class RestifyHttpClient : RestifyStringClient { + + private RestifyHttpClient() { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyJsonClient.cs b/src/Libraries/Node/Node.Restify/RestifyJsonClient.cs new file mode 100644 index 000000000..f97c0f957 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyJsonClient.cs @@ -0,0 +1,21 @@ +// RestifyJsonClient.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Collections; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + /// + /// sends and expects application/json + /// + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class RestifyJsonClient : RestifyStringClient { + + private RestifyJsonClient() { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs b/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs new file mode 100644 index 000000000..082f1e5ba --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyJsonClientOptions.cs @@ -0,0 +1,78 @@ +// RestifyJsonClientOptions.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + [ScriptName("Object")] + public sealed class RestifyJsonClientOptions { + + public RestifyJsonClientOptions() { + } + + public RestifyJsonClientOptions(params object[] nameValuePairs) { + } + + /// + /// Accept header to send + /// + public string Accept; + + /// + /// Amount of time to wait for a socket + /// + public int ConnectTimeout; + + /// + /// node-dtrace-provider handle + /// + [ScriptName("dtrace")] + public object DTrace; + + /// + /// Will compress data when sent using content-encoding: gzip + /// + public object Gzip; + + /// + /// HTTP headers to set in all requests + /// + public object Headers; + + /// + /// bunyan instance + /// + public object Log; + + /// + /// options to provide to node-retry; defaults to 3 retries + /// + public object Retry; + + /// + /// synchronous callback for interposing headers before request is sent + /// + public Action SignRequest; + + /// + /// Fully-qualified URL to connect to + /// + public string Url; + + /// + /// user-agent string to use; restify inserts one, but you can override it + /// + public string UserAgent; + + /// + /// semver string to set the accept-version + /// + public string Version; + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyLogger.cs b/src/Libraries/Node/Node.Restify/RestifyLogger.cs new file mode 100644 index 000000000..f98dc8245 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyLogger.cs @@ -0,0 +1,23 @@ +// BunyanLogger.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + [ScriptName("Object")] + public sealed class RestifyLogger { + + private RestifyLogger() { + } + + public void Debug(object options, string format, params string[] formatArguments) { + } + } +} \ No newline at end of file diff --git a/src/Libraries/Node/Node.Restify/RestifyRequest.cs b/src/Libraries/Node/Node.Restify/RestifyRequest.cs new file mode 100644 index 000000000..a982abe2f --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyRequest.cs @@ -0,0 +1,210 @@ +// RestifyRequest.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using NodeApi.Network; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyRequest { + + private RestifyRequest() { + } + + [ScriptField] + public Socket Connection { + get { + return null; + } + } + + /// + /// short hand for the header content-length + /// + [ScriptField] + public int ContentLength { + get { + return 0; + } + } + + /// + /// short hand for the header content-type + /// + [ScriptField] + public string ContentType { + get { + return String.Empty; + } + } + + [ScriptField] + public object Headers { + get { + return null; + } + } + + /// + /// url.parse(req.url) href + /// + [ScriptField] + public string Href { + get { + return String.Empty; + } + } + + [ScriptField] + public string HttpVersion { + get { + return null; + } + } + + /// + /// A unique request id (x-request-id) + /// + [ScriptField] + public string Id { + get { + return String.Empty; + } + } + + /// + /// bunyan logger you can piggyback on + /// + [ScriptField] + public RestifyLogger Log { + get { + return null; + } + } + + [ScriptField] + public HttpVerb Method { + get { + return HttpVerb.GET; + } + } + + [ScriptField] + [ScriptName("params")] + public Dictionary Parameters { + get { + return null; + } + } + + /// + /// cleaned up URL path + /// + [ScriptField] + public string Path { + get { + return String.Empty; + } + } + + /// + /// the query string only + /// + [ScriptField] + public string Query { + get { + return String.Empty; + } + } + + /// + /// Whether this was an SSL request + /// + [ScriptField] + public bool Secure { + get { + return true; + } + } + + /// + /// the time when this request arrived (ms since epoch) + /// + [ScriptField] + [ScriptName("time")] + public int TimeInMilliseconds { + get { + return 0; + } + } + + [ScriptField] + public object Trailers { + get { + return null; + } + } + + [ScriptField] + public string Url { + get { + return null; + } + } + + /// + /// Check if the Accept header is present, and includes the given type. + /// + /// + /// + [ScriptName("accepts")] + public bool AcceptsContentType(string type) { + return true; + } + + /// + /// Check if the Accept header is present, and includes the given types. + /// + /// + /// + [ScriptName("accepts")] + public bool AcceptsContentType(string[] types) { + return true; + } + + [ScriptName("header")] + public string GetHeader(string name) { + return String.Empty; + } + + [ScriptName("header")] + public string GetHeader(string key, string defaultValue) { + return String.Empty; + } + + /// + /// Shorthand to grab a new bunyan instance that is a child component of the one restify has: + /// + /// + /// + public RestifyLogger GetLogger(string name) { + return null; + } + + /// + /// Check if the incoming request contains the Content-Type header field, and it contains the give mime type. + /// + /// + /// + [ScriptName("is")] + public bool IsContentType(string type) { + return true; + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyResponse.cs b/src/Libraries/Node/Node.Restify/RestifyResponse.cs new file mode 100644 index 000000000..ddb2bb85b --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyResponse.cs @@ -0,0 +1,159 @@ +// RestifyResponse.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using NodeApi.Network; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyResponse { + + private RestifyResponse() { + } + + /// + /// In conjunction with contentType, you can explicitly set the charSet to be written in the content-type header + /// + [ScriptField] + public string CharSet { + get { + return String.Empty; + } + } + + /// + /// short hand for the header content-length + /// + [ScriptField] + public int ContentLength { + get { + return 0; + } + } + + /// + /// short hand for the header content-type + /// + [ScriptField] + public string ContentType { + get { + return String.Empty; + } + } + + /// + /// response headers + /// + [ScriptField] + public Dictionary Headers { + get { + return null; + } + } + + /// + /// HTTP status code + /// + [ScriptName("code")] + [ScriptField] + public int HttpStatusCode { + get { + return 0; + } + } + + /// + /// A unique request id (x-request-id) + /// + [ScriptField] + public string Id { + get { + return String.Empty; + } + } + + [ScriptField] + public int StatusCode { + get; + set; + } + + public void AddTrailers(Dictionary headers) { + } + + public string GetHeader(string name) { + return null; + } + + /// + /// Short-hand for: + /// res.contentType = 'json'; + /// res.send({hello: 'world'}); + /// + /// Status code + /// content + public void Json(HttpStatusCode code, object body) { + } + + public void RemoveHeader(string name) { + } + + + public void Send(object message) { + } + + public void Send(int errorCode, RestifyError message) { + } + + public void SendDate() { + } + + /// + /// Sets the cache-control header. + /// + /// type defaults to _public_ + /// options currently only takes maxAge. + public void SetCache(string type, Dictionary options) { + } + + public void SetHeader(string name, string value) { + } + + /// + /// Sets the response statusCode. + /// + /// Status code + public void Status(HttpStatusCode code) { + } + + /// + /// You can use send() to wrap up all the usual writeHead(), write(), end() calls on the HTTP API of node. + /// When you call send(), restify figures out how to format the response (see content-negotiation, above), and does that. + /// + /// Status Code + /// body can be an Object, a Buffer, or an Error. + public void Status(HttpStatusCode code, object body) { + } + + public void WriteContinue() { + } + + public void WriteHead(HttpStatusCode statusCode) { + } + + public void WriteHead(HttpStatusCode statusCode, string reasonPhrase) { + } + + public void WriteHead(HttpStatusCode statusCode, Dictionary headers) { + } + + public void WriteHead(HttpStatusCode statusCode, string reasonPhrase, Dictionary headers) { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyRoute.cs b/src/Libraries/Node/Node.Restify/RestifyRoute.cs new file mode 100644 index 000000000..7b28b1e03 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyRoute.cs @@ -0,0 +1,17 @@ +// RestifyRoute.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyRoute { + + private RestifyRoute() { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyServer.cs b/src/Libraries/Node/Node.Restify/RestifyServer.cs new file mode 100644 index 000000000..f7043678f --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyServer.cs @@ -0,0 +1,315 @@ + // RestifyServer.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + public sealed class RestifyServer { + + private RestifyServer() { + } + + /// + /// list of content-types this server can respond with + /// + [ScriptField] + public String[] Acceptable { + get { + return null; + } + } + + /// + /// bunyan instance + /// + [ScriptField] + public RestifyLogger Log { + get { + return null; + } + } + + /// + /// name of the server + /// + [ScriptField] + public string Name { + get { + return null; + } + } + + /// + /// Once listen() is called, this will be filled in with where the server is running + /// + [ScriptField] + public string Url { + get { + return null; + } + } + + /// + /// default version to use in all routes + /// + [ScriptField] + public string Version { + get { + return null; + } + } + + /// + /// Emitted after a route has finished all the handlers you registered. + /// You can use this to write audit logs, etc. The route parameter will be the Route object that ran. + /// Note that when you are using the default 404/405/BadVersion handlers, this event will still be fired, + /// but route will be null. If you have registered your own listeners for those, this event will not be fired + /// unless you invoke the cb argument that is provided with them. + /// + [ScriptEvent("on", "removeListener")] + public event Action After { + add { + } + remove { + } + } + + /// + /// When a client request is sent for a URL that does exist, but you have not registered a route for that HTTP verb, + /// restify will emit this event. Note that restify checks for listeners on this event, and if there are none, + /// responds with a default 405 handler. It is expected that if you listen for this event, you respond to the client. + /// + [ScriptEvent("on", "removeListener")] + [ScriptName("MethodNotAllowed")] + public event Action MethodNotAllowed { + add { + } + remove { + } + } + + /// + /// When a client request is sent for a URL that does not exist, restify will emit this event. + /// Note that restify checks for listeners on this event, and if there are none, responds with a default 404 handler. + /// It is expected that if you listen for this event, you respond to the client. + /// + [ScriptEvent("on", "removeListener")] + [ScriptName("NotFound")] + public event Action NotFound { + add { + } + remove { + } + } + + /// + /// Emitted when some handler throws an uncaughtException somewhere in the chain. + /// The default behavior is to just call res.send(error), and let the built-ins in restify handle transforming, + /// but you can override to whatever you want here. + /// + [ScriptEvent("on", "removeListener")] + public event Action UncaughtException { + add { + } + remove { + } + } + + /// + /// When a client request is sent for a route that exist, but has a content-type mismatch, restify will emit this event. + /// Note that restify checks for listeners on this event, and if there are none, responds with a default 415 handler. + /// It is expected that if you listen for this event, you respond to the client. + /// + [ScriptEvent("on", "removeListener")] + [ScriptName("UnsupportedMediaType")] + public event Action UnsupportedMediaType { + add { + } + remove { + } + } + + /// + /// When a client request is sent for a route that exists, but does not match the version(s) on those routes, + /// restify will emit this event. Note that restify checks for listeners on this event, and if there are none, + /// responds with a default 400 handler. It is expected that if you listen for this event, you respond to the client. + /// + [ScriptEvent("on", "removeListener")] + [ScriptName("VersionNotAllowed")] + public event Action VersionNotAllowed { + add { + } + remove { + } + } + + public RestifyChainedHandler[] AcceptParser(string[] acceptable) { + return null; + } + + public Dictionary Address() { + return null; + } + + public RestifyChainedHandler[] AuditLogger(object options) { + return null; + } + + public RestifyChainedHandler[] AuthorizationParser() { + return null; + } + + public RestifyChainedHandler[] BodyParser() { + return null; + } + + public void Close(Action callback) { + } + + public RestifyChainedHandler[] ConditionalRequest() { + return null; + } + + public RestifyServer CreateServer() { + return null; + } + + public RestifyServer CreateServer(object options) { + return null; + } + + public RestifyServer CreateServer(RestifyServerOptions options) { + return null; + } + + public RestifyChainedHandler[] DateParser() { + return null; + } + + [ScriptName("del")] + public void Delete(string path, RestifyChainedHandler handler) { + } + + [ScriptName("del")] + public void Delete(string path, RestifyChainedHandler[] handlers) { + } + + [ScriptName("del")] + public void Delete(RegExp pathPattern, RestifyChainedHandler handler) { + } + + [ScriptName("del")] + public void Delete(RegExp pathPattern, RestifyChainedHandler[] handlers) { + } + + public void Get(string path, RestifyChainedHandler handler) { + } + + public void Get(string path, RestifyChainedHandler[] handlers) { + } + + public void Get(RestifyServerGetOptions options, RestifyChainedHandler handler) { + } + + public void Get(RestifyServerGetOptions options, RestifyChainedHandler[] handlers) { + } + + public void Get(RegExp pathPattern, RestifyChainedHandler handler) { + } + + public void Get(RegExp pathPattern, RestifyChainedHandler[] handlers) { + } + + public void Get(object options, RestifyChainedHandler handler) { + } + + public void Get(object options, RestifyChainedHandler[] handlers) { + } + + public RestifyChainedHandler[] GzipResponse() { + return null; + } + + public void Head(string path, RestifyChainedHandler handler) { + } + + public void Head(string path, RestifyChainedHandler[] handlers) { + } + + public void Head(RegExp pathPattern, RestifyChainedHandler handler) { + } + + public void Head(RegExp pathPattern, RestifyChainedHandler[] handlers) { + } + + public void Listen(int port, Action callback) { + } + + public void Listen(object handle, Action callback) { + } + + public void Listen(string path, Action callback) { + } + + public void Post(string path, RestifyChainedHandler handler) { + } + + public void Post(string path, RestifyChainedHandler[] handlers) { + } + + public void Post(RegExp pathPattern, RestifyChainedHandler handler) { + } + + public void Post(RegExp pathPattern, RestifyChainedHandler[] handlers) { + } + + public void Pre(RestifyChainedHandler handler) { + } + + public void Pre(RestifyChainedHandler[] handlers) { + } + + public RestifyChainedHandler[] QueryParser() { + return null; + } + + public RestifyChainedHandler[] RequestLogger() { + return null; + } + + public RestifyChainedHandler[] RequestLogger(object options) { + return null; + } + + public RestifyChainedHandler[] ServeStatic(object options) { + return null; + } + + public RestifyChainedHandler[] Throttle(RestifyThrottleOptions options) { + return null; + } + + public RestifyChainedHandler[] Throttle(Dictionary options) { + return null; + } + + /// + /// Restify runs handlers in the order they are registered on a server, + /// so if you want some common handlers to run before any of your routes, + /// issue calls to use() before defining routes. + /// + public void Use(RestifyChainedHandler handlers) { + } + + public void Use(RestifyChainedHandler[] handlers) { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs b/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs new file mode 100644 index 000000000..70f4edbf2 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyServerGetOptions.cs @@ -0,0 +1,26 @@ +// RestifyServerGetOptions.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + [ScriptName("Object")] + public sealed class RestifyServerGetOptions { + + public RestifyServerGetOptions() { + } + + public RestifyServerGetOptions(params object[] nameValuePairs) { + } + + public string Path; + + public string Version; + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs b/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs new file mode 100644 index 000000000..e25086916 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyServerOptions.cs @@ -0,0 +1,79 @@ +// RestifyServerOptions.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + [ScriptName("Object")] + public sealed class RestifyServerOptions { + + public RestifyServerOptions() { + } + + public RestifyServerOptions(params object[] nameValuePairs) { + } + + /// + /// If you want to create an HTTPS server, pass in the PEM-encoded certificate and key + /// + public string Certificate; + + /// + /// Custom response formatters for res.send() + /// + public object Formatters; + + /// + /// If you want to create an HTTPS server, pass in the PEM-encoded certificate and key + /// + public string Key; + + /// + /// You can optionally pass in a bunyan (https://github.com/trentm/node-bunyan) instance; not required + /// + public object Log; + + /// + /// By default, this will be set in the Server response header, default is restify + /// + public string Name; + + /// + /// Any options accepted by node-spdy (https://github.com/indutny/node-spdy) + /// + public string Spdy; + + /// + /// Allows you to apply formatting to the value of the header. + /// The duration is passed as an argument in number of milliseconds to execute. + /// + /// + /// + /// app = module.exports = restify.createServer({ + /// name: 'restify', + /// version: '1.0.0', + /// responseTimeHeader: 'X-Runtime', + /// responseTimeFormatter: function(durationInMilliseconds) { + /// return durationInMilliseconds / 1000; + /// } + /// }); + /// + public Func ResponseTimeFormatter; + + /// + /// By default, this will be X-Response-Time + /// + public string ResponseTimeHeader; + + /// + /// A default version to set for all routes + /// + public string Version; + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyStringClient.cs b/src/Libraries/Node/Node.Restify/RestifyStringClient.cs new file mode 100644 index 000000000..94c687b64 --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyStringClient.cs @@ -0,0 +1,57 @@ +// RestifyStringClient.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptImport] + [ScriptIgnoreNamespace] + public class RestifyStringClient { + + protected RestifyStringClient() { + } + + public void BasicAuth(string login, string password) { + } + + /// + /// del doesn't take content, since you know, it should't: + /// + public void Del(string path, object content, RestifyCallback callback) { + } + + /// + /// Performs an HTTP get; if no payload was returned, obj defaults to {} for you (so you don't get a bunch of null pointer errors). + /// + /// + /// + public void Get(string path, RestifyCallback callback) { + } + + /// + /// Just like get, but without obj: + /// + /// + /// + public void Head(string path, RestifyCallback callback) { + } + + /// + /// Takes a complete object to serialize and send to the server. + /// + /// + /// + /// + public void Post(string path, object content, RestifyCallback callback) { + } + + /// + /// Just like post: + /// + public void Put(string path, object content, RestifyCallback callback) { + } + } +} diff --git a/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs b/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs new file mode 100644 index 000000000..5d312cb7c --- /dev/null +++ b/src/Libraries/Node/Node.Restify/RestifyThrottleOptions.cs @@ -0,0 +1,91 @@ +// RestifyThrottleOptions.cs +// Script#/Libraries/Node/Restify +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.Restify { + + [ScriptIgnoreNamespace] + [ScriptImport] + [ScriptName("Object")] + public sealed class RestifyThrottleOptions { + + public RestifyThrottleOptions() { + } + + public RestifyThrottleOptions(params object[] nameValuePairs) { + } + + /// + /// If available, the amount of requests to burst to + /// + [ScriptField] + public int Burst { + set { + } + } + + /// + /// Do throttling on a /32 (source IP) + /// + [ScriptField] + public bool Ip { + set { + } + } + + /// + /// If using the built-in storage table, the maximum distinct throttling keys to allow at a time + /// + [ScriptField] + public int MaxKeys { + set { + } + } + + /// + /// Per "key" overrides + /// + [ScriptField] + public object Overrides { + set { + } + } + + [ScriptField] + public int Rate { + set { + } + } + + /// + /// Storage engine; must support put/get + /// + [ScriptField] + public object TokensTable { + set { + } + } + + /// + /// Do throttling on req.username + /// + [ScriptField] + public bool Username { + set { + } + } + + /// + /// Do throttling on a /32 (X-Forwarded-For) + /// + [ScriptField] + public bool Xff { + set { + } + } + } +} diff --git a/src/ScriptSharp.sln b/src/ScriptSharp.sln index 04fe50e77..7717665a7 100644 --- a/src/ScriptSharp.sln +++ b/src/ScriptSharp.sln @@ -73,6 +73,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Node.Neo4j", "Libraries\Nod EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deployment", "Tools\Deployment\Deployment.csproj", "{9D59077D-1A05-4D6C-A1A4-FB748D200578}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Node.Restify", "Libraries\Node\Node.Restify\Node.Restify.csproj", "{1ECC689C-2542-4EE8-8A86-7627E63F44F8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET @@ -336,6 +338,18 @@ Global {9D59077D-1A05-4D6C-A1A4-FB748D200578}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {9D59077D-1A05-4D6C-A1A4-FB748D200578}.Release|Mixed Platforms.Build.0 = Release|Any CPU {9D59077D-1A05-4D6C-A1A4-FB748D200578}.Release|x86.ActiveCfg = Release|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Debug|.NET.ActiveCfg = Debug|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Debug|x86.ActiveCfg = Debug|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|.NET.ActiveCfg = Release|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|Any CPU.Build.0 = Release|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -353,6 +367,7 @@ Global {4A9F7CE9-5B45-4B28-AD01-05528709B6E4} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} {4A9F7CE9-5B45-4B28-AD01-05529709B6E4} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} {232445FF-22AA-46F7-BA12-4590C670F2B1} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} + {1ECC689C-2542-4EE8-8A86-7627E63F44F8} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} {1772A38C-7204-42DC-B81D-6C74D17A4F66} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} {BE1E0A21-F6C0-4698-B405-66FC2BB289F4} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} {36D4B098-A21C-4725-ACD3-400922885F38} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} From 4c8412e23d272ccc5bd10917474a5ae996b17808 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Thu, 18 Apr 2013 04:43:37 -0700 Subject: [PATCH 07/35] Undo changes to HttpServerRequest/Response. --- src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs | 4 ++-- src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs b/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs index ac8358a3a..22ead043e 100644 --- a/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs +++ b/src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs @@ -11,9 +11,9 @@ namespace NodeApi.Network { [ScriptImport] [ScriptIgnoreNamespace] - public class HttpServerRequest : ReadableStream, IEventEmitter { + public sealed class HttpServerRequest : ReadableStream, IEventEmitter { - protected HttpServerRequest() { + private HttpServerRequest() { } [ScriptField] diff --git a/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs b/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs index d9422dcf1..f8d9355d7 100644 --- a/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs +++ b/src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs @@ -12,9 +12,9 @@ namespace NodeApi.Network { [ScriptImport] [ScriptIgnoreNamespace] - public class HttpServerResponse : WritableStream, IEventEmitter { + public sealed class HttpServerResponse : WritableStream, IEventEmitter { - protected HttpServerResponse() { + private HttpServerResponse() { } [ScriptField] From fe165de0c3ce64422cb4fe6563e114ac0f58893f Mon Sep 17 00:00:00 2001 From: nikhilk Date: Thu, 18 Apr 2013 04:49:07 -0700 Subject: [PATCH 08/35] Import library for azure node module (storage and role environment related APIs) --- src/Libraries/Node/Node.Azure/Azure.cs | 61 ++++++++ .../Node/Node.Azure/Node.Azure.csproj | 88 +++++++++++ .../Node.Azure/Properties/AssemblyInfo.cs | 12 ++ .../Node/Node.Azure/Properties/ScriptInfo.txt | 10 ++ src/Libraries/Node/Node.Azure/Runtime/Role.cs | 18 +++ .../Node.Azure/Runtime/RoleEnvironment.cs | 63 ++++++++ .../Node/Node.Azure/Runtime/RoleEvent.cs | 32 ++++ .../Node/Node.Azure/Runtime/RoleEventType.cs | 20 +++ .../Node/Node.Azure/Runtime/RoleInstance.cs | 18 +++ .../Node/Node.Azure/Runtime/RoleStatus.cs | 20 +++ .../Node/Node.Azure/Storage/CloudBlob.cs | 26 ++++ .../Node.Azure/Storage/CloudBlobContainer.cs | 25 +++ .../CloudBlobContainerListContinuation.cs | 32 ++++ .../Node/Node.Azure/Storage/CloudBlobLease.cs | 25 +++ .../Storage/CloudBlobListContinuation.cs | 32 ++++ .../Node.Azure/Storage/CloudBlobService.cs | 144 ++++++++++++++++++ .../Node/Node.Azure/Storage/CloudBlockBlob.cs | 18 +++ .../Node/Node.Azure/Storage/CloudQueue.cs | 26 ++++ .../Storage/CloudQueueListContinuation.cs | 32 ++++ .../Node.Azure/Storage/CloudQueueMessage.cs | 42 +++++ .../Node.Azure/Storage/CloudQueueService.cs | 81 ++++++++++ .../Node/Node.Azure/Storage/CloudTable.cs | 26 ++++ .../Node.Azure/Storage/CloudTableEntity.cs | 60 ++++++++ .../Storage/CloudTableListContinuation.cs | 32 ++++ .../Node.Azure/Storage/CloudTableQuery.cs | 59 +++++++ .../Storage/CloudTableQueryContinuation.cs | 39 +++++ .../Node.Azure/Storage/CloudTableService.cs | 129 ++++++++++++++++ src/ScriptSharp.sln | 15 ++ 28 files changed, 1185 insertions(+) create mode 100644 src/Libraries/Node/Node.Azure/Azure.cs create mode 100644 src/Libraries/Node/Node.Azure/Node.Azure.csproj create mode 100644 src/Libraries/Node/Node.Azure/Properties/AssemblyInfo.cs create mode 100644 src/Libraries/Node/Node.Azure/Properties/ScriptInfo.txt create mode 100644 src/Libraries/Node/Node.Azure/Runtime/Role.cs create mode 100644 src/Libraries/Node/Node.Azure/Runtime/RoleEnvironment.cs create mode 100644 src/Libraries/Node/Node.Azure/Runtime/RoleEvent.cs create mode 100644 src/Libraries/Node/Node.Azure/Runtime/RoleEventType.cs create mode 100644 src/Libraries/Node/Node.Azure/Runtime/RoleInstance.cs create mode 100644 src/Libraries/Node/Node.Azure/Runtime/RoleStatus.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudBlob.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudBlobContainer.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudBlobContainerListContinuation.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudBlobLease.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudBlobListContinuation.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudBlobService.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudBlockBlob.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudQueue.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudQueueListContinuation.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudQueueMessage.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudQueueService.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudTable.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudTableEntity.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudTableListContinuation.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudTableQuery.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudTableQueryContinuation.cs create mode 100644 src/Libraries/Node/Node.Azure/Storage/CloudTableService.cs diff --git a/src/Libraries/Node/Node.Azure/Azure.cs b/src/Libraries/Node/Node.Azure/Azure.cs new file mode 100644 index 000000000..c6f7baee5 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Azure.cs @@ -0,0 +1,61 @@ +// Azure.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; +using NodeApi.WindowsAzure.Runtime; +using NodeApi.WindowsAzure.Storage; + +namespace NodeApi.WindowsAzure { + + /// + /// The root Azure services API. + /// + [ScriptImport] + [ScriptIgnoreNamespace] + [ScriptName("azure")] + public static class Azure { + + [ScriptField] + [ScriptName(PreserveCase = true)] + public static RoleEnvironment RoleEnvironment { + get { + return null; + } + } + + [ScriptField] + [ScriptName(PreserveCase = true)] + public static CloudTableQuery TableQuery { + get { + return null; + } + } + + public static CloudBlobService CreateBlobService() { + return null; + } + + public static CloudBlobService CreateBlobService(string storageAccount, string accessKey) { + return null; + } + + public static CloudQueueService CreateQueueService() { + return null; + } + + public static CloudQueueService CreateQueueService(string storageAccount, string accessKey) { + return null; + } + + public static CloudTableService CreateTableService() { + return null; + } + + public static CloudTableService CreateTableService(string storageAccount, string accessKey) { + return null; + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Node.Azure.csproj b/src/Libraries/Node/Node.Azure/Node.Azure.csproj new file mode 100644 index 000000000..a9296cadd --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Node.Azure.csproj @@ -0,0 +1,88 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4} + Library + Properties + NodeApi.WindowsAzure + Script.Node.Azure + True + true + ..\..\..\ScriptSharp.snk + v2.0 + 512 + + + + ..\..\..\..\bin\Debug\ + false + DEBUG + prompt + 4 + ..\..\..\..\bin\Debug\Script.Node.Azure.xml + 1591, 0661, 0660, 1684 + true + + + none + false + true + ..\..\..\..\bin\Release\ + TRACE + prompt + 4 + ..\..\..\..\bin\Release\Script.Node.Azure.xml + 1591, 0661, 0660, 1684 + true + + + + + + + + + + + + Properties\ScriptSharp.cs + + + + + + + + + + + + + + + + + + + + + + + {36D4B098-A21C-4725-ACD3-400922885F38} + CoreLib + + + {4a9f7ce9-5a45-4b28-ad01-05528709b6e4} + Node.Core + + + + + + + + \ No newline at end of file diff --git a/src/Libraries/Node/Node.Azure/Properties/AssemblyInfo.cs b/src/Libraries/Node/Node.Azure/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..653672513 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Properties/AssemblyInfo.cs @@ -0,0 +1,12 @@ +// AssemblyInfo.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Script.Node.Azure")] +[assembly: AssemblyDescription("Script# NodeJS Azure Module API")] +[assembly: ScriptAssembly("azure")] diff --git a/src/Libraries/Node/Node.Azure/Properties/ScriptInfo.txt b/src/Libraries/Node/Node.Azure/Properties/ScriptInfo.txt new file mode 100644 index 000000000..a0e3513f9 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Properties/ScriptInfo.txt @@ -0,0 +1,10 @@ +Node Azure Module +=============================================================================== + +This assembly provides access to Azure Cloud APIs for NodeJS applications. +This is only meant for use at development time, so you can reference and compile +your c# code against Azure APIs. + +More information is on http://www.windowsazure.com/en-us/develop/nodejs/. + +------------------------------------------------------------------------------- diff --git a/src/Libraries/Node/Node.Azure/Runtime/Role.cs b/src/Libraries/Node/Node.Azure/Runtime/Role.cs new file mode 100644 index 000000000..2841fc2c5 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Runtime/Role.cs @@ -0,0 +1,18 @@ +// Role.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Runtime { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class Role { + + private Role() { + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Runtime/RoleEnvironment.cs b/src/Libraries/Node/Node.Azure/Runtime/RoleEnvironment.cs new file mode 100644 index 000000000..87e1320c8 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Runtime/RoleEnvironment.cs @@ -0,0 +1,63 @@ +// RoleEnvironment.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Runtime { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class RoleEnvironment { + + private RoleEnvironment() { + } + + [ScriptEvent("on", "removeListener")] + public event Action Changed { + add { + } + remove { + } + } + + [ScriptEvent("on", "removeListener")] + public event Action Changing { + add { + } + remove { + } + } + + public void ClearStatus(AsyncCallback callback) { + } + + public void GetConfigurationSettings(AsyncResultCallback> callback) { + } + + public void GetCurrentRoleInstance(AsyncResultCallback callback) { + } + + [ScriptName("getDeploymentId")] + public void GetDeploymentID(AsyncResultCallback callback) { + } + + public void GetRoles(AsyncResultCallback callback) { + } + + public void IsAvailable(AsyncResultCallback callback) { + } + + public void IsEmulated(AsyncResultCallback callback) { + } + + public void RequestRecycle(AsyncCallback callback) { + } + + public void SetStatus(RoleStatus status, Date expirationDate, AsyncCallback callback) { + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Runtime/RoleEvent.cs b/src/Libraries/Node/Node.Azure/Runtime/RoleEvent.cs new file mode 100644 index 000000000..ac2834823 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Runtime/RoleEvent.cs @@ -0,0 +1,32 @@ +// RoleEvent.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Runtime { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class RoleEvent { + + private RoleEvent() { + } + + [ScriptField] + public string Name { + get { + return null; + } + } + + [ScriptField] + public RoleEventType Type { + get { + return RoleEventType.ConfigurationSettingChange; + } + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Runtime/RoleEventType.cs b/src/Libraries/Node/Node.Azure/Runtime/RoleEventType.cs new file mode 100644 index 000000000..e7403960e --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Runtime/RoleEventType.cs @@ -0,0 +1,20 @@ +// RoleEventType.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Runtime { + + [ScriptImport] + [ScriptIgnoreNamespace] + [ScriptConstants(UseNames = true)] + public enum RoleEventType { + + TopologyChange = 0, + + ConfigurationSettingChange = 1 + } +} diff --git a/src/Libraries/Node/Node.Azure/Runtime/RoleInstance.cs b/src/Libraries/Node/Node.Azure/Runtime/RoleInstance.cs new file mode 100644 index 000000000..272d094e9 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Runtime/RoleInstance.cs @@ -0,0 +1,18 @@ +// RoleInstance.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Runtime { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class RoleInstance { + + private RoleInstance() { + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Runtime/RoleStatus.cs b/src/Libraries/Node/Node.Azure/Runtime/RoleStatus.cs new file mode 100644 index 000000000..47f37368d --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Runtime/RoleStatus.cs @@ -0,0 +1,20 @@ +// RoleStatus.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Runtime { + + [ScriptImport] + [ScriptIgnoreNamespace] + [ScriptConstants(UseNames = true)] + public enum RoleStatus { + + Busy = 0, + + Ready = 1 + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudBlob.cs b/src/Libraries/Node/Node.Azure/Storage/CloudBlob.cs new file mode 100644 index 000000000..35caef469 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudBlob.cs @@ -0,0 +1,26 @@ +// CloudBlob.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public abstract class CloudBlob { + + internal CloudBlob() { + } + + [ScriptField] + [ScriptName("blob")] + public string Name { + get { + return null; + } + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudBlobContainer.cs b/src/Libraries/Node/Node.Azure/Storage/CloudBlobContainer.cs new file mode 100644 index 000000000..374a1cd31 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudBlobContainer.cs @@ -0,0 +1,25 @@ +// CloudBlobContainer.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudBlobContainer { + + private CloudBlobContainer() { + } + + [ScriptField] + public string Name { + get { + return null; + } + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudBlobContainerListContinuation.cs b/src/Libraries/Node/Node.Azure/Storage/CloudBlobContainerListContinuation.cs new file mode 100644 index 000000000..a8d70f5dc --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudBlobContainerListContinuation.cs @@ -0,0 +1,32 @@ +// CloudBlobContainerListContinuation.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudBlobContainerListContinuation { + + private CloudBlobContainerListContinuation() { + } + + [ScriptField] + public string NextMarker { + get { + return null; + } + } + + public void GetNextPage(AsyncResultCallback callback) { + } + + public bool HasNextPage() { + return false; + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudBlobLease.cs b/src/Libraries/Node/Node.Azure/Storage/CloudBlobLease.cs new file mode 100644 index 000000000..725507961 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudBlobLease.cs @@ -0,0 +1,25 @@ +// CloudBlobLease.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public abstract class CloudBlobLease { + + internal CloudBlobLease() { + } + + [ScriptField] + public string ID { + get { + return null; + } + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudBlobListContinuation.cs b/src/Libraries/Node/Node.Azure/Storage/CloudBlobListContinuation.cs new file mode 100644 index 000000000..96b11c367 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudBlobListContinuation.cs @@ -0,0 +1,32 @@ +// CloudBlobListContinuation.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudBlobListContinuation { + + private CloudBlobListContinuation() { + } + + [ScriptField] + public string NextMarker { + get { + return null; + } + } + + public void GetNextPage(AsyncResultCallback callback) { + } + + public bool HasNextPage() { + return false; + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudBlobService.cs b/src/Libraries/Node/Node.Azure/Storage/CloudBlobService.cs new file mode 100644 index 000000000..bfc335eee --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudBlobService.cs @@ -0,0 +1,144 @@ +// CloudBlobService.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; +using NodeApi.IO; + +namespace NodeApi.WindowsAzure.Storage { + + // TODO: ACLs + // TODO: Page blobs + // TODO: Shared access signatures + // TODO: Metadata/properties + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudBlobService { + + private CloudBlobService() { + } + + public void AcquireLease(string containerName, string blobName, AsyncResultCallback callback) { + } + + public void AcquireLease(string containerName, string blobName, object options, AsyncResultCallback callback) { + } + + public void BreakLease(string containerName, string blobName, string leaseID, AsyncResultCallback callback) { + } + + public void BreakLease(string containerName, string blobName, string leaseID, object options, AsyncResultCallback callback) { + } + + public void CopyBlob(string sourceContainerName, string sourceBlobName, string targetContainerName, string targetBlobName, AsyncResultCallback callback) { + } + + public void CopyBlob(string sourceContainerName, string sourceBlobName, string targetContainerName, string targetBlobName, object options, AsyncResultCallback callback) { + } + + public void CreateBlobSnapshot(string containerName, string blobName, AsyncResultCallback callback) { + } + + public void CreateBlobSnapshot(string containerName, string blobName, object options, AsyncResultCallback callback) { + } + + public void CreateBlockBlobFromFile(string containerName, string blobName, string fileName, AsyncResultCallback callback) { + } + + public void CreateBlockBlobFromFile(string containerName, string blobName, string fileName, object options, AsyncResultCallback callback) { + } + + public void CreateBlockBlobFromStream(string containerName, string blobName, ReadableStream stream, AsyncResultCallback callback) { + } + + public void CreateBlockBlobFromStream(string containerName, string blobName, ReadableStream stream, object options, AsyncResultCallback callback) { + } + + public void CreateBlockBlobFromText(string containerName, string blobName, string text, AsyncResultCallback callback) { + } + + public void CreateBlockBlobFromText(string containerName, string blobName, string text, object options, AsyncResultCallback callback) { + } + + public void CreateContainer(string containerName, AsyncCallback callback) { + } + + public void CreateContainer(string containerName, object options, AsyncCallback callback) { + } + + public void CreateContainerIfNotExists(string containerName, AsyncCallback callback) { + } + + public void CreateContainerIfNotExists(string containerName, object options, AsyncCallback callback) { + } + + public void DeleteBlob(string containerName, string blobName, AsyncCallback callback) { + } + + public void DeleteBlob(string containerName, string blobName, object options, AsyncCallback callback) { + } + + public void DeleteContainer(string containerName, AsyncCallback callback) { + } + + public void DeleteContainer(string containerName, object options, AsyncCallback callback) { + } + + public void GetBlobToFile(string containerName, string blobName, string fileName, AsyncResultCallback callback) { + } + + public void GetBlobToFile(string containerName, string blobName, string fileName, object options, AsyncResultCallback callback) { + } + + public void GetBlobToStream(string containerName, string blobName, WritableStream stream, AsyncResultCallback callback) { + } + + public void GetBlobToStream(string containerName, string blobName, WritableStream stream, object options, AsyncResultCallback callback) { + } + + public void GetBlobToText(string containerName, string blobName, string text, AsyncResultCallback callback) { + } + + public void GetBlobToText(string containerName, string blobName, string text, object options, AsyncResultCallback callback) { + } + + public void ListBlobs(string containerName, AsyncResultCallback callback) { + } + + public void ListBlobs(string containerName, AsyncResultCallback callback) { + } + + public void ListBlobs(string containerName, object options, AsyncResultCallback callback) { + } + + public void ListBlobs(string containerName, object options, AsyncResultCallback callback) { + } + + public void ListContainers(AsyncResultCallback callback) { + } + + public void ListContainers(AsyncResultCallback callback) { + } + + public void ListContainers(object options, AsyncResultCallback callback) { + } + + public void ListContainers(object options, AsyncResultCallback callback) { + } + + public void ReleaseLease(string containerName, string blobName, string leaseID, AsyncResultCallback callback) { + } + + public void ReleaseLease(string containerName, string blobName, string leaseID, object options, AsyncResultCallback callback) { + } + + public void RenewLease(string containerName, string blobName, string leaseID, AsyncResultCallback callback) { + } + + public void RenewLease(string containerName, string blobName, string leaseID, object options, AsyncResultCallback callback) { + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudBlockBlob.cs b/src/Libraries/Node/Node.Azure/Storage/CloudBlockBlob.cs new file mode 100644 index 000000000..b7457ae05 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudBlockBlob.cs @@ -0,0 +1,18 @@ +// CloudBlockBlob.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudBlockBlob : CloudBlob { + + private CloudBlockBlob() { + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudQueue.cs b/src/Libraries/Node/Node.Azure/Storage/CloudQueue.cs new file mode 100644 index 000000000..949eede12 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudQueue.cs @@ -0,0 +1,26 @@ +// CloudQueue.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudQueue { + + private CloudQueue() { + } + + [ScriptField] + [ScriptName(PreserveCase = true)] + public string Name { + get { + return null; + } + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudQueueListContinuation.cs b/src/Libraries/Node/Node.Azure/Storage/CloudQueueListContinuation.cs new file mode 100644 index 000000000..bc3072342 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudQueueListContinuation.cs @@ -0,0 +1,32 @@ +// CloudQueueListContinuation.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudQueueListContinuation { + + private CloudQueueListContinuation() { + } + + [ScriptField] + public string NextMarker { + get { + return null; + } + } + + public void GetNextPage(AsyncResultCallback callback) { + } + + public bool HasNextPage() { + return false; + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudQueueMessage.cs b/src/Libraries/Node/Node.Azure/Storage/CloudQueueMessage.cs new file mode 100644 index 000000000..42d075201 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudQueueMessage.cs @@ -0,0 +1,42 @@ +// CloudQueueMessage.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudQueueMessage { + + private CloudQueueMessage() { + } + + [ScriptField] + [ScriptName("messageid")] + public string MessageID { + get { + return null; + } + } + + [ScriptField] + [ScriptName("messagetext")] + public string MessageText { + get { + return null; + } + } + + [ScriptField] + [ScriptName("popreceipt")] + public string PopReceipt { + get { + return null; + } + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudQueueService.cs b/src/Libraries/Node/Node.Azure/Storage/CloudQueueService.cs new file mode 100644 index 000000000..7badc2ca8 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudQueueService.cs @@ -0,0 +1,81 @@ +// CloudQueueService.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + // TODO: Properties, metadata related APIs + // TODO: Does azure sdk support shared access signature functionality for tables? + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudQueueService { + + private CloudQueueService() { + } + + public void ClearMessages(string queueName, AsyncCallback callback) { + } + + public void ClearMessages(string queueName, object options, AsyncCallback callback) { + } + + public void CreateMessage(string queueName, string message, AsyncCallback callback) { + } + + public void CreateMessage(string queueName, string message, object options, AsyncCallback callback) { + } + + public void CreateQueue(string queueName, AsyncCallback callback) { + } + + public void CreateQueue(string queueName, object options, AsyncCallback callback) { + } + + public void CreateQueueIfNotExists(string queueName, AsyncCallback callback) { + } + + public void CreateQueueIfNotExists(string queueName, object options, AsyncCallback callback) { + } + + public void DeleteMessage(string queueName, string messageID, string popReceipt, AsyncCallback callback) { + } + + public void DeleteMessage(string queueName, string messageID, string popReceipt, object options, AsyncCallback callback) { + } + + public void DeleteQueue(string queueName, AsyncCallback callback) { + } + + public void DeleteQueue(string queueName, object options, AsyncCallback callback) { + } + + public void GetMessages(string queueName, AsyncResultCallback callback) { + } + + public void GetMessages(string queueName, object options, AsyncResultCallback callback) { + } + + public void ListQueues(AsyncResultCallback callback) { + } + + public void ListQueues(object options, AsyncResultCallback callback) { + } + + public void PeekMessages(string queueName, AsyncResultCallback callback) { + } + + public void PeekMessages(string queueName, object options, AsyncResultCallback callback) { + } + + public void UpdateMessage(string queueName, string messageID, string popReceipt, int visibilityTimeout, AsyncResultCallback callback) { + } + + public void UpdateMessage(string queueName, string messageID, string popReceipt, int visibilityTimeout, object options, AsyncResultCallback callback) { + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudTable.cs b/src/Libraries/Node/Node.Azure/Storage/CloudTable.cs new file mode 100644 index 000000000..0c83c1f85 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudTable.cs @@ -0,0 +1,26 @@ +// CloudTable.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudTable { + + private CloudTable() { + } + + [ScriptField] + [ScriptName(PreserveCase = true)] + public string TableName { + get { + return null; + } + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudTableEntity.cs b/src/Libraries/Node/Node.Azure/Storage/CloudTableEntity.cs new file mode 100644 index 000000000..536c61764 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudTableEntity.cs @@ -0,0 +1,60 @@ +// CloudTableEntity.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + [ScriptName("Object")] + public sealed class CloudTableEntity { + + public CloudTableEntity() { + } + + public CloudTableEntity(params object[] nameValuePairs) { + } + + [ScriptField] + [ScriptName(PreserveCase = true)] + public string PartitionKey { + get { + return null; + } + set { + } + } + + [ScriptField] + [ScriptName(PreserveCase = true)] + public string RowKey { + get { + return null; + } + set { + } + } + + [ScriptField] + public object this[string key] { + get { + return null; + } + set { + } + } + + public static implicit operator Dictionary(CloudTableEntity entity) { + return null; + } + + public static implicit operator CloudTableEntity(Dictionary data) { + return null; + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudTableListContinuation.cs b/src/Libraries/Node/Node.Azure/Storage/CloudTableListContinuation.cs new file mode 100644 index 000000000..2c529df3a --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudTableListContinuation.cs @@ -0,0 +1,32 @@ +// CloudTableListContinuation.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudTableListContinuation { + + private CloudTableListContinuation() { + } + + [ScriptField] + public string NextTableName { + get { + return null; + } + } + + public void GetNextPage(AsyncResultCallback callback) { + } + + public bool HasNextPage() { + return false; + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudTableQuery.cs b/src/Libraries/Node/Node.Azure/Storage/CloudTableQuery.cs new file mode 100644 index 000000000..30fec793c --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudTableQuery.cs @@ -0,0 +1,59 @@ +// CloudTableQuery.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudTableQuery { + + private CloudTableQuery() { + } + + public CloudTableQuery And(string filter, object[] values) { + return null; + } + + public CloudTableQuery From(string tableName) { + return null; + } + + public CloudTableQuery Or(string filter, object[] values) { + return null; + } + + public CloudTableQuery Select() { + return null; + } + + public CloudTableQuery Select(string[] fields) { + return null; + } + + public CloudTableQuery Top(int count) { + return null; + } + + public CloudTableQuery Where(string filter, string value) { + return null; + } + + public CloudTableQuery Where(string filter, object[] values) { + return null; + } + + public CloudTableQuery WhereKeys(string partitionKey, string rowKey) { + return null; + } + + public CloudTableQuery WhereNextKeys(string partitionKey, string rowKey) { + return null; + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudTableQueryContinuation.cs b/src/Libraries/Node/Node.Azure/Storage/CloudTableQueryContinuation.cs new file mode 100644 index 000000000..fef7691e8 --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudTableQueryContinuation.cs @@ -0,0 +1,39 @@ +// CloudTableQueryContinuation.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudTableQueryContinuation { + + private CloudTableQueryContinuation() { + } + + [ScriptField] + public string NextPartitionKey { + get { + return null; + } + } + + [ScriptField] + public string NextRowKey { + get { + return null; + } + } + + public void GetNextPage(AsyncResultCallback callback) { + } + + public bool HasNextPage() { + return false; + } + } +} diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudTableService.cs b/src/Libraries/Node/Node.Azure/Storage/CloudTableService.cs new file mode 100644 index 000000000..db98e00af --- /dev/null +++ b/src/Libraries/Node/Node.Azure/Storage/CloudTableService.cs @@ -0,0 +1,129 @@ +// CloudTableService.cs +// Script#/Libraries/Node/Azure +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Runtime.CompilerServices; + +namespace NodeApi.WindowsAzure.Storage { + + // TODO: Properties, metadata related APIs + // TODO: Does azure sdk support shared access signature functionality for tables? + + [ScriptImport] + [ScriptIgnoreNamespace] + public sealed class CloudTableService { + + private CloudTableService() { + } + + public void BeginBatch() { + } + + public void CommitBatch(AsyncCallback callback) { + } + + public void CommitBatch(object options, AsyncCallback callback) { + } + + public void CreateTable(string tableName, AsyncCallback callback) { + } + + public void CreateTable(string tableName, object options, AsyncCallback callback) { + } + + public void CreateTableIfNotExists(string tableName, AsyncCallback callback) { + } + + public void CreateTableIfNotExists(string tableName, object options, AsyncCallback callback) { + } + + public void DeleteEntity(string tableName, CloudTableEntity entity, AsyncCallback callback) { + } + + public void DeleteEntity(string tableName, CloudTableEntity entity, object options, AsyncCallback callback) { + } + + public void DeleteTable(string tableName, AsyncCallback callback) { + } + + public void DeleteTable(string tableName, object options, AsyncCallback callback) { + } + + public bool HasOperations() { + return false; + } + + public void InsertEntity(string tableName, CloudTableEntity entity, AsyncCallback callback) { + } + + public void InsertEntity(string tableName, CloudTableEntity entity, object options, AsyncCallback callback) { + } + + public void InsertOrMergeEntity(string tableName, CloudTableEntity entity, AsyncCallback callback) { + } + + public void InsertOrMergeEntity(string tableName, CloudTableEntity entity, object options, AsyncCallback callback) { + } + + public void InsertOrReplaceEntity(string tableName, CloudTableEntity entity, AsyncCallback callback) { + } + + public void InsertOrReplaceEntity(string tableName, CloudTableEntity entity, object options, AsyncCallback callback) { + } + + public bool IsInBatch() { + return false; + } + + [ScriptName("queryTables")] + public void ListTables(AsyncResultCallback callback) { + } + + [ScriptName("queryTables")] + public void ListTables(AsyncResultCallback callback) { + } + + [ScriptName("queryTables")] + public void ListTables(object options, AsyncResultCallback callback) { + } + + [ScriptName("queryTables")] + public void ListTables(object options, AsyncResultCallback callback) { + } + + public void MergeEntity(string tableName, CloudTableEntity entity, AsyncCallback callback) { + } + + public void MergeEntity(string tableName, CloudTableEntity entity, object options, AsyncCallback callback) { + } + + public void QueryEntities(CloudTableQuery query, AsyncResultCallback callback) { + } + + public void QueryEntities(CloudTableQuery query, object options, AsyncResultCallback callback) { + } + + public void QueryEntities(CloudTableQuery query, AsyncResultCallback callback) { + } + + public void QueryEntities(CloudTableQuery query, object options, AsyncResultCallback callback) { + } + + public void QueryEntity(string tableName, string partitionKey, string rowKey, AsyncResultCallback callback) { + } + + public void QueryEntity(string tableName, string partitionKey, string rowKey, object options, AsyncResultCallback callback) { + } + + public void Rollback() { + } + + public void UpdateEntity(string tableName, CloudTableEntity entity, AsyncCallback callback) { + } + + public void UpdateEntity(string tableName, CloudTableEntity entity, object options, AsyncCallback callback) { + } + } +} diff --git a/src/ScriptSharp.sln b/src/ScriptSharp.sln index 7717665a7..fef45edef 100644 --- a/src/ScriptSharp.sln +++ b/src/ScriptSharp.sln @@ -75,6 +75,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deployment", "Tools\Deploym EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Node.Restify", "Libraries\Node\Node.Restify\Node.Restify.csproj", "{1ECC689C-2542-4EE8-8A86-7627E63F44F8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Node.Azure", "Libraries\Node\Node.Azure\Node.Azure.csproj", "{4A9F7CE9-5B55-4B28-AD01-05528709B6E4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET @@ -350,6 +352,18 @@ Global {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|Mixed Platforms.Build.0 = Release|Any CPU {1ECC689C-2542-4EE8-8A86-7627E63F44F8}.Release|x86.ActiveCfg = Release|Any CPU + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4}.Debug|.NET.ActiveCfg = Debug|Any CPU + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4}.Debug|x86.ActiveCfg = Debug|Any CPU + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4}.Release|.NET.ActiveCfg = Release|Any CPU + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4}.Release|Any CPU.Build.0 = Release|Any CPU + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -368,6 +382,7 @@ Global {4A9F7CE9-5B45-4B28-AD01-05529709B6E4} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} {232445FF-22AA-46F7-BA12-4590C670F2B1} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} {1ECC689C-2542-4EE8-8A86-7627E63F44F8} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} + {4A9F7CE9-5B55-4B28-AD01-05528709B6E4} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} {1772A38C-7204-42DC-B81D-6C74D17A4F66} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} {BE1E0A21-F6C0-4698-B405-66FC2BB289F4} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} {36D4B098-A21C-4725-ACD3-400922885F38} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} From d88742a134289aff86f3712b21cc3c1c9976f5dc Mon Sep 17 00:00:00 2001 From: nikhilk Date: Thu, 18 Apr 2013 04:58:47 -0700 Subject: [PATCH 09/35] Fix import library description and build --- src/Libraries/Node/Node.Restify/Node.Restify.csproj | 3 ++- src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Libraries/Node/Node.Restify/Node.Restify.csproj b/src/Libraries/Node/Node.Restify/Node.Restify.csproj index 6c800093b..fbfbea917 100644 --- a/src/Libraries/Node/Node.Restify/Node.Restify.csproj +++ b/src/Libraries/Node/Node.Restify/Node.Restify.csproj @@ -43,8 +43,9 @@ Properties\ScriptSharp.cs - + + diff --git a/src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt b/src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt index 018207ec7..afd792f38 100644 --- a/src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt +++ b/src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt @@ -1,4 +1,4 @@ -Node Express Module +Node Restify Module =============================================================================== This assembly provides access to Restify Module APIs for NodeJS applications. From fc264cc3983543a4168de1af68df410ce863cbe6 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Thu, 18 Apr 2013 05:00:07 -0700 Subject: [PATCH 10/35] Nuget packages for restify ans azure node import libraries --- src/ZipX/Packages/Lib.Node.Azure.nuspec | 29 +++++++++++++++++++++++ src/ZipX/Packages/Lib.Node.Restify.nuspec | 29 +++++++++++++++++++++++ src/ZipX/ZipX.csproj | 4 ++++ 3 files changed, 62 insertions(+) create mode 100644 src/ZipX/Packages/Lib.Node.Azure.nuspec create mode 100644 src/ZipX/Packages/Lib.Node.Restify.nuspec diff --git a/src/ZipX/Packages/Lib.Node.Azure.nuspec b/src/ZipX/Packages/Lib.Node.Azure.nuspec new file mode 100644 index 000000000..ee7cee95b --- /dev/null +++ b/src/ZipX/Packages/Lib.Node.Azure.nuspec @@ -0,0 +1,29 @@ + + + + ScriptSharp.Lib.Node.Azure + 0.8 + Script# Azure for Node.js Reference Assembly + Nikhil Kothari + Copyright (c) 2012, Nikhil Kothari + http://scriptsharp.com + http://scriptsharp.com/nuget/PackageLib.png + http://scriptsharp.com/nuget/License.txt + Allows you to reference and use Azure APIs in node.js Script# projects. + + This package contains contains the Script.Node.Azure assembly that allows you to reference and program against the Windows Azure APIs when creating Node.js based applications and modules with Script#. + + script azure windowsazure node nodejs javascript server scriptsharp thescriptsharp + en-US + false + + + + + + + + + + + diff --git a/src/ZipX/Packages/Lib.Node.Restify.nuspec b/src/ZipX/Packages/Lib.Node.Restify.nuspec new file mode 100644 index 000000000..d62e0c784 --- /dev/null +++ b/src/ZipX/Packages/Lib.Node.Restify.nuspec @@ -0,0 +1,29 @@ + + + + ScriptSharp.Lib.Node.Restify + 0.8 + Script# Restify for Node.js Reference Assembly + Nikhil Kothari + Copyright (c) 2012, Nikhil Kothari + http://scriptsharp.com + http://scriptsharp.com/nuget/PackageLib.png + http://scriptsharp.com/nuget/License.txt + Allows you to reference and use Restify APIs in node.js Script# projects. + + This package contains contains the Script.Node.Restify assembly that allows you to reference and program against the Restify APIs when creating Node.js based applications and modules with Script#. + + script restify node nodejs javascript server scriptsharp thescriptsharp + en-US + false + + + + + + + + + + + diff --git a/src/ZipX/ZipX.csproj b/src/ZipX/ZipX.csproj index c042ef9f6..faa70ac0b 100644 --- a/src/ZipX/ZipX.csproj +++ b/src/ZipX/ZipX.csproj @@ -28,8 +28,10 @@ + + @@ -81,8 +83,10 @@ + + From 18f37b7da8b998c9d7046125baff17470b029ea2 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Thu, 18 Apr 2013 10:46:30 -0700 Subject: [PATCH 11/35] Script.IsTruthy, IsFalsey and Or (to replace Value) to fix issue #358 --- .../Compiler/Compiler/ExpressionBuilder.cs | 22 +++++++--- .../Expressions/LiteralExpression.cs | 3 ++ src/Core/CoreLib/Script.cs | 44 ++++++++++++++----- tests/TestCases/Basic/Metadata/Baseline.txt | 20 ++++++--- .../TestCases/Expression/Script/Baseline.txt | 5 +++ tests/TestCases/Expression/Script/Code.cs | 11 +++-- tests/TestCases/Library/Node/Code.cs | 2 +- 7 files changed, 79 insertions(+), 28 deletions(-) diff --git a/src/Core/Compiler/Compiler/ExpressionBuilder.cs b/src/Core/Compiler/Compiler/ExpressionBuilder.cs index 9d1d38c46..d6543694e 100644 --- a/src/Core/Compiler/Compiler/ExpressionBuilder.cs +++ b/src/Core/Compiler/Compiler/ExpressionBuilder.cs @@ -540,12 +540,7 @@ private Expression ProcessDotExpressionNode(BinaryExpressionNode node, SymbolFil } if (objectExpression is LiteralExpression) { - object literalValue = ((LiteralExpression)objectExpression).Value; - if (!((literalValue is Boolean) || (literalValue is String))) { - // Numeric literals need to be paranthesized in script when followed by a - // dot member access. - objectExpression.AddParenthesisHint(); - } + objectExpression.AddParenthesisHint(); } Debug.Assert(objectExpression.EvaluatedType is ISymbolTable); @@ -1115,9 +1110,22 @@ private Expression ProcessOpenParenExpressionNode(BinaryExpressionNode node) { else if (method.Name.Equals("Boolean", StringComparison.Ordinal)) { Debug.Assert(args.Count == 1); + args[0].AddParenthesisHint(); + return new UnaryExpression(Operator.LogicalNot, new UnaryExpression(Operator.LogicalNot, args[0])); + } + else if (method.Name.Equals("IsTruthy", StringComparison.Ordinal)) { + Debug.Assert(args.Count == 1); + + args[0].AddParenthesisHint(); return new UnaryExpression(Operator.LogicalNot, new UnaryExpression(Operator.LogicalNot, args[0])); } - else if (method.Name.Equals("Value", StringComparison.Ordinal)) { + else if (method.Name.Equals("IsFalsey", StringComparison.Ordinal)) { + Debug.Assert(args.Count == 1); + + args[0].AddParenthesisHint(); + return new UnaryExpression(Operator.LogicalNot, args[0]); + } + else if (method.Name.Equals("Or", StringComparison.Ordinal)) { Debug.Assert(args.Count >= 2); Expression expr = args[0]; diff --git a/src/Core/Compiler/ScriptModel/Expressions/LiteralExpression.cs b/src/Core/Compiler/ScriptModel/Expressions/LiteralExpression.cs index 26baf48d7..0df7088b5 100644 --- a/src/Core/Compiler/ScriptModel/Expressions/LiteralExpression.cs +++ b/src/Core/Compiler/ScriptModel/Expressions/LiteralExpression.cs @@ -23,6 +23,9 @@ public LiteralExpression(TypeSymbol valueType, object value) protected override bool IsParenthesisRedundant { get { + // Numeric literals need to be paranthesized in script when followed by a + // dot member access, so it is not redundant for numbers. + if ((_value is String) || (_value is Boolean)) { return true; } diff --git a/src/Core/CoreLib/Script.cs b/src/Core/CoreLib/Script.cs index ecb78904b..810eb8e37 100644 --- a/src/Core/CoreLib/Script.cs +++ b/src/Core/CoreLib/Script.cs @@ -131,6 +131,16 @@ public static T InvokeMethod(Type type, string name, params object[] args) { return default(T); } + /// + /// Checks if the specified object has a falsey value, i.e. it is null or + /// undefined or empty string or false or zero. + /// + /// The object to test. + /// true if the object represents a falsey value; false otherwise. + public static bool IsFalsey(object o) { + return false; + } + [ScriptAlias("isFinite")] public static bool IsFinite(object o) { return false; @@ -186,6 +196,16 @@ public static bool IsValue(object o) { return false; } + /// + /// Checks if the specified object has a truthy value, i.e. it is not + /// null or undefined or empty string or false or zero. + /// + /// The object to test. + /// true if the object represents a truthy value; false otherwise. + public static bool IsTruthy(object o) { + return false; + } + /// /// Enables you to generate an arbitrary (literal) script expression. /// The script can contain simple String.Format style tokens (such as @@ -198,6 +218,18 @@ public static object Literal(string script, params object[] args) { return null; } + /// + /// Gets the first truthy (true, non-null, non-undefined, non-empty, non-zero) value. + /// + /// The type of the value. + /// The value to check for validity. + /// The alternate value to use if the first is invalid. + /// Additional alternative values to use if the first is invalid. + /// The first valid value. + public static TValue Or(TValue value, TValue alternateValue, params TValue[] alternateValues) { + return default(TValue); + } + public static void SetField(object instance, string name, object value) { } @@ -253,17 +285,5 @@ public static int SetTimeout(Action callback, int milliseconds, public static int SetTimeout(Delegate d, int milliseconds, params object[] args) { return 0; } - - /// - /// Gets the first valid (non-null, non-undefined, non-empty) value. - /// - /// The type of the value. - /// The value to check for validity. - /// The alternate value to use if the first is invalid. - /// Additional alternative values to use if the first is invalid. - /// The first valid value. - public static TValue Value(TValue value, TValue alternateValue, params TValue[] alternateValues) { - return default(TValue); - } } } diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index 12ad10fbb..da468d2ae 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -1513,6 +1513,11 @@ Types: Visibility: Public, Static Generated Name: invokeMethod Abstract: False + Method: IsFalsey + AssociatedType: Boolean + Visibility: Public, Static + Generated Name: isFalsey + Abstract: False Method: IsFinite AssociatedType: Boolean Visibility: Public, Static @@ -1543,11 +1548,21 @@ Types: Visibility: Public, Static Generated Name: ss.isValue Abstract: False + Method: IsTruthy + AssociatedType: Boolean + Visibility: Public, Static + Generated Name: isTruthy + Abstract: False Method: Literal AssociatedType: Object Visibility: Public, Static Generated Name: literal Abstract: False + Method: Or + AssociatedType: TValue + Visibility: Public, Static + Generated Name: or + Abstract: False Method: SetField AssociatedType: Void Visibility: Public, Static @@ -1563,11 +1578,6 @@ Types: Visibility: Public, Static Generated Name: setTimeout Abstract: False - Method: Value - AssociatedType: TValue - Visibility: Public, Static - Generated Name: value - Abstract: False Method: Enumerate AssociatedType: Object Visibility: Public, Static diff --git a/tests/TestCases/Expression/Script/Baseline.txt b/tests/TestCases/Expression/Script/Baseline.txt index a31779477..05f51928e 100644 --- a/tests/TestCases/Expression/Script/Baseline.txt +++ b/tests/TestCases/Expression/Script/Baseline.txt @@ -27,6 +27,11 @@ define('test', ['ss'], function(ss) { b = ss.isValue(i); b = isNaN(0); b = isFinite(3); + b = !!(0); + b = !!b; + b = !!(b && b); + b = !(1); + b = !(b && b); var addition = eval('2 + 2'); addition = 2 + 2; addition = 2 + 3; diff --git a/tests/TestCases/Expression/Script/Code.cs b/tests/TestCases/Expression/Script/Code.cs index f7cd615fa..6e7ca1502 100644 --- a/tests/TestCases/Expression/Script/Code.cs +++ b/tests/TestCases/Expression/Script/Code.cs @@ -8,9 +8,9 @@ namespace ExpressionTests { public class App { public void Test(int arg) { - arg = Script.Value(arg, 10); - arg = Script.Value(arg, 10, 100); - string s = Script.Value(arg, 10).ToString(10); + arg = Script.Or(arg, 10); + arg = Script.Or(arg, 10, 100); + string s = Script.Or(arg, 10).ToString(10); bool b = Script.Boolean(arg); StringBuilder sb = (StringBuilder)Script.CreateInstance(typeof(StringBuilder)); @@ -29,6 +29,11 @@ public void Test(int arg) { b = Script.IsValue(i); b = Script.IsNaN(0); b = Script.IsFinite(3); + b = Script.IsTruthy(0); + b = Script.IsTruthy(b); + b = Script.IsTruthy(b && b); + b = Script.IsFalsey(1); + b = Script.IsFalsey(b && b); int addition = (int)Script.Eval("2 + 2"); diff --git a/tests/TestCases/Library/Node/Code.cs b/tests/TestCases/Library/Node/Code.cs index 635421889..3a1b8641a 100644 --- a/tests/TestCases/Library/Node/Code.cs +++ b/tests/TestCases/Library/Node/Code.cs @@ -23,6 +23,6 @@ static App() { response.WriteHead(HttpStatusCode.OK, new Dictionary("Content-Type", "text/html")); response.End("Hello Node World, from Script#!"); - }).Listen(Script.Value(Node.Process.Environment["port"], 8888)); + }).Listen(Script.Or(Node.Process.Environment["port"], 8888)); } } From 40dc7ea3795f8548c3e41ad3641dc589c031eaa0 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Thu, 18 Apr 2013 11:04:06 -0700 Subject: [PATCH 12/35] Validate Script.Literal strings are valid String.Format strings (fix #360) --- src/Core/Compiler/Compiler/ExpressionBuilder.cs | 14 ++++++++++++++ src/Core/Compiler/Generator/ExpressionGenerator.cs | 2 +- tests/TestCases/Validation/InlineScript/Code.cs | 1 + tests/ValidationTests.cs | 3 ++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Core/Compiler/Compiler/ExpressionBuilder.cs b/src/Core/Compiler/Compiler/ExpressionBuilder.cs index d6543694e..0e2607ef2 100644 --- a/src/Core/Compiler/Compiler/ExpressionBuilder.cs +++ b/src/Core/Compiler/Compiler/ExpressionBuilder.cs @@ -7,6 +7,7 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.Linq; using ScriptSharp; using ScriptSharp.CodeModel; @@ -1100,6 +1101,19 @@ private Expression ProcessOpenParenExpressionNode(BinaryExpressionNode node) { return new InlineScriptExpression("", objectType); } + if (args.Count > 1) { + // Check whether the script is a valid string format string + try { + object[] argValues = new object[args.Count - 1]; + String.Format(CultureInfo.InvariantCulture, script, argValues); + } + catch { + _errorHandler.ReportError("The argument to Script.Literal must be a valid String.Format string.", + argNodes.Expressions[0].Token.Location); + return new InlineScriptExpression("", objectType); + } + } + InlineScriptExpression scriptExpression = new InlineScriptExpression(script, objectType); for (int i = 1; i < args.Count; i++) { scriptExpression.AddParameterValue(args[i]); diff --git a/src/Core/Compiler/Generator/ExpressionGenerator.cs b/src/Core/Compiler/Generator/ExpressionGenerator.cs index fe6e5ac3d..796d4e430 100644 --- a/src/Core/Compiler/Generator/ExpressionGenerator.cs +++ b/src/Core/Compiler/Generator/ExpressionGenerator.cs @@ -525,7 +525,7 @@ private static void GenerateInlineScriptExpression(ScriptGenerator generator, Me } } - script = String.Format(script, parameterScripts); + script = String.Format(CultureInfo.InvariantCulture, script, parameterScripts); } writer.Write(script); diff --git a/tests/TestCases/Validation/InlineScript/Code.cs b/tests/TestCases/Validation/InlineScript/Code.cs index 28de5655f..5ee3257a6 100644 --- a/tests/TestCases/Validation/InlineScript/Code.cs +++ b/tests/TestCases/Validation/InlineScript/Code.cs @@ -13,6 +13,7 @@ public void Test(int arg) { string scriptTemplate = "alert({0} + {1})"; Script.Literal(scriptTemplate, a, a); + Script.Literal("alert({name:{0}})", "aaa"); } } } diff --git a/tests/ValidationTests.cs b/tests/ValidationTests.cs index ff598d290..1d608b69e 100644 --- a/tests/ValidationTests.cs +++ b/tests/ValidationTests.cs @@ -114,7 +114,8 @@ public void TestImplicitEnums() { [TestMethod] public void TestInlineScript() { string expectedErrors = - "The argument to Script.Literal must be a constant string. Code.cs(15, 28)"; + "The argument to Script.Literal must be a constant string. Code.cs(15, 28)" + Environment.NewLine + + "The argument to Script.Literal must be a valid String.Format string. Code.cs(16, 28)"; Compilation compilation = CreateCompilation(); compilation.AddSource("Code.cs"); From b1e3243dd57d2f8a2a382077668562277ce971ca Mon Sep 17 00:00:00 2001 From: nikhilk Date: Fri, 19 Apr 2013 07:03:34 -0700 Subject: [PATCH 13/35] Add ss.value as runtime impl of Script.Value; ?? operator generates ss.value to honor c# semantics (#358) --- src/Core/Compiler/Compiler/ExpressionBuilder.cs | 16 +++++++++++++++- .../ScriptModel/Expressions/OperatorConverter.cs | 1 - src/Core/CoreLib/Script.cs | 13 +++++++++++++ src/Core/Scripts/Runtime.js | 1 + src/Core/Scripts/Runtime/Misc.js | 12 ++++++++++++ tests/TestCases/Basic/Metadata/Baseline.txt | 5 +++++ tests/TestCases/Expression/Binary/Baseline.txt | 2 +- tests/TestCases/Library/jQuery/Baseline.txt | 4 ++-- tests/TestCases/Library/jQuery/Code.cs | 4 ++-- 9 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/Core/Compiler/Compiler/ExpressionBuilder.cs b/src/Core/Compiler/Compiler/ExpressionBuilder.cs index 0e2607ef2..7faed834a 100644 --- a/src/Core/Compiler/Compiler/ExpressionBuilder.cs +++ b/src/Core/Compiler/Compiler/ExpressionBuilder.cs @@ -318,13 +318,27 @@ private Expression ProcessBinaryExpressionNode(BinaryExpressionNode node) { if (leftExpression.Type == ExpressionType.Member) { leftExpression = TransformMemberExpression((MemberExpression)leftExpression, - /* getOrAdd */ (node.Operator != TokenType.Equal)); + /* getOrAdd */ (node.Operator != TokenType.Equal)); } if (rightExpression.Type == ExpressionType.Member) { rightExpression = TransformMemberExpression((MemberExpression)rightExpression); } + if (node.Operator == TokenType.Coalesce) { + TypeSymbol scriptType = _symbolSet.ResolveIntrinsicType(IntrinsicType.Script); + MethodSymbol valueMethod = (MethodSymbol)scriptType.GetMember("Value"); + + TypeExpression scriptExpression = new TypeExpression(scriptType, SymbolFilter.Public | SymbolFilter.StaticMembers); + MethodExpression valueExpression = new MethodExpression(scriptExpression, valueMethod); + + valueExpression.AddParameterValue(leftExpression); + valueExpression.AddParameterValue(rightExpression); + valueExpression.Reevaluate(rightExpression.EvaluatedType); + + return valueExpression; + } + TypeSymbol resultType = null; Operator operatorType = OperatorConverter.OperatorFromToken(node.Operator); diff --git a/src/Core/Compiler/ScriptModel/Expressions/OperatorConverter.cs b/src/Core/Compiler/ScriptModel/Expressions/OperatorConverter.cs index d6620bab4..ff9fdffe6 100644 --- a/src/Core/Compiler/ScriptModel/Expressions/OperatorConverter.cs +++ b/src/Core/Compiler/ScriptModel/Expressions/OperatorConverter.cs @@ -48,7 +48,6 @@ public static Operator OperatorFromToken(TokenType token) { case TokenType.LogAnd: return Operator.LogicalAnd; case TokenType.LogOr: - case TokenType.Coalesce: return Operator.LogicalOr; case TokenType.EqualEqual: return Operator.EqualEqualEqual; diff --git a/src/Core/CoreLib/Script.cs b/src/Core/CoreLib/Script.cs index 810eb8e37..3e25f586a 100644 --- a/src/Core/CoreLib/Script.cs +++ b/src/Core/CoreLib/Script.cs @@ -285,5 +285,18 @@ public static int SetTimeout(Action callback, int milliseconds, public static int SetTimeout(Delegate d, int milliseconds, params object[] args) { return 0; } + + /// + /// Gets the first non-null and non-undefined value. + /// + /// The type of the value. + /// The value to check for validity. + /// The alternate value to use if the first is invalid. + /// Additional alternative values to use if the first is invalid. + /// The first valid value. + [ScriptAlias("ss.value")] + public static TValue Value(TValue value, TValue alternateValue, params TValue[] alternateValues) { + return default(TValue); + } } } diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index 6244ce646..737fa772e 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -44,6 +44,7 @@ version: '0.8', isValue: isValue, + value: value, extend: extend, keys: keys, keyCount: keyCount, diff --git a/src/Core/Scripts/Runtime/Misc.js b/src/Core/Scripts/Runtime/Misc.js index 6fa583819..9275e4d8b 100644 --- a/src/Core/Scripts/Runtime/Misc.js +++ b/src/Core/Scripts/Runtime/Misc.js @@ -7,6 +7,18 @@ function isValue(o) { return (o !== null) && (o !== undefined); } +function _value(args) { + for (var i = 2, l = args.length; i < l; i++) { + if (isValue(args[i])) { + return args[i]; + } + } + return null; +} +function value(a, b) { + return isValue(a) ? a : isValue(b) ? b : _value(arguments); +} + function extend(o, items) { for (var n in items) { o[n] = items[n]; diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index da468d2ae..c3d6f72df 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -1578,6 +1578,11 @@ Types: Visibility: Public, Static Generated Name: setTimeout Abstract: False + Method: Value + AssociatedType: TValue + Visibility: Public, Static + Generated Name: ss.value + Abstract: False Method: Enumerate AssociatedType: Object Visibility: Public, Static diff --git a/tests/TestCases/Expression/Binary/Baseline.txt b/tests/TestCases/Expression/Binary/Baseline.txt index ff3b9e1ea..262b6ad85 100644 --- a/tests/TestCases/Expression/Binary/Baseline.txt +++ b/tests/TestCases/Expression/Binary/Baseline.txt @@ -85,7 +85,7 @@ define('test', ['ss'], function(ss) { var d = new Data(); d.set_value(d.get_value() + 5); d.set_flag((d.get_flag() | true) === 1); - var o1 = null || {}; + var o1 = ss.value(null, {}); var s2 = (10).toString(); s2 = (100).toString(); s2 = true.toString(); diff --git a/tests/TestCases/Library/jQuery/Baseline.txt b/tests/TestCases/Library/jQuery/Baseline.txt index c28be011f..76ddc570f 100644 --- a/tests/TestCases/Library/jQuery/Baseline.txt +++ b/tests/TestCases/Library/jQuery/Baseline.txt @@ -17,8 +17,8 @@ define('test', ['ss', 'jquery'], function(ss, $) { } }); }; MyApp.postData = function(url, data, succesCallback, errorCallback, returnType, requestType) { - returnType = returnType || 'text'; - requestType = requestType || 'POST'; + returnType = (returnType || 'text'); + requestType = (requestType || 'POST'); $.ajax({ cache: false, data: data, dataType: returnType, error: function(req, textStatus, error) { if (ss.isValue(errorCallback)) { errorCallback(req, textStatus, error); diff --git a/tests/TestCases/Library/jQuery/Code.cs b/tests/TestCases/Library/jQuery/Code.cs index e64103c26..46395d620 100644 --- a/tests/TestCases/Library/jQuery/Code.cs +++ b/tests/TestCases/Library/jQuery/Code.cs @@ -43,8 +43,8 @@ private static void AlertData(string url) { } public static void PostData(string url, object data, AjaxRequestCallback succesCallback, AjaxErrorCallback errorCallback, string returnType, string requestType) { - returnType = returnType ?? "text"; - requestType = requestType ?? "POST"; + returnType = Script.Or(returnType, "text"); + requestType = Script.Or(requestType, "POST"); jQuery.Ajax(new jQueryAjaxOptions( "cache", false, From febce32387b8ac3e278eec802edd5a0232a5cec7 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sat, 20 Apr 2013 07:46:21 -0700 Subject: [PATCH 14/35] Add some missing xml dom APIs; remove some IE only ones. --- src/Libraries/Web/Xml/XmlNode.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Libraries/Web/Xml/XmlNode.cs b/src/Libraries/Web/Xml/XmlNode.cs index ed6189b80..e1fb1a90e 100644 --- a/src/Libraries/Web/Xml/XmlNode.cs +++ b/src/Libraries/Web/Xml/XmlNode.cs @@ -137,31 +137,31 @@ public XmlNodeList GetElementsByTagName(string tagName) { return null; } - public bool HasChildNodes() { + public bool HasAttributes() { return false; } - public XmlNode InsertBefore(XmlNode child, XmlNode refChild) { - return null; + public bool HasChildNodes() { + return false; } - public XmlNode RemoveChild(XmlNode child) { + public XmlNode InsertBefore(XmlNode child, XmlNode refChild) { return null; } - public XmlNode ReplaceChild(XmlNode child, XmlNode oldChild) { + public XmlNode QuerySelector(string selector) { return null; } - public XmlNodeList SelectNodes(string xpath) { + public XmlNodeList QuerySelectorAll(string selector) { return null; } - public XmlNode SelectSingleNode(string xpath) { + public XmlNode RemoveChild(XmlNode child) { return null; } - public string TransformNode(XmlDocument stylesheet) { + public XmlNode ReplaceChild(XmlNode child, XmlNode oldChild) { return null; } } From cb6e0f3347f20cae47ede09b42dcd4d615b02443 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sat, 20 Apr 2013 08:23:58 -0700 Subject: [PATCH 15/35] String.Trim with ability to specify trim characters + updated tests --- src/Core/CoreLib/String.cs | 16 ++++++++++++ src/Core/Scripts/Runtime.js | 1 + src/Core/Scripts/Runtime/String.js | 18 ++++++++++--- tests/TestCases/Basic/Metadata/Baseline.txt | 2 +- .../Expression/Generics/Baseline.txt | 2 +- tests/TestSite/String.htm | 25 +++++++++++++++++-- 6 files changed, 56 insertions(+), 8 deletions(-) diff --git a/src/Core/CoreLib/String.cs b/src/Core/CoreLib/String.cs index 6939d8088..e445f6acc 100644 --- a/src/Core/CoreLib/String.cs +++ b/src/Core/CoreLib/String.cs @@ -379,20 +379,36 @@ public string ToUpperCase() { return null; } + [ScriptAlias("ss.trim")] public string Trim() { return null; } + [ScriptAlias("ss.trim")] + public string Trim(char[] trimCharacters) { + return null; + } + [ScriptAlias("ss.trimEnd")] public string TrimEnd() { return null; } + [ScriptAlias("ss.trimEnd")] + public string TrimEnd(char[] trimCharacters) { + return null; + } + [ScriptAlias("ss.trimStart")] public string TrimStart() { return null; } + [ScriptAlias("ss.trimStart")] + public string TrimStart(char[] trimCharacters) { + return null; + } + /// /// Decodes a string by replacing escaped parts with their equivalent textual representation. /// diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index 737fa772e..4fa0d4d37 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -71,6 +71,7 @@ endsWith: endsWith, padLeft: padLeft, padRight: padRight, + trim: trim, trimStart: trimStart, trimEnd: trimEnd, insertString: insertString, diff --git a/src/Core/Scripts/Runtime/String.js b/src/Core/Scripts/Runtime/String.js index ca3467230..6b864a922 100644 --- a/src/Core/Scripts/Runtime/String.js +++ b/src/Core/Scripts/Runtime/String.js @@ -58,11 +58,21 @@ function format(cultureOrFormat) { }); } -function trimStart(s) { - return s.replace(/^\s*/, ''); +function trim(s, tc) { + if (tc || !String.prototype.trim) { + tc = tc ? tc.join('') : null; + var r = tc ? new RegExp('^[' + tc + ']+|[' + tc + ']+$', 'g') : /^\s+|\s+$/g; + return s.replace(r, ''); + } + return s.trim(); +} +function trimStart(s, tc) { + var r = tc ? new RegExp('^[' + tc.join('') + ']+') : /^\s+/; + return s.replace(r, ''); } -function trimEnd(s) { - return s.replace(/\s*$/, ''); +function trimEnd(s, tc) { + var r = tc ? new RegExp('[' + tc.join('') + ']+$') : /\s+$/; + return s.replace(r, ''); } function startsWith(s, prefix) { if (emptyString(prefix)) { diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index c3d6f72df..4e7a523b0 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -1836,7 +1836,7 @@ Types: Method: Trim AssociatedType: String Visibility: Public - Generated Name: trim + Generated Name: ss.trim Abstract: False Method: TrimEnd AssociatedType: String diff --git a/tests/TestCases/Expression/Generics/Baseline.txt b/tests/TestCases/Expression/Generics/Baseline.txt index d227986bf..a4864a0d8 100644 --- a/tests/TestCases/Expression/Generics/Baseline.txt +++ b/tests/TestCases/Expression/Generics/Baseline.txt @@ -14,7 +14,7 @@ define('test', ['ss', 'jquery'], function(ss, $) { }, 0).toString(10); var s4 = encodeURIComponent(this._func(10)); var f2 = this._func; - f2(11).trim(); + ss.trim(f2(11)); var d = {}; var s5 = $.extend(d, d)['abc'].toString(10); var keys = ss.keyCount(d); diff --git a/tests/TestSite/String.htm b/tests/TestSite/String.htm index dc0422059..7adba8c55 100644 --- a/tests/TestSite/String.htm +++ b/tests/TestSite/String.htm @@ -22,11 +22,32 @@

test('trim', function() { QUnit.equal(ss.trimStart('Hello'), 'Hello'); QUnit.equal(ss.trimStart(' Hello'), 'Hello'); - QUnit.equal(ss.trimEnd(' Hello'), ' Hello'); + QUnit.equal(ss.trimStart(' Hello '), 'Hello '); + + QUnit.equal(ss.trimEnd('Hello'), 'Hello'); QUnit.equal(ss.trimEnd('Hello '), 'Hello'); - QUnit.equal(ss.trimStart('Hello'), 'Hello'); + QUnit.equal(ss.trimEnd(' Hello '), ' Hello'); + QUnit.equal(ss.trimEnd(ss.trimStart(' Hello ')), 'Hello'); QUnit.equal(ss.trimEnd(ss.trimStart('\tHello ')), 'Hello'); + + QUnit.equal(ss.trim('Hello'), 'Hello'); + QUnit.equal(ss.trim(' Hello '), 'Hello'); + QUnit.equal(ss.trim('\tHello '), 'Hello'); + QUnit.equal(ss.trim('\t Hello World '), 'Hello World'); + + QUnit.equal(ss.trimStart('00word00', ['0']), 'word00'); + QUnit.equal(ss.trimStart('10word01', ['0', '1']), 'word01'); + QUnit.equal(ss.trimStart('10 0word0 01', ['0', '1']), ' 0word0 01'); + + QUnit.equal(ss.trimEnd('00word00', ['0']), '00word'); + QUnit.equal(ss.trimEnd('10word01', ['0', '1']), '10word'); + QUnit.equal(ss.trimEnd('10 0word0 01', ['0', '1']), '10 0word0 '); + + QUnit.equal(ss.trim('00word00', ['0']), 'word'); + QUnit.equal(ss.trim('10word01', ['0', '1']), 'word'); + QUnit.equal(ss.trim('10 0word0 01', ['0', '1']), ' 0word0 '); + QUnit.equal(ss.trim(' word ', []), 'word'); }); test('padLeft', function() { From fe6900d18f3178c2c415b039dc5f8c117c513466 Mon Sep 17 00:00:00 2001 From: Nick Karnik Date: Sat, 20 Apr 2013 10:58:43 -0700 Subject: [PATCH 16/35] Creating stubs for base64 encoding/decoding as listed in #362 --- src/Libraries/Web/Html/Window.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Libraries/Web/Html/Window.cs b/src/Libraries/Web/Html/Window.cs index 2a111fb81..6fab1367e 100644 --- a/src/Libraries/Web/Html/Window.cs +++ b/src/Libraries/Web/Html/Window.cs @@ -324,6 +324,28 @@ public static void Alert(object o) { public static void AttachEvent(string eventName, ElementEventHandler handler) { } + /// + /// Decodes a string of data which has been encoded using base-64 encoding. + /// For use with Unicode or UTF-8 strings. + /// + /// Base64 encoded string + /// String of Binary data + [ScriptName("atob")] + public static string Base64ToBinary(string base64EncodedData) { + return null; + } + + /// + /// Creates a base-64 encoded ASCII string from a "string" of binary data. + /// Please note that this is not suitable for raw Unicode strings! + /// + /// String of binary data + /// Base64 string + [ScriptName("btoa")] + public static string BinaryToBase64(string stringToEncode) { + return null; + } + public static void Close() { } From 5a41f0fb01ca19519fd4f7b48df7e73574d844dc Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 28 Apr 2013 23:19:29 -0700 Subject: [PATCH 17/35] Fix missing metadata attribute --- src/Libraries/Node/Node.Core/IO/Path.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Libraries/Node/Node.Core/IO/Path.cs b/src/Libraries/Node/Node.Core/IO/Path.cs index 8b07b34f7..725e7052b 100644 --- a/src/Libraries/Node/Node.Core/IO/Path.cs +++ b/src/Libraries/Node/Node.Core/IO/Path.cs @@ -11,6 +11,7 @@ namespace NodeApi.IO { [ScriptImport] [ScriptIgnoreNamespace] [ScriptDependency("path")] + [ScriptName("path")] public static class Path { [ScriptName("sep")] From adcba6f82cb4ab9e274ab6ca82410c906418955a Mon Sep 17 00:00:00 2001 From: nikhilk Date: Fri, 10 May 2013 21:03:13 -0700 Subject: [PATCH 18/35] Fix azure import library metadata/APIs --- src/Libraries/Node/Node.Azure/Azure.cs | 8 -------- src/Libraries/Node/Node.Azure/Storage/CloudTableQuery.cs | 4 +--- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Libraries/Node/Node.Azure/Azure.cs b/src/Libraries/Node/Node.Azure/Azure.cs index c6f7baee5..7b6a58b4d 100644 --- a/src/Libraries/Node/Node.Azure/Azure.cs +++ b/src/Libraries/Node/Node.Azure/Azure.cs @@ -26,14 +26,6 @@ public static RoleEnvironment RoleEnvironment { } } - [ScriptField] - [ScriptName(PreserveCase = true)] - public static CloudTableQuery TableQuery { - get { - return null; - } - } - public static CloudBlobService CreateBlobService() { return null; } diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudTableQuery.cs b/src/Libraries/Node/Node.Azure/Storage/CloudTableQuery.cs index 30fec793c..a54c06903 100644 --- a/src/Libraries/Node/Node.Azure/Storage/CloudTableQuery.cs +++ b/src/Libraries/Node/Node.Azure/Storage/CloudTableQuery.cs @@ -11,11 +11,9 @@ namespace NodeApi.WindowsAzure.Storage { [ScriptImport] [ScriptIgnoreNamespace] + [ScriptName("azure.TableQuery")] public sealed class CloudTableQuery { - private CloudTableQuery() { - } - public CloudTableQuery And(string filter, object[] values) { return null; } From 760cc48c6dfd6eff209d00d1dbb112cdb9c57c16 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Fri, 24 May 2013 05:41:17 -0700 Subject: [PATCH 19/35] Improve azure node module import library APIs --- .../CloudBlobContainerListContinuation.cs | 3 +- .../Storage/CloudBlobListContinuation.cs | 3 +- .../Node.Azure/Storage/CloudBlobService.cs | 17 ++++--- .../Storage/CloudQueueListContinuation.cs | 3 +- .../Node.Azure/Storage/CloudQueueService.cs | 13 ++--- .../Storage/CloudTableListContinuation.cs | 3 +- .../Storage/CloudTableQueryContinuation.cs | 3 +- .../Node.Azure/Storage/CloudTableService.cs | 49 ++++++++++--------- 8 files changed, 51 insertions(+), 43 deletions(-) diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudBlobContainerListContinuation.cs b/src/Libraries/Node/Node.Azure/Storage/CloudBlobContainerListContinuation.cs index a8d70f5dc..3bec7f8c9 100644 --- a/src/Libraries/Node/Node.Azure/Storage/CloudBlobContainerListContinuation.cs +++ b/src/Libraries/Node/Node.Azure/Storage/CloudBlobContainerListContinuation.cs @@ -4,6 +4,7 @@ // using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; namespace NodeApi.WindowsAzure.Storage { @@ -22,7 +23,7 @@ public string NextMarker { } } - public void GetNextPage(AsyncResultCallback callback) { + public void GetNextPage(AsyncResultCallback, CloudBlobContainerListContinuation> callback) { } public bool HasNextPage() { diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudBlobListContinuation.cs b/src/Libraries/Node/Node.Azure/Storage/CloudBlobListContinuation.cs index 96b11c367..31065d9db 100644 --- a/src/Libraries/Node/Node.Azure/Storage/CloudBlobListContinuation.cs +++ b/src/Libraries/Node/Node.Azure/Storage/CloudBlobListContinuation.cs @@ -4,6 +4,7 @@ // using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; namespace NodeApi.WindowsAzure.Storage { @@ -22,7 +23,7 @@ public string NextMarker { } } - public void GetNextPage(AsyncResultCallback callback) { + public void GetNextPage(AsyncResultCallback, CloudBlobListContinuation> callback) { } public bool HasNextPage() { diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudBlobService.cs b/src/Libraries/Node/Node.Azure/Storage/CloudBlobService.cs index bfc335eee..04ad65b8b 100644 --- a/src/Libraries/Node/Node.Azure/Storage/CloudBlobService.cs +++ b/src/Libraries/Node/Node.Azure/Storage/CloudBlobService.cs @@ -4,6 +4,7 @@ // using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; using NodeApi.IO; @@ -105,28 +106,28 @@ public void GetBlobToText(string containerName, string blobName, string text, As public void GetBlobToText(string containerName, string blobName, string text, object options, AsyncResultCallback callback) { } - public void ListBlobs(string containerName, AsyncResultCallback callback) { + public void ListBlobs(string containerName, AsyncResultCallback> callback) { } - public void ListBlobs(string containerName, AsyncResultCallback callback) { + public void ListBlobs(string containerName, AsyncResultCallback, CloudBlobListContinuation> callback) { } - public void ListBlobs(string containerName, object options, AsyncResultCallback callback) { + public void ListBlobs(string containerName, object options, AsyncResultCallback> callback) { } - public void ListBlobs(string containerName, object options, AsyncResultCallback callback) { + public void ListBlobs(string containerName, object options, AsyncResultCallback, CloudBlobListContinuation> callback) { } - public void ListContainers(AsyncResultCallback callback) { + public void ListContainers(AsyncResultCallback> callback) { } - public void ListContainers(AsyncResultCallback callback) { + public void ListContainers(AsyncResultCallback, CloudBlobContainerListContinuation> callback) { } - public void ListContainers(object options, AsyncResultCallback callback) { + public void ListContainers(object options, AsyncResultCallback> callback) { } - public void ListContainers(object options, AsyncResultCallback callback) { + public void ListContainers(object options, AsyncResultCallback, CloudBlobContainerListContinuation> callback) { } public void ReleaseLease(string containerName, string blobName, string leaseID, AsyncResultCallback callback) { diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudQueueListContinuation.cs b/src/Libraries/Node/Node.Azure/Storage/CloudQueueListContinuation.cs index bc3072342..2d32e5418 100644 --- a/src/Libraries/Node/Node.Azure/Storage/CloudQueueListContinuation.cs +++ b/src/Libraries/Node/Node.Azure/Storage/CloudQueueListContinuation.cs @@ -4,6 +4,7 @@ // using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; namespace NodeApi.WindowsAzure.Storage { @@ -22,7 +23,7 @@ public string NextMarker { } } - public void GetNextPage(AsyncResultCallback callback) { + public void GetNextPage(AsyncResultCallback, CloudQueueListContinuation> callback) { } public bool HasNextPage() { diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudQueueService.cs b/src/Libraries/Node/Node.Azure/Storage/CloudQueueService.cs index 7badc2ca8..f3826a8d3 100644 --- a/src/Libraries/Node/Node.Azure/Storage/CloudQueueService.cs +++ b/src/Libraries/Node/Node.Azure/Storage/CloudQueueService.cs @@ -4,6 +4,7 @@ // using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; namespace NodeApi.WindowsAzure.Storage { @@ -54,22 +55,22 @@ public void DeleteQueue(string queueName, AsyncCallback callback) { public void DeleteQueue(string queueName, object options, AsyncCallback callback) { } - public void GetMessages(string queueName, AsyncResultCallback callback) { + public void GetMessages(string queueName, AsyncResultCallback> callback) { } - public void GetMessages(string queueName, object options, AsyncResultCallback callback) { + public void GetMessages(string queueName, object options, AsyncResultCallback> callback) { } - public void ListQueues(AsyncResultCallback callback) { + public void ListQueues(AsyncResultCallback> callback) { } - public void ListQueues(object options, AsyncResultCallback callback) { + public void ListQueues(object options, AsyncResultCallback> callback) { } - public void PeekMessages(string queueName, AsyncResultCallback callback) { + public void PeekMessages(string queueName, AsyncResultCallback> callback) { } - public void PeekMessages(string queueName, object options, AsyncResultCallback callback) { + public void PeekMessages(string queueName, object options, AsyncResultCallback> callback) { } public void UpdateMessage(string queueName, string messageID, string popReceipt, int visibilityTimeout, AsyncResultCallback callback) { diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudTableListContinuation.cs b/src/Libraries/Node/Node.Azure/Storage/CloudTableListContinuation.cs index 2c529df3a..10214c048 100644 --- a/src/Libraries/Node/Node.Azure/Storage/CloudTableListContinuation.cs +++ b/src/Libraries/Node/Node.Azure/Storage/CloudTableListContinuation.cs @@ -4,6 +4,7 @@ // using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; namespace NodeApi.WindowsAzure.Storage { @@ -22,7 +23,7 @@ public string NextTableName { } } - public void GetNextPage(AsyncResultCallback callback) { + public void GetNextPage(AsyncResultCallback, CloudTableListContinuation> callback) { } public bool HasNextPage() { diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudTableQueryContinuation.cs b/src/Libraries/Node/Node.Azure/Storage/CloudTableQueryContinuation.cs index fef7691e8..9c613bac3 100644 --- a/src/Libraries/Node/Node.Azure/Storage/CloudTableQueryContinuation.cs +++ b/src/Libraries/Node/Node.Azure/Storage/CloudTableQueryContinuation.cs @@ -4,6 +4,7 @@ // using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; namespace NodeApi.WindowsAzure.Storage { @@ -29,7 +30,7 @@ public string NextRowKey { } } - public void GetNextPage(AsyncResultCallback callback) { + public void GetNextPage(AsyncResultCallback, CloudTableQueryContinuation> callback) { } public bool HasNextPage() { diff --git a/src/Libraries/Node/Node.Azure/Storage/CloudTableService.cs b/src/Libraries/Node/Node.Azure/Storage/CloudTableService.cs index db98e00af..1360191c6 100644 --- a/src/Libraries/Node/Node.Azure/Storage/CloudTableService.cs +++ b/src/Libraries/Node/Node.Azure/Storage/CloudTableService.cs @@ -4,6 +4,7 @@ // using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; namespace NodeApi.WindowsAzure.Storage { @@ -33,44 +34,44 @@ public void CreateTable(string tableName, AsyncCallback callback) { public void CreateTable(string tableName, object options, AsyncCallback callback) { } - public void CreateTableIfNotExists(string tableName, AsyncCallback callback) { + public void CreateTableIfNotExists(string tableName, AsyncResultCallback callback) { } - public void CreateTableIfNotExists(string tableName, object options, AsyncCallback callback) { + public void CreateTableIfNotExists(string tableName, object options, AsyncResultCallback callback) { } - public void DeleteEntity(string tableName, CloudTableEntity entity, AsyncCallback callback) { + public void DeleteEntity(string tableName, CloudTableEntity entity, AsyncResultCallback callback) { } - public void DeleteEntity(string tableName, CloudTableEntity entity, object options, AsyncCallback callback) { + public void DeleteEntity(string tableName, CloudTableEntity entity, object options, AsyncResultCallback callback) { } - public void DeleteTable(string tableName, AsyncCallback callback) { + public void DeleteTable(string tableName, AsyncResultCallback callback) { } - public void DeleteTable(string tableName, object options, AsyncCallback callback) { + public void DeleteTable(string tableName, object options, AsyncResultCallback callback) { } public bool HasOperations() { return false; } - public void InsertEntity(string tableName, CloudTableEntity entity, AsyncCallback callback) { + public void InsertEntity(string tableName, CloudTableEntity entity, AsyncResultCallback callback) { } - public void InsertEntity(string tableName, CloudTableEntity entity, object options, AsyncCallback callback) { + public void InsertEntity(string tableName, CloudTableEntity entity, object options, AsyncResultCallback callback) { } - public void InsertOrMergeEntity(string tableName, CloudTableEntity entity, AsyncCallback callback) { + public void InsertOrMergeEntity(string tableName, CloudTableEntity entity, AsyncResultCallback callback) { } - public void InsertOrMergeEntity(string tableName, CloudTableEntity entity, object options, AsyncCallback callback) { + public void InsertOrMergeEntity(string tableName, CloudTableEntity entity, object options, AsyncResultCallback callback) { } - public void InsertOrReplaceEntity(string tableName, CloudTableEntity entity, AsyncCallback callback) { + public void InsertOrReplaceEntity(string tableName, CloudTableEntity entity, AsyncResultCallback callback) { } - public void InsertOrReplaceEntity(string tableName, CloudTableEntity entity, object options, AsyncCallback callback) { + public void InsertOrReplaceEntity(string tableName, CloudTableEntity entity, object options, AsyncResultCallback callback) { } public bool IsInBatch() { @@ -78,37 +79,37 @@ public bool IsInBatch() { } [ScriptName("queryTables")] - public void ListTables(AsyncResultCallback callback) { + public void ListTables(AsyncResultCallback> callback) { } [ScriptName("queryTables")] - public void ListTables(AsyncResultCallback callback) { + public void ListTables(AsyncResultCallback, CloudTableListContinuation> callback) { } [ScriptName("queryTables")] - public void ListTables(object options, AsyncResultCallback callback) { + public void ListTables(object options, AsyncResultCallback> callback) { } [ScriptName("queryTables")] - public void ListTables(object options, AsyncResultCallback callback) { + public void ListTables(object options, AsyncResultCallback, CloudTableListContinuation> callback) { } - public void MergeEntity(string tableName, CloudTableEntity entity, AsyncCallback callback) { + public void MergeEntity(string tableName, CloudTableEntity entity, AsyncResultCallback callback) { } - public void MergeEntity(string tableName, CloudTableEntity entity, object options, AsyncCallback callback) { + public void MergeEntity(string tableName, CloudTableEntity entity, object options, AsyncResultCallback callback) { } - public void QueryEntities(CloudTableQuery query, AsyncResultCallback callback) { + public void QueryEntities(CloudTableQuery query, AsyncResultCallback> callback) { } - public void QueryEntities(CloudTableQuery query, object options, AsyncResultCallback callback) { + public void QueryEntities(CloudTableQuery query, object options, AsyncResultCallback> callback) { } - public void QueryEntities(CloudTableQuery query, AsyncResultCallback callback) { + public void QueryEntities(CloudTableQuery query, AsyncResultCallback, CloudTableQueryContinuation> callback) { } - public void QueryEntities(CloudTableQuery query, object options, AsyncResultCallback callback) { + public void QueryEntities(CloudTableQuery query, object options, AsyncResultCallback, CloudTableQueryContinuation> callback) { } public void QueryEntity(string tableName, string partitionKey, string rowKey, AsyncResultCallback callback) { @@ -120,10 +121,10 @@ public void QueryEntity(string tableName, string partitionKey, string rowKey, ob public void Rollback() { } - public void UpdateEntity(string tableName, CloudTableEntity entity, AsyncCallback callback) { + public void UpdateEntity(string tableName, CloudTableEntity entity, AsyncResultCallback callback) { } - public void UpdateEntity(string tableName, CloudTableEntity entity, object options, AsyncCallback callback) { + public void UpdateEntity(string tableName, CloudTableEntity entity, object options, AsyncResultCallback callback) { } } } From 91ce5c172ebe939c52bbd23e80459aa3433d4b31 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Fri, 24 May 2013 05:43:22 -0700 Subject: [PATCH 20/35] Script# node module/npm package --- src/Core/Compiler/ScriptCompiler.cs | 11 ++++++++++- src/Core/Scripts/Package/package.json | 17 +++++++++++++++++ src/Core/Scripts/Package/readme.md | 4 ++++ src/Core/Scripts/Scripts.csproj | 6 ++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/Core/Scripts/Package/package.json create mode 100644 src/Core/Scripts/Package/readme.md diff --git a/src/Core/Compiler/ScriptCompiler.cs b/src/Core/Compiler/ScriptCompiler.cs index 50045e229..b2700fbb4 100644 --- a/src/Core/Compiler/ScriptCompiler.cs +++ b/src/Core/Compiler/ScriptCompiler.cs @@ -314,11 +314,20 @@ private string GenerateScriptWithTemplate() { depLookupBuilder.Append(",\r\n "); } + string name = dependency.Name; + if (name == "ss") { + // TODO: This is a hack... to make generated node.js scripts + // be able to reference the 'scriptsharp' node module. + // Fix this in a better/1st class manner by allowing + // script assemblies to declare such things. + name = "scriptsharp"; + } + requiresBuilder.Append("'" + dependency.Path + "'"); dependenciesBuilder.Append(dependency.Identifier); depLookupBuilder.Append(dependency.Identifier); - depLookupBuilder.Append(" = require('" + dependency.Name + "')"); + depLookupBuilder.Append(" = require('" + name + "')"); firstDependency = false; } diff --git a/src/Core/Scripts/Package/package.json b/src/Core/Scripts/Package/package.json new file mode 100644 index 000000000..80826f7d6 --- /dev/null +++ b/src/Core/Scripts/Package/package.json @@ -0,0 +1,17 @@ +{ + "name": "scriptsharp", + "version": "0.8.0", + "description": "Script# Runtime", + "keywords": [ "scriptsharp", "script#" ], + "author": "Nikhil Kothari", + "license": "Apache 2.0", + "repository": { + "type": "git", + "url": "https://github.com/nikhilk/scriptsharp" + }, + "main": "ss.js", + "dependencies": {}, + "engines": { + "node": "*" + } +} diff --git a/src/Core/Scripts/Package/readme.md b/src/Core/Scripts/Package/readme.md new file mode 100644 index 000000000..b71dace71 --- /dev/null +++ b/src/Core/Scripts/Package/readme.md @@ -0,0 +1,4 @@ +Script# Runtime + +This packages the script# runtime as a node module for node.js applications written using c# and compiled into javascript using the script# compiler. +More information is at [http://scriptsharp.com](http://scriptsharp.com). diff --git a/src/Core/Scripts/Scripts.csproj b/src/Core/Scripts/Scripts.csproj index e8894387f..a9323d886 100644 --- a/src/Core/Scripts/Scripts.csproj +++ b/src/Core/Scripts/Scripts.csproj @@ -32,11 +32,17 @@ + + + + + + From 09d872149777afcc00d735ac88824f2170e9fc6c Mon Sep 17 00:00:00 2001 From: nikhilk Date: Tue, 4 Jun 2013 04:03:39 -0700 Subject: [PATCH 21/35] Test fixes --- tests/TestCases/Basic/Simple/SimpleBaseline.txt | 2 +- tests/TestCases/Library/Node/Baseline.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/TestCases/Basic/Simple/SimpleBaseline.txt b/tests/TestCases/Basic/Simple/SimpleBaseline.txt index 1cecbaec5..68ee0124f 100644 --- a/tests/TestCases/Basic/Simple/SimpleBaseline.txt +++ b/tests/TestCases/Basic/Simple/SimpleBaseline.txt @@ -3,7 +3,7 @@ "use strict"; (function($global) { - var ss = require('ss'); + var ss = require('scriptsharp'); // Basic.EventArgs diff --git a/tests/TestCases/Library/Node/Baseline.txt b/tests/TestCases/Library/Node/Baseline.txt index e2be2db2b..f53bbd167 100644 --- a/tests/TestCases/Library/Node/Baseline.txt +++ b/tests/TestCases/Library/Node/Baseline.txt @@ -1,7 +1,7 @@ // app.js // -var ss = require('ss'), +var ss = require('scriptsharp'), http = require('http'); var $global = this; From 8b97f3f847b993ac4c15586dc7414b10589ee463 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Tue, 4 Jun 2013 04:04:36 -0700 Subject: [PATCH 22/35] Add PATCH to http verbs enumeration --- src/Libraries/Node/Node.Core/Network/HttpVerb.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Libraries/Node/Node.Core/Network/HttpVerb.cs b/src/Libraries/Node/Node.Core/Network/HttpVerb.cs index 01198d564..b7d9c3a44 100644 --- a/src/Libraries/Node/Node.Core/Network/HttpVerb.cs +++ b/src/Libraries/Node/Node.Core/Network/HttpVerb.cs @@ -23,6 +23,8 @@ public enum HttpVerb { HEAD, - OPTIONS + OPTIONS, + + PATCH } } From 283e79dd0015adb6c68e427bc4f1f26a0dca0e1c Mon Sep 17 00:00:00 2001 From: nikhilk Date: Tue, 4 Jun 2013 04:06:39 -0700 Subject: [PATCH 23/35] Fixed bug in Task implementation Add ability to write a task continuation that changes the task result --- src/Core/CoreLib/Threading/Task.cs | 8 ++++++++ src/Core/Scripts/Runtime/Task.js | 19 ++++++++++++++++++- tests/TestCases/Basic/Metadata/Baseline.txt | 10 ++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Core/CoreLib/Threading/Task.cs b/src/Core/CoreLib/Threading/Task.cs index 14e0080e7..2ab3bce7f 100644 --- a/src/Core/CoreLib/Threading/Task.cs +++ b/src/Core/CoreLib/Threading/Task.cs @@ -50,6 +50,10 @@ public static Task Any(int timeout, params Task[] tasks) { return null; } + public Task ChangeWith(Func continuation) { + return null; + } + public Task ContinueWith(Action continuation) { return null; } @@ -85,6 +89,10 @@ public T Result { } } + public Task ChangeWith(Func, TResult> continuation) { + return null; + } + public Task ContinueWith(Action> continuation) { return null; } diff --git a/src/Core/Scripts/Runtime/Task.js b/src/Core/Scripts/Runtime/Task.js index c308d00d6..066c34b67 100644 --- a/src/Core/Scripts/Runtime/Task.js +++ b/src/Core/Scripts/Runtime/Task.js @@ -1,7 +1,7 @@ // Task function Task(result) { - this._continuations = isValue(result) ? + this._continuations = result !== undefined ? (this.status = 'done', null) : (this.status = 'pending', []); this.result = result; @@ -11,6 +11,23 @@ var Task$ = { get_completed: function() { return this.status != 'pending'; }, + changeWith: function(continuation) { + var task = new Task(); + this.continueWith(function(t) { + var error = t.error; + var result; + if (!error) { + try { + result = continuation(t); + } + catch (e) { + error = e; + } + } + _updateTask(task, result, error); + }); + return task; + }, continueWith: function(continuation) { if (this._continuations) { this._continuations.push(continuation); diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index 4e7a523b0..dac4adc20 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -3669,6 +3669,11 @@ Types: Visibility: Public, Static Generated Name: any Abstract: False + Method: ChangeWith + AssociatedType: Task`1 + Visibility: Public + Generated Name: changeWith + Abstract: False Method: ContinueWith AssociatedType: Task Visibility: Public @@ -3706,6 +3711,11 @@ Types: AssociatedType: T Visibility: Public Generated Name: result + Method: ChangeWith + AssociatedType: Task`1 + Visibility: Public + Generated Name: changeWith + Abstract: False Method: ContinueWith AssociatedType: Task`1 Visibility: Public From 35444d0a9f9d0ad49d355d15c220dec0e562420b Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sat, 15 Jun 2013 17:22:01 -0700 Subject: [PATCH 24/35] Handle scenario for Task.All/Any called with array of tasks rather than sequence of params. --- src/Core/Scripts/Runtime/Task.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Core/Scripts/Runtime/Task.js b/src/Core/Scripts/Runtime/Task.js index 066c34b67..40dd9f3b3 100644 --- a/src/Core/Scripts/Runtime/Task.js +++ b/src/Core/Scripts/Runtime/Task.js @@ -90,6 +90,10 @@ function _joinTasks(tasks, any) { tasks = tasks.slice(1); count--; } + if (Array.isArray(tasks[0])) { + tasks = tasks[0]; + count = tasks.length; + } var joinTask = new Task(); var seen = 0; From 2be30f9eae0c3369abd669d3dd110b694d9dcc63 Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Tue, 18 Jun 2013 19:21:43 -0500 Subject: [PATCH 25/35] Fix for issue #379: use known compile time base to build runtime expression. --- .../Compiler/Generator/ExpressionGenerator.cs | 28 ++++++++----------- src/Core/Scripts/Runtime.js | 1 - src/Core/Scripts/Runtime/TypeSystem.js | 6 ---- .../TestCases/Basic/Minimization/Baseline.txt | 4 +-- tests/TestCases/Expression/Base/Baseline.txt | 4 +-- .../TestCases/Expression/Members/Baseline.txt | 2 +- tests/TestCases/Member/Indexers/Baseline.txt | 8 +++--- tests/TestCases/Type/Partials/Baseline.txt | 2 +- 8 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/Core/Compiler/Generator/ExpressionGenerator.cs b/src/Core/Compiler/Generator/ExpressionGenerator.cs index 796d4e430..f80610f05 100644 --- a/src/Core/Compiler/Generator/ExpressionGenerator.cs +++ b/src/Core/Compiler/Generator/ExpressionGenerator.cs @@ -43,11 +43,10 @@ private static void GenerateBinaryExpression(ScriptGenerator generator, MemberSy Debug.Assert(propExpression.Type == ExpressionType.PropertySet); if (propExpression.ObjectReference is BaseExpression) { - writer.Write("ss.base("); - writer.Write(generator.CurrentImplementation.ThisIdentifier); - writer.Write(", 'set_"); + writer.Write(((BaseExpression)propExpression.ObjectReference).EvaluatedType.FullGeneratedName); + writer.Write(".prototype.set_"); writer.Write(propExpression.Property.GeneratedName); - writer.Write("').call("); + writer.Write(".call("); writer.Write(generator.CurrentImplementation.ThisIdentifier); writer.Write(", "); GenerateExpression(generator, symbol, expression.RightOperand); @@ -71,11 +70,10 @@ private static void GenerateBinaryExpression(ScriptGenerator generator, MemberSy Debug.Assert(indexExpression.Type == ExpressionType.Indexer); if (indexExpression.ObjectReference is BaseExpression) { - writer.Write("ss.base("); - writer.Write(generator.CurrentImplementation.ThisIdentifier); - writer.Write(", 'set_"); + writer.Write(((BaseExpression)indexExpression.ObjectReference).EvaluatedType.FullGeneratedName); + writer.Write(".prototype.set_"); writer.Write(indexExpression.Indexer.GeneratedName); - writer.Write("').call("); + writer.Write(".call("); writer.Write(generator.CurrentImplementation.ThisIdentifier); writer.Write(", "); GenerateExpressionList(generator, symbol, indexExpression.Indices); @@ -478,11 +476,10 @@ private static void GenerateIndexerExpression(ScriptGenerator generator, MemberS writer.Write("]"); } else if (expression.ObjectReference is BaseExpression) { - writer.Write("ss.base("); - writer.Write(generator.CurrentImplementation.ThisIdentifier); - writer.Write(", 'get_"); + writer.Write(((BaseExpression)expression.ObjectReference).EvaluatedType.FullGeneratedName); + writer.Write(".prototype.get_"); writer.Write(expression.Indexer.GeneratedName); - writer.Write("').call("); + writer.Write(".call("); writer.Write(generator.CurrentImplementation.ThisIdentifier); writer.Write(", "); GenerateExpressionList(generator, symbol, expression.Indices); @@ -707,11 +704,10 @@ private static void GenerateMethodExpression(ScriptGenerator generator, MemberSy if (expression.ObjectReference is BaseExpression) { Debug.Assert(expression.Method.IsExtension == false); - writer.Write("ss.base("); - writer.Write(generator.CurrentImplementation.ThisIdentifier); - writer.Write(", '"); + writer.Write(((BaseExpression)expression.ObjectReference).EvaluatedType.FullGeneratedName); + writer.Write(".prototype."); writer.Write(expression.Method.GeneratedName); - writer.Write("').call("); + writer.Write(".call("); writer.Write(generator.CurrentImplementation.ThisIdentifier); if ((expression.Parameters != null) && (expression.Parameters.Count != 0)) { writer.Write(", "); diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index 4fa0d4d37..beba55767 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -95,7 +95,6 @@ safeCast: safeCast, canAssign: canAssign, instanceOf: instanceOf, - base: base, culture: { neutral: neutralCulture, diff --git a/src/Core/Scripts/Runtime/TypeSystem.js b/src/Core/Scripts/Runtime/TypeSystem.js index c478b92ff..5bf79bcfc 100644 --- a/src/Core/Scripts/Runtime/TypeSystem.js +++ b/src/Core/Scripts/Runtime/TypeSystem.js @@ -153,12 +153,6 @@ function safeCast(instance, type) { return instanceOf(type, instance) ? instance : null; } -function base(instanceOrType, method) { - var baseType = instanceOrType.constructor.$base || instanceOrType.$base; - var m = baseType.prototype[method]; - return m !== instanceOrType[method] ? m : base(baseType, method); -} - function module(name, implementation, exports) { var registry = _modules[name] = { $name: name }; diff --git a/tests/TestCases/Basic/Minimization/Baseline.txt b/tests/TestCases/Basic/Minimization/Baseline.txt index cf463a71c..daf9da6f6 100644 --- a/tests/TestCases/Basic/Minimization/Baseline.txt +++ b/tests/TestCases/Basic/Minimization/Baseline.txt @@ -173,7 +173,7 @@ define('test', ['ss', 'lib'], function(ss, lib) { }, $0: function() { this.$2(); - ss.base(this, '$0').call(this); + Bar2.prototype.$0.call(this); var d = MyData('a', 'b'); d.$0 = d.$1; }, @@ -273,7 +273,7 @@ define('test', ['ss', 'lib'], function(ss, lib) { }, dispose: function() { this.c$0 = 0; - ss.base(this, 'dispose').call(this); + lib.Behavior.prototype.dispose.call(this); }, c$6: function() { }, diff --git a/tests/TestCases/Expression/Base/Baseline.txt b/tests/TestCases/Expression/Base/Baseline.txt index 60080165b..8c8ee0fd1 100644 --- a/tests/TestCases/Expression/Base/Baseline.txt +++ b/tests/TestCases/Expression/Base/Baseline.txt @@ -24,10 +24,10 @@ define('test', ['ss'], function(ss) { } var Bar$ = { sum: function() { - return ss.base(this, 'sum').call(this, 1) + 1; + return Foo.prototype.sum.call(this, 1) + 1; }, toString: function() { - return ss.base(this, 'toString').call(this) + ' -> Bar'; + return Foo.prototype.toString.call(this) + ' -> Bar'; } }; diff --git a/tests/TestCases/Expression/Members/Baseline.txt b/tests/TestCases/Expression/Members/Baseline.txt index 609890cbb..cf65cc0ef 100644 --- a/tests/TestCases/Expression/Members/Baseline.txt +++ b/tests/TestCases/Expression/Members/Baseline.txt @@ -70,7 +70,7 @@ define('test', ['ss'], function(ss) { n = App$.get_XYZ.call(this); this.set_XYZ(n); this.set_XYZ(n); - ss.base(this, 'set_XYZ').call(this, n); + App.prototype.set_XYZ.call(this, n); this._value2 = n; this._value2 = n; this._value2 = n; diff --git a/tests/TestCases/Member/Indexers/Baseline.txt b/tests/TestCases/Member/Indexers/Baseline.txt index a4db55dd7..3c2065171 100644 --- a/tests/TestCases/Member/Indexers/Baseline.txt +++ b/tests/TestCases/Member/Indexers/Baseline.txt @@ -133,15 +133,15 @@ define('test', ['ss'], function(ss) { VirtualIndexer.call(this); var i = this.get_item('name'); this.set_item('name', i + 1); - var j = ss.base(this, 'get_item').call(this, 'name'); - ss.base(this, 'set_item').call(this, 'name', 43); + var j = VirtualIndexer.prototype.get_item.call(this, 'name'); + VirtualIndexer.prototype.set_item.call(this, 'name', 43); } var OverriddenIndexer$ = { get_item: function(name) { - return ss.base(this, 'get_item').call(this, name) + 1; + return VirtualIndexer.prototype.get_item.call(this, name) + 1; }, set_item: function(name, value) { - ss.base(this, 'set_item').call(this, name, value - 1); + VirtualIndexer.prototype.set_item.call(this, name, value - 1); return value; } }; diff --git a/tests/TestCases/Type/Partials/Baseline.txt b/tests/TestCases/Type/Partials/Baseline.txt index 968a6db33..11d256e6c 100644 --- a/tests/TestCases/Type/Partials/Baseline.txt +++ b/tests/TestCases/Type/Partials/Baseline.txt @@ -112,7 +112,7 @@ define('test', ['ss'], function(ss) { var e1 = document.getElementById(this.bar); var e2 = document.getElementById(this.name); var e3 = document.getElementById(this.bar); - var s = this.testMethod() + ss.base(this, 'testMethod').call(this); + var s = this.testMethod() + MergedMembersClass.prototype.testMethod.call(this); }, get_item: function(s) { return s; From c4a03cfdfca696bfe67a3989e400f39d844fba20 Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Wed, 19 Jun 2013 08:39:36 -0500 Subject: [PATCH 26/35] Add ImportNode() to XmlDocument. --- src/Libraries/Web/Xml/XmlDocument.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Libraries/Web/Xml/XmlDocument.cs b/src/Libraries/Web/Xml/XmlDocument.cs index d196825f3..2629072e9 100644 --- a/src/Libraries/Web/Xml/XmlDocument.cs +++ b/src/Libraries/Web/Xml/XmlDocument.cs @@ -59,5 +59,9 @@ public XmlNode CreateProcessingInstruction(string target, string data) { public XmlText CreateTextNode(string text) { return null; } + + public XmlNode ImportNode(XmlNode externalNode, bool deep) { + return null; + } } } From 5e900e785741a3e51d02237b5acd7f1fbc9d9767 Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Wed, 19 Jun 2013 08:43:46 -0500 Subject: [PATCH 27/35] Add ImportNode() to XmlDocument. --- src/Libraries/Web/Xml/XmlDocument.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Libraries/Web/Xml/XmlDocument.cs b/src/Libraries/Web/Xml/XmlDocument.cs index d196825f3..2629072e9 100644 --- a/src/Libraries/Web/Xml/XmlDocument.cs +++ b/src/Libraries/Web/Xml/XmlDocument.cs @@ -59,5 +59,9 @@ public XmlNode CreateProcessingInstruction(string target, string data) { public XmlText CreateTextNode(string text) { return null; } + + public XmlNode ImportNode(XmlNode externalNode, bool deep) { + return null; + } } } From 87cc02ed8106fa8b25c1852d11e24a0208fb230d Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Wed, 19 Jun 2013 09:17:42 -0500 Subject: [PATCH 28/35] Remove problematic optimization for local base class properties. --- src/Core/Compiler/Generator/ExpressionGenerator.cs | 8 +------- tests/TestCases/Expression/Members/Baseline.txt | 2 +- tests/TestCases/Member/Properties/Baseline.txt | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Core/Compiler/Generator/ExpressionGenerator.cs b/src/Core/Compiler/Generator/ExpressionGenerator.cs index 796d4e430..e6c9d44a6 100644 --- a/src/Core/Compiler/Generator/ExpressionGenerator.cs +++ b/src/Core/Compiler/Generator/ExpressionGenerator.cs @@ -860,13 +860,7 @@ private static void GeneratePropertyExpression(ScriptGenerator generator, Member Debug.Assert(baseClass != null); writer.Write(baseClass.FullGeneratedName); - if (baseClass.IsApplicationType) { - writer.Write("$."); - } - else { - writer.Write(".prototype."); - } - writer.Write("get_"); + writer.Write(".prototype.get_"); writer.Write(expression.Property.GeneratedName); writer.Write(".call("); writer.Write(generator.CurrentImplementation.ThisIdentifier); diff --git a/tests/TestCases/Expression/Members/Baseline.txt b/tests/TestCases/Expression/Members/Baseline.txt index 609890cbb..f5b380079 100644 --- a/tests/TestCases/Expression/Members/Baseline.txt +++ b/tests/TestCases/Expression/Members/Baseline.txt @@ -67,7 +67,7 @@ define('test', ['ss'], function(ss) { test2: function() { var n = this.get_XYZ(); n = this.get_XYZ(); - n = App$.get_XYZ.call(this); + n = App.prototype.get_XYZ.call(this); this.set_XYZ(n); this.set_XYZ(n); ss.base(this, 'set_XYZ').call(this, n); diff --git a/tests/TestCases/Member/Properties/Baseline.txt b/tests/TestCases/Member/Properties/Baseline.txt index 9c8678a95..88c797959 100644 --- a/tests/TestCases/Member/Properties/Baseline.txt +++ b/tests/TestCases/Member/Properties/Baseline.txt @@ -41,7 +41,7 @@ define('test', ['ss'], function(ss) { function Test2() { Test.call(this); - var n = Test$.get_XYZ.call(this); + var n = Test.prototype.get_XYZ.call(this); if (n === this.get_XYZ()) { } if (this.get_XYZ() === n) { From 1d33e49057f6e198df8f83ce01b7801441115461 Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Fri, 21 Jun 2013 09:34:32 -0500 Subject: [PATCH 29/35] When a compilation error occurs, fail any of the tests that are based on that compilation. --- tests/Core/BrowserTest.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/Core/BrowserTest.cs b/tests/Core/BrowserTest.cs index 5b450750a..d807e7f4e 100644 --- a/tests/Core/BrowserTest.cs +++ b/tests/Core/BrowserTest.cs @@ -22,6 +22,7 @@ public abstract class BrowserTest { private static readonly string[] _codeFiles = new string[] { "OOP.cs" }; + private static string _compilationFailures; private const int _port = 3976; @@ -40,16 +41,24 @@ static BrowserTest() { File.Copy(Path.Combine(binDirectory, script), Path.Combine(scriptsDirectory, script), overwrite: true); } + List codeFailures = new List(); + string mscorlibPath = Path.Combine(binDirectory, "mscorlib.dll"); foreach (string codeFile in _codeFiles) { string script = Path.GetFileNameWithoutExtension(codeFile) + Path.ChangeExtension(".cs", ".js"); SimpleCompilation compilation = new SimpleCompilation(Path.Combine(scriptsDirectory, script)); - compilation.AddReference(mscorlibPath) + bool result = compilation.AddReference(mscorlibPath) .AddSource(Path.Combine(codeDirectory, codeFile)) .Execute(); + + if (!result) { + codeFailures.Add(codeFile); + } } + _compilationFailures = (codeFailures.Count == 0) ? null : string.Join(", ", codeFailures); + _webTest = new WebTest(); _webTest.StartWebServer(_port, webRoot); } @@ -64,6 +73,11 @@ public TestContext TestContext { } protected void RunTest(string url) { + if (_compilationFailures != null) { + Assert.Fail("Could not run test due to compilation failure of " + _compilationFailures + "."); + return; + } + Uri testUri = _webTest.GetTestUri(url); WebTestResult result = _webTest.RunTest(testUri, WebBrowser.Chrome); From 7602db379c2a1809dd7146b1140ee51aa6c2c44c Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Fri, 21 Jun 2013 09:53:28 -0500 Subject: [PATCH 30/35] Add tests for base methods, properties, and indexes. --- tests/ScriptTests.cs | 5 ++ tests/TestSite/Bases.htm | 45 +++++++++++ tests/TestSite/Code/OOP.cs | 151 +++++++++++++++++++++++++++++++++++-- 3 files changed, 194 insertions(+), 7 deletions(-) create mode 100644 tests/TestSite/Bases.htm diff --git a/tests/ScriptTests.cs b/tests/ScriptTests.cs index e64325083..6ea00bfb1 100644 --- a/tests/ScriptTests.cs +++ b/tests/ScriptTests.cs @@ -22,6 +22,11 @@ public void TestTypeSystem() { RunTest("/TypeSystem.htm"); } + [TestMethod] + public void TestBases() { + RunTest("/Bases.htm"); + } + #region Loader Tests [TestMethod] public void TestLoader() { diff --git a/tests/TestSite/Bases.htm b/tests/TestSite/Bases.htm new file mode 100644 index 000000000..a90ed09b5 --- /dev/null +++ b/tests/TestSite/Bases.htm @@ -0,0 +1,45 @@ + + + + Bases + + + + + +

Test Results

+

+

+
    +
    + + + + + + + + + diff --git a/tests/TestSite/Code/OOP.cs b/tests/TestSite/Code/OOP.cs index 1b5d7b415..e6c0a0241 100644 --- a/tests/TestSite/Code/OOP.cs +++ b/tests/TestSite/Code/OOP.cs @@ -9,22 +9,22 @@ namespace Test { public interface IMammal { } - + public interface IPet { - + string Name { get; } - + string Owner { get; } } - + public class Animal { - + private string _species; - + public Animal(string species) { _species = species; } @@ -104,7 +104,7 @@ public string Name { return _name; } } - + public ICharacter Star { get { return _star; @@ -121,3 +121,140 @@ public interface IObject { public class Zoo { } } + + +namespace Test.Bases { + + // A series of classes with different combinations of overrides at different + // levels in the class hierarchy. Tests issues #379, #384 as applied to properties, + // methods, and index operators. + + public class C1 { + private string _valueA = "A"; + + public virtual string PropertyA { + get { + return _valueA + "-PC1"; + } + set { + _valueA = value + "+PC1"; + } + } + + public virtual string MethodA() { + return _valueA + "-MC1"; + } + + public virtual string this[int key] { + get { + return _valueA + "-" + key.ToString() + "IC1"; + } + set { + _valueA = value + "+" + key.ToString() + "IC1"; + } + } + } + + public class C2 : C1 { + public override string PropertyA { + get { + return base.PropertyA + "-PC2"; + } + set { + base.PropertyA = value + "+PC2"; + } + } + + public override string MethodA() { + return base.MethodA() + "-MC2"; + } + + public override string this[int key] { + get { + return base[key] + "-" + key.ToString() + "IC2"; + } + set { + base[key] = value + "+" + key.ToString() + "IC2"; + } + } + } + + public class C3 : C2 { + public override string PropertyA { + get { + return base.PropertyA + "-PC3"; + } + set { + base.PropertyA = value + "+PC3"; + } + } + + public override string MethodA() { + return base.MethodA() + "-MC3"; + } + + public override string this[int key] { + get { + return base[key] + "-" + key.ToString() + "IC3"; + } + set { + base[key] = value + "+" + key.ToString() + "IC3"; + } + } + } + + public class C4 : C3 { + // intentionally skip this generation of overrides + } + + public class C5 : C4 { + public override string PropertyA { + get { + return base.PropertyA + "-PC5"; + } + set { + base.PropertyA = value + "+PC5"; + } + } + + public override string MethodA() { + return base.MethodA() + "-MC5"; + } + + public override string this[int key] { + get { + return base[key] + "-" + key.ToString() + "IC5"; + } + set { + base[key] = value + "+" + key.ToString() + "IC5"; + } + } + } + + public class TestCase { + + public static string RunTest(C1 x) { + string output = ""; + string delim = ","; + + // Test getter, method, and index (should accumulate outward through bases) + output = x.PropertyA + + delim + x.MethodA() + + delim + x[99]; + + // Test property setter (should accumulate inward and outward through bases) + + x.PropertyA = "X"; + output += delim + x.PropertyA; + + // Test index setter (should accumulate inward and outward through bases) + + x[88] = "Y"; + output += delim + x[99]; + + return output; + } + + } + +} From 66bf380983bc14e3ed3286cfa649cc1f9d3b9988 Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Fri, 21 Jun 2013 09:57:20 -0500 Subject: [PATCH 31/35] Fix some whitespace. --- tests/TestSite/Code/OOP.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/TestSite/Code/OOP.cs b/tests/TestSite/Code/OOP.cs index e6c0a0241..7891e84ef 100644 --- a/tests/TestSite/Code/OOP.cs +++ b/tests/TestSite/Code/OOP.cs @@ -9,22 +9,22 @@ namespace Test { public interface IMammal { } - + public interface IPet { - + string Name { get; } - + string Owner { get; } } - + public class Animal { - + private string _species; - + public Animal(string species) { _species = species; } @@ -104,7 +104,7 @@ public string Name { return _name; } } - + public ICharacter Star { get { return _star; From 4fac58c3c005080a8b1c91e70f1db00e105f895e Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Fri, 21 Jun 2013 14:06:36 -0500 Subject: [PATCH 32/35] Add missing namespaced methods to Html.Document. And ImportNode. --- src/Libraries/Web/Html/Document.cs | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/Libraries/Web/Html/Document.cs b/src/Libraries/Web/Html/Document.cs index b4790206e..957266017 100644 --- a/src/Libraries/Web/Html/Document.cs +++ b/src/Libraries/Web/Html/Document.cs @@ -148,18 +148,53 @@ public static void AddEventListener(string eventName, ElementEventListener liste public static void AttachEvent(string eventName, ElementEventHandler handler) { } + /// + /// Creates an Attr of the given name. Note that the Attr instance can then be set on an + /// Element using the setAttributeNode method. To create an attribute with a qualified name + /// and namespace URI, use the CreateAttributeNS method. + /// + /// The name of the attribute. + /// A new Attr object with the nodeName attribute set to name, and localName, prefix, + /// and namespaceURI set to null. The value of the attribute is the empty string. public static ElementAttribute CreateAttribute(string name) { return null; } + /// + /// Creates an attribute of the given qualified name and namespace URI. + /// + /// The namespace URI of the attribute to create. + /// The qualified name of the attribute to instantiate. + /// A new Attr object with the given namespace and qualified name. + public static ElementAttribute CreateAttributeNS(string namespaceURI, string qualifiedName) { + return null; + } + public static DocumentFragment CreateDocumentFragment() { return null; } + /// + /// Creates an element of the type specified. + /// To create an element with a qualified name and namespace URI, use the CreateElementNS method. + /// + /// The name of the element type to instantiate. + /// A new Element object with the nodeName attribute set to tagName, and localName, + /// prefix, and namespaceURI set to null. public static Element CreateElement(string tagName) { return null; } + /// + /// Creates an element of the given qualified name and namespace URI. + /// + /// The namespace URI of the element to create. + /// The qualified name of the element type to instantiate. + /// A new Element object with the given namespace and qualified name. + public static Element CreateElementNS(string namespaceURI, string qualifiedName) { + return null; + } + public static MutableEvent CreateEvent(string eventType) { return null; } @@ -168,6 +203,10 @@ public static Element CreateTextNode(string data) { return null; } + public static Element ImportNode(Element imporedNode, bool deep) { + return null; + } + public static void DetachEvent(string eventName, ElementEventHandler handler) { } @@ -206,6 +245,16 @@ public static ElementCollection GetElementsByTagName(string tagName) { return null; } + /// + /// Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree. + /// + /// The namespace URI of the elements to match on. The special value "*" matches all namespaces. + /// The local name of the elements to match on. The special value "*" matches all local names. + /// A new NodeList object containing all the matched Elements. + public static ElementCollection GetElementsByTagNameNS(string namespaceURI, string localName) { + return null; + } + public static bool HasFocus() { return false; } From 0e3f288247a38d4930570fcc6951895de562606e Mon Sep 17 00:00:00 2001 From: Nikhil Kothari Date: Sun, 23 Jun 2013 17:06:50 -0600 Subject: [PATCH 33/35] Minor formatting changes --- tests/Core/BrowserTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Core/BrowserTest.cs b/tests/Core/BrowserTest.cs index d807e7f4e..2dc75d4ab 100644 --- a/tests/Core/BrowserTest.cs +++ b/tests/Core/BrowserTest.cs @@ -49,15 +49,15 @@ static BrowserTest() { SimpleCompilation compilation = new SimpleCompilation(Path.Combine(scriptsDirectory, script)); bool result = compilation.AddReference(mscorlibPath) - .AddSource(Path.Combine(codeDirectory, codeFile)) - .Execute(); + .AddSource(Path.Combine(codeDirectory, codeFile)) + .Execute(); - if (!result) { + if (result == false) { codeFailures.Add(codeFile); } } - _compilationFailures = (codeFailures.Count == 0) ? null : string.Join(", ", codeFailures); + _compilationFailures = (codeFailures.Count == 0) ? null : String.Join(", ", codeFailures); _webTest = new WebTest(); _webTest.StartWebServer(_port, webRoot); From 26dc5645b86946c7a01edf16d2dc18e3f3720be4 Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Fri, 23 Aug 2013 11:51:08 -0500 Subject: [PATCH 34/35] NodeApi.IO.Buffer.Length should be a simple property accessor. --- src/Libraries/Node/Node.Core/IO/Buffer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Libraries/Node/Node.Core/IO/Buffer.cs b/src/Libraries/Node/Node.Core/IO/Buffer.cs index b2c81f3ae..3b8c1de6a 100644 --- a/src/Libraries/Node/Node.Core/IO/Buffer.cs +++ b/src/Libraries/Node/Node.Core/IO/Buffer.cs @@ -24,6 +24,7 @@ public Buffer(string data) { public Buffer(string data, Encoding encoding) { } + [ScriptField] public int Length { get { return 0; From 9b4780f03e7b1169c43df337ed8f20c14f089e4e Mon Sep 17 00:00:00 2001 From: Mark Stega Date: Mon, 18 Nov 2013 09:22:45 -0500 Subject: [PATCH 35/35] Added VS2013 target --- src/ZipX/VSIX/Extension.vsixmanifest | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ZipX/VSIX/Extension.vsixmanifest b/src/ZipX/VSIX/Extension.vsixmanifest index d8ed80ae0..459fd8d27 100644 --- a/src/ZipX/VSIX/Extension.vsixmanifest +++ b/src/ZipX/VSIX/Extension.vsixmanifest @@ -29,6 +29,13 @@ VCSExpress VWDExpress + + Ultimate + Premium + Pro + VCSExpress + VWDExpress +