microsoft / RTVS

R Tools for Visual Studio.
MIT License
389 stars 118 forks source link

.NET Standard 2.0 Assembly Used as R Package? #4326

Closed JeffFerguson closed 6 years ago

JeffFerguson commented 6 years ago

Is it possible to package a .NET Standard assembly as an R package such that R scripts can call into the .NET Standard assembly? Would any additional work need to be added to the .NET Standard assembly such that this level of integration is possible?

I see documentation that references .NET code calling into an R script, but nothing that references an R script calling into an assembly. Is this possible?

MikhailArkhipov commented 6 years ago

The simplest probably is to run C# as a process and call it via JSON RPC. You can use StreamJsonRpc library. We do exactly this calling C# from TypeScript in VS Code Python.

This would save you from trouble converting data types from R to C++ to C#.

MikhailArkhipov commented 6 years ago

Look at https://github.com/Microsoft/PTVS/blob/master/Python/Product/VSCode/AnalysisVsc/Program.cs how to setup JSON RPC and https://github.com/Microsoft/PTVS/blob/master/Python/Product/VSCode/AnalysisVsc/LanguageServer.cs that has bunch of methods mapped to JSON requests. The project is .NET App 2.0