API

reference

csharpy.binaries.AddReference (name)

Imports a C# dll.

csharpy.binaries.add_csharp_extension ()

Imports CSharpExtension into global context.

This binary has a version. On Windows, the system might decide to skip the replacement of an assembly because it is in use. You can check the version of this by using the following code.

runtime

csharpy.runtime.create_cs_function (name, code, usings = None, dependencies = None, redirect = False)

Compiles a C# function. Relies on run_cs_function.

sphinx extensions

csharpy.sphinxext.RunCSharpDirective (self, name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Runs a C# script based on runpython. The directive adds a couple of options:

  • 'dependency': list of necessary dependencies, list comma separated
  • 'entrypoint': function to call first to start the program, it can be empty, it must be a function without any argument.
  • 'using': list of necessary usings, list comma separated

A few examples, the first one shows how to call one function inside others.