This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new 69dd806  .NET Core 2.2 Runtime (#4172)
69dd806 is described below

commit 69dd806480fc4743e9dba04f2f1026e60c384755
Author: Shawn Black <[email protected]>
AuthorDate: Fri Dec 14 05:47:57 2018 -0600

    .NET Core 2.2 Runtime (#4172)
---
 ansible/files/runtimes.json                        |  17 ++++
 .../src/main/resources/apiv1swagger.json           |   3 +-
 docs/actions-dotnet.md                             | 107 +++++++++++++++++++++
 docs/actions.md                                    |   1 +
 tests/dat/actions/unicode.tests/dotnet-2.2.bin     | Bin 0 -> 676736 bytes
 .../Apache.OpenWhisk.UnicodeTests.Dotnet.csproj    |  27 ++++++
 .../Unicode.cs                                     |  35 +++++++
 .../dotnet2.2/openwhisk-unicodetests-dotnet.sln    |  33 +++++++
 .../test/scala/system/basic/WskUnicodeTests.scala  |   4 +-
 9 files changed, 225 insertions(+), 2 deletions(-)

diff --git a/ansible/files/runtimes.json b/ansible/files/runtimes.json
index 9bc28df..6a47db3 100644
--- a/ansible/files/runtimes.json
+++ b/ansible/files/runtimes.json
@@ -238,6 +238,23 @@
                     "tag": "latest"
                 }
             }
+        ],
+        "dotnet": [
+            {
+                "kind": "dotnet:2.2",
+                "default": true,
+                "deprecated": false,
+                "requireMain": true,
+                "image": {
+                    "prefix": "openwhisk",
+                    "name": "action-dotnet-v2.2",
+                    "tag": "latest"
+                },
+                "attached": {
+                    "attachmentName": "codefile",
+                    "attachmentType": "text/plain"
+                }
+            }
         ]
     },
     "blackboxes": [
diff --git a/core/controller/src/main/resources/apiv1swagger.json 
b/core/controller/src/main/resources/apiv1swagger.json
index cefdb99..9596867 100644
--- a/core/controller/src/main/resources/apiv1swagger.json
+++ b/core/controller/src/main/resources/apiv1swagger.json
@@ -1902,7 +1902,8 @@
                         "go:1.11",
                         "sequence",
                         "swift:3.1.1",
-                        "swift:4.1"
+                        "swift:4.1",
+                        "dotnet:2.2"
                     ],
                     "description": "the type of action"
                 },
diff --git a/docs/actions-dotnet.md b/docs/actions-dotnet.md
new file mode 100644
index 0000000..2e96b97
--- /dev/null
+++ b/docs/actions-dotnet.md
@@ -0,0 +1,107 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Creating and invoking .NET Core actions
+
+The following sections guide you through creating and invoking a single .NET 
Core action.
+
+In order to compile, test and archive .NET Core projects, you must have the 
[.NET Core SDK](https://www.microsoft.com/net/download) installed locally and 
the environment variable `DOTNET_HOME` set to the location where the `dotnet` 
executable can be found.
+
+A .NET Core action is a .NET Core class library with a method called `Main` 
that has the exact signature as follows:
+
+```csharp
+public Newtonsoft.Json.Linq.JObject Main(Newtonsoft.Json.Linq.JObject);
+```
+
+For example, create a C# project called `Apache.OpenWhisk.Example.Dotnet`:
+
+```bash
+dotnet new classlib -n Apache.OpenWhisk.Example.Dotnet -lang "C#"
+cd Apache.OpenWhisk.Example.Dotnet
+```
+
+Install the [Newtonsoft.Json](https://www.newtonsoft.com/json) NuGet package 
as follows:
+
+```bash
+dotnet add package Newtonsoft.Json -v 12.0.1
+```
+
+Now create a file called `Hello.cs` with the following content:
+
+```csharp
+using System;
+using Newtonsoft.Json.Linq;
+
+namespace Apache.OpenWhisk.Example.Dotnet
+{
+    public class Hello
+    {
+        public JObject Main(JObject args)
+        {
+            string name = "stranger";
+            if (args.ContainsKey("name")) {
+                name = args["name"].ToString();
+            }
+            JObject message = new JObject();
+            message.Add("greeting", new JValue($"Hello, {name}!"));
+            return (message);
+        }
+    }
+}
+```
+
+Publish the project as follows:
+
+```bash
+dotnet publish -c Release -o out
+```
+
+Zip the published files as follows:
+
+```bash
+cd out
+zip -r -0 helloDotNet.bin *
+```
+
+### Create the .NET Core Action
+
+You need to specify the name of the function handler using `--main` argument.
+The value for `main` needs to be in the following format:
+`{Assembly}::{Class Full Name}::{Method}`, e.q.,
+`Apache.OpenWhisk.Example.Dotnet::Apache.OpenWhisk.Example.Dotnet.Hello::Main`
+
+To use on a deployment of OpenWhisk that contains the runtime as a kind:
+
+```bash
+wsk action update helloDotNet helloDotNet.bin --main 
Apache.OpenWhisk.Example.Dotnet::Apache.OpenWhisk.Example.Dotnet.Hello::Main 
--kind dotnet:2.2
+```
+
+### Invoke the .NET Core Action
+
+Action invocation is the same for .NET Core actions as it is for Swift and 
JavaScript actions:
+
+```bash
+wsk action invoke --result helloDotNet --param name World
+```
+
+```json
+  {
+      "greeting": "Hello World!"
+  }
+```
diff --git a/docs/actions.md b/docs/actions.md
index b181ad6..f03e708 100644
--- a/docs/actions.md
+++ b/docs/actions.md
@@ -61,6 +61,7 @@ paths more suitable. Or, you can [create a new 
runtime](actions-new.md).
 * [Python](actions-python.md)
 * [Ruby](actions-ruby.md)
 * [Swift](actions-swift.md)
+* [.NET Core](actions-dotnet.md)
 * [Docker and native binaries](actions-docker.md)
 
 Multiple actions from different languages may be composed together to create a 
longer processing
diff --git a/tests/dat/actions/unicode.tests/dotnet-2.2.bin 
b/tests/dat/actions/unicode.tests/dotnet-2.2.bin
new file mode 100644
index 0000000..f3949ee
Binary files /dev/null and b/tests/dat/actions/unicode.tests/dotnet-2.2.bin 
differ
diff --git 
a/tests/dat/actions/unicode.tests/src/dotnet2.2/Apache.OpenWhisk.UnicodeTests.Dotnet/Apache.OpenWhisk.UnicodeTests.Dotnet.csproj
 
b/tests/dat/actions/unicode.tests/src/dotnet2.2/Apache.OpenWhisk.UnicodeTests.Dotnet/Apache.OpenWhisk.UnicodeTests.Dotnet.csproj
new file mode 100644
index 0000000..c67fa66
--- /dev/null
+++ 
b/tests/dat/actions/unicode.tests/src/dotnet2.2/Apache.OpenWhisk.UnicodeTests.Dotnet/Apache.OpenWhisk.UnicodeTests.Dotnet.csproj
@@ -0,0 +1,27 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<Project Sdk="Microsoft.NET.Sdk">
+
+    <PropertyGroup>
+        <TargetFramework>netcoreapp2.2</TargetFramework>
+    </PropertyGroup>
+
+    <ItemGroup>
+      <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
+    </ItemGroup>
+
+</Project>
diff --git 
a/tests/dat/actions/unicode.tests/src/dotnet2.2/Apache.OpenWhisk.UnicodeTests.Dotnet/Unicode.cs
 
b/tests/dat/actions/unicode.tests/src/dotnet2.2/Apache.OpenWhisk.UnicodeTests.Dotnet/Unicode.cs
new file mode 100644
index 0000000..6963b86
--- /dev/null
+++ 
b/tests/dat/actions/unicode.tests/src/dotnet2.2/Apache.OpenWhisk.UnicodeTests.Dotnet/Unicode.cs
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Newtonsoft.Json.Linq;
+
+namespace Apache.OpenWhisk.UnicodeTests.Dotnet
+{
+    public class Unicode
+    {
+        public JObject Main(JObject args)
+        {
+            string delimiter = args["delimiter"].ToString();
+            JObject message = new JObject();
+            string output = $"{delimiter} ☃ {delimiter}";
+            message.Add("winter", new JValue(output));
+            Console.WriteLine(output);
+            return (message);
+        }
+    }
+}
\ No newline at end of file
diff --git 
a/tests/dat/actions/unicode.tests/src/dotnet2.2/openwhisk-unicodetests-dotnet.sln
 
b/tests/dat/actions/unicode.tests/src/dotnet2.2/openwhisk-unicodetests-dotnet.sln
new file mode 100644
index 0000000..92e2e06
--- /dev/null
+++ 
b/tests/dat/actions/unicode.tests/src/dotnet2.2/openwhisk-unicodetests-dotnet.sln
@@ -0,0 +1,33 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = 
"Apache.OpenWhisk.UnicodeTests.Dotnet", 
"Apache.OpenWhisk.UnicodeTests.Dotnet\Apache.OpenWhisk.UnicodeTests.Dotnet.csproj",
 "{B905FD2E-6975-411E-B139-36747747F524}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Any CPU = Debug|Any CPU
+               Release|Any CPU = Release|Any CPU
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {B905FD2E-6975-411E-B139-36747747F524}.Debug|Any CPU.ActiveCfg 
= Debug|Any CPU
+               {B905FD2E-6975-411E-B139-36747747F524}.Debug|Any CPU.Build.0 = 
Debug|Any CPU
+               {B905FD2E-6975-411E-B139-36747747F524}.Release|Any 
CPU.ActiveCfg = Release|Any CPU
+               {B905FD2E-6975-411E-B139-36747747F524}.Release|Any CPU.Build.0 
= Release|Any CPU
+       EndGlobalSection
+EndGlobal
diff --git a/tests/src/test/scala/system/basic/WskUnicodeTests.scala 
b/tests/src/test/scala/system/basic/WskUnicodeTests.scala
index 611d8ba..3368051 100644
--- a/tests/src/test/scala/system/basic/WskUnicodeTests.scala
+++ b/tests/src/test/scala/system/basic/WskUnicodeTests.scala
@@ -52,7 +52,9 @@ class WskUnicodeTests extends TestHelpers with WskTestHelpers 
with JsHelpers wit
   def main(kind: String): Option[String] = {
     kind match {
       case "java" => Some("Unicode")
-      case _      => None
+      case s if (s.contains("dotnet")) =>
+        
Some("Apache.OpenWhisk.UnicodeTests.Dotnet::Apache.OpenWhisk.UnicodeTests.Dotnet.Unicode::Main")
+      case _ => None
     }
   }
 

Reply via email to