Skip to content

Commit

Permalink
updating code
Browse files Browse the repository at this point in the history
  • Loading branch information
agracio committed Apr 29, 2024
1 parent 6f482f7 commit d3dddd3
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ https://github.com/agracio/edge-js

1. Install dependencies `npm install`
2. Build `src\QuickStart.sln` by running `dotnet build src/QuickStart.sln`
3. To run the app using .NET Core use `npm start` or `npm run start:core`
3. To run the app using .NET Core use `npm start`
4. To run the app using .NET Standard use `npm run start:standard`
45 changes: 24 additions & 21 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');
var net = process.argv[2];
var namespace = 'QuickStart.' + net.charAt(0).toUpperCase() + net.substr(1);
var framework = net.charAt(0).toUpperCase() + net.substr(1);
var namespace = 'QuickStart.' + framework;
if(net === 'core') net = '';
var version = net == 'standard' ? '2.0' : '7.0'

Expand Down Expand Up @@ -61,28 +62,30 @@ var listCertificates = edge.func({
var getInlinePerson = edge.func({
source: function () {/*
using System.Threading.Tasks;
using System;
public class Person
public class Person
{
public Person(string name, string email, int age)
{
public Person(string name, string email, int age)
{
Name = name;
Email = email;
Age = age;
}
public string Name {get;set;}
public string Email {get;set;}
public int Age {get;set;}
Id = Guid.NewGuid();
Name = name;
Email = email;
Age = age;
}
public class Startup
public Guid Id {get;}
public string Name {get;set;}
public string Email {get;set;}
public int Age {get;set;}
}
public class Startup
{
public async Task<object> Invoke(dynamic input)
{
public async Task<object> Invoke(dynamic input)
{
Person person = new Person(input.name, input.email, input.age);
return person;
}
}
return new Person(input.name, input.email, input.age);
}
}
*/}
});

Expand Down Expand Up @@ -113,7 +116,7 @@ getCurrentTime('', function(error, result) {
console.log();
});

useDynamicInput('Node.Js', function(error, result) {
useDynamicInput({framework: framework, node: 'Node.Js'}, function(error, result) {
if (error) throw error;
console.log(localTypeName + '.UseDynamicInput');
console.log(result);
Expand Down Expand Up @@ -142,7 +145,7 @@ try{
console.log();
console.log('### Calling external library methods using '+ namespace +'.dll wrapper');
console.log();
getPerson('', function(error, result) {
getPerson({name: 'John Smith', email: '[email protected]', age: 35}, function(error, result) {
if (error) throw error;
console.log(externalTypeName + '.GetPersonInfo');
console.log(result);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"main": "main.js",
"scripts": {
"start": "node main.js core",
"start:core": "node main.js core",
"start:standard": "node main.js standard"
},
"repository": "https://github.com/agracio/edge-js-quick-start",
Expand All @@ -15,7 +14,8 @@
"tutorial",
"demo",
"Edge",
"Edge.js"
"Edge.js",
"edge-js"
],
"license": "MIT",
"dependencies": {
Expand Down
4 changes: 4 additions & 0 deletions src/ExternalLibrary/ExternalLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>

</Project>
19 changes: 9 additions & 10 deletions src/ExternalLibrary/Libarary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ namespace ExternalLibrary
{
public class Person
{
public Guid Id => Guid.NewGuid();
public string Name => "John Smith";
public string Email => "[email protected]";

}

public class Library
{
public Person GetPerson()
public Person(string name, string email, int age)
{
return new Person();
Id = Guid.NewGuid();
Name = name;
Email = email;
Age = age;
}
public Guid Id {get;}
public string Name {get;}
public string Email {get;}
public int Age {get;}
}
}
2 changes: 1 addition & 1 deletion src/QuickStart.Core/QuickStart.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.9.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/QuickStart.Standard/QuickStart.Standard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.9.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
</ItemGroup>
Expand Down
5 changes: 1 addition & 4 deletions src/shared/ExternalLibarary.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
using System.Threading.Tasks;
using ExternalLibrary;
using Newtonsoft.Json;

namespace QuickStart
{
class ExternalMethods
{
private readonly Library _library = new Library();

public async Task<object> GetPersonInfo(dynamic input)
{
return await Task.Run(() =>JsonConvert.SerializeObject(_library.GetPerson(), Formatting.Indented));
return await Task.Run(() => new Person(input.name, input.email, input.age));
}
}
}
2 changes: 1 addition & 1 deletion src/shared/LocalMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task<object> GetCurrentTime(dynamic input)

public async Task<object> UseDynamicInput(dynamic input)

Check warning on line 22 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (macos-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 22 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (macos-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 22 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (macos-14)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 22 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (macos-14)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 22 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (ubuntu-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 22 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (ubuntu-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 22 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (windows-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 22 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (windows-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
return $".NET Standard welcomes {input}";
return $".NET {input.framework} welcomes {input.node}";
}
public async Task<object> ThrowException(dynamic input)

Check warning on line 26 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (macos-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 26 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (macos-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 26 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (macos-14)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 26 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (macos-14)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 26 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (ubuntu-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 26 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (ubuntu-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 26 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (windows-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 26 in src/shared/LocalMethods.cs

View workflow job for this annotation

GitHub Actions / main (windows-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
Expand Down

0 comments on commit d3dddd3

Please sign in to comment.