Skip to content

Commit

Permalink
improving assembly loader for .NET Core, minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
agracio committed May 3, 2024
1 parent 2855e9f commit 6df2fb7
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 150 deletions.
56 changes: 0 additions & 56 deletions .jshintrc

This file was deleted.

5 changes: 4 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ tools/*.cs
tools/*.vbs
tools/nuget
*.nupkg
appveyor.*
appveyor*.*
.github
tools/coverage.js
tools/test*.js
tools/download*.js
test/mochawesome-report
mochawesome-report
mochawesome.json
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,9 @@ In that case the default typeName of `My.Edge.Samples.Startup` and methodName of

### How to: specify additional CLR assembly references in C# code

When you provide C# source code and let edge compile it for you at runtime, edge will by default reference only mscorlib.dll and System.dll assemblies. If you're using .NET Core, we automatically reference the most recent versions of the System.Runtime, System.Threading.Tasks, System.Dynamic.Runtime, and the compiler language packages, like Microsoft.CSharp. In applications that require additional assemblies you can specify them in C# code using a special hash pattern, similar to Roslyn. For example, to use ADO.NET you must reference System.Data.dll:
When you provide C# source code and let edge compile it for you at runtime, edge will by default reference only mscorlib.dll and System.dll assemblies. If you're using .NET Core, we automatically reference the most recent versions of the System. Runtime, System.Threading.Tasks, and the compiler language packages, like Microsoft.CSharp. In applications that require additional assemblies you can specify them in C# code using a special hash pattern, similar to Roslyn. For example, to use ADO.NET you must reference System.Data.dll:

#### NOTE: `#r` and `references: [ 'MyDll.dll' ]` references only work when using .NET Framework 4.5

```javascript
var add7 = edge.func(function() {/*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "http://tomasz.janczuk.org",
"twitter": "tjanczuk"
},
"version": "21.7.4",
"version": "21.7.5",
"description": "Edge.js: run .NET and Node.js in-process on Windows, Mac OS, and Linux",
"tags": [
"owin",
Expand Down
81 changes: 57 additions & 24 deletions samples/203_x509store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,67 @@

var edge = require('../lib/edge');

var listCertificates = edge.func(function() {/*
#r "System.dll"
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
async (dynamic data) =>
{
X509Store store = new X509Store(
(string)data.storeName,
(StoreLocation)Enum.Parse(typeof(StoreLocation), (string)data.storeLocation));
store.Open(OpenFlags.ReadOnly);
try
// var listCertificates = edge.func(function() {/*
// //#r "System.Security.Cryptography"

// using System.Security.Cryptography;
// using System.Collections.Generic;
// using System.Security.Cryptography.X509Certificates;

// async (dynamic data) =>
// {
// X509Store store = new X509Store(
// (string)data.storeName,
// (StoreLocation)Enum.Parse(typeof(StoreLocation), (string)data.storeLocation));
// store.Open(OpenFlags.ReadOnly);
// try
// {
// List<string> result = new List<string>();
// foreach (X509Certificate2 certificate in store.Certificates)
// {
// result.Add(certificate.Subject);
// }

// return result;
// }
// finally
// {
// store.Close();
// }
// }
// */});

var listCertificates = edge.func({
source: function() {/*
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
async (dynamic data) =>
{
List<string> result = new List<string>();
foreach (X509Certificate2 certificate in store.Certificates)
X509Store store = new X509Store(
(string)data.storeName,
(StoreLocation)Enum.Parse(typeof(StoreLocation), (string)data.storeLocation));
store.Open(OpenFlags.ReadOnly);
try
{
result.Add(certificate.Subject);
}
List<string> result = new List<string>();
foreach (X509Certificate2 certificate in store.Certificates)
{
result.Add(certificate.Subject);
}
return result;
}
finally
{
store.Close();
return result;
}
finally
{
store.Close();
}
}
}
*/});
*/},
references: [ 'System.Security.Cryptography' ]
});

var result = listCertificates({ storeName: 'My', storeLocation: 'LocalMachine' }, true);
console.log(result);
Loading

0 comments on commit 6df2fb7

Please sign in to comment.