Compiler
interface cAlgo.API Since 5.1
DesktopCLICloud
Provides access to compiler for algos.
Environment behaviour
Cloud — not supported. Nothing is compiled. Compile returns a failed result with no errors; CompileAsync calls back asynchronously with that failed result.
Definition
public interface Compiler
Namespace: cAlgo.API · Group: Compilation
Examples
Example 1
using cAlgo.API;
namespace cAlgo.Robots;
public partial class TestExample : Robot
{
protected override void OnStart()
{
// Path is relative to Algo type data directory
var result = Compiler.Compile(@"Test\Test\Test.csproj");
if (result.Succeeded)
Print("Compilation finished successfully");
else
Print($"Compilation failed with errors: {string.Join(", ", result.Errors)}");
}
}
# Path is relative to Algo type data directory
result = api.Compiler.Compile(r"Test\Test\Test.csproj")
if result.Succeeded:
api.Print("Compilation finished successfully")
else:
errors = ", ".join(result.Errors)
api.Print(f"Compilation failed with errors: {errors}")
{
"AccessRights": "None"
}
Example 2
using cAlgo.API;
namespace cAlgo.Robots;
public partial class TestExample : Robot
{
protected override void OnStart()
{
// Path is relative to Algo type data directory
var operation = Compiler.CompileAsync(@"Test\Test\Test.csproj", result =>
{
if (result.Succeeded)
Print("Compilation finished successfully");
else
Print($"Compilation failed with errors: {string.Join(", ", result.Errors)}");
});
if (operation.IsExecuting)
Print("Compilation is running");
}
}
def on_start(self):
# Path is relative to Algo type data directory
operation = api.Compiler.CompileAsync(r"Test\Test\Test.csproj", self.on_compilation_finished)
if operation.IsExecuting:
api.Print("Compilation is running")
def on_compilation_finished(self, result):
if result.Succeeded:
api.Print("Compilation finished successfully")
else:
errors = ", ".join(result.Errors)
api.Print(f"Compilation failed with errors: {errors}")
{
"AccessRights": "None"
}
Methods
| Name | Description |
|---|---|
Compile 2 overloadsDesktopCLICloudCompilationResult | Compiles an algo. |
CompileAsync 2 overloadsDesktopCLICloudCompilationOperation | Compiles an algo asynchronously and calls the passed callback when compilation finishes. |