CompuMaster.JitCompilation 3.0.2025.115

dotnet add package CompuMaster.JitCompilation --version 3.0.2025.115
                    
NuGet\Install-Package CompuMaster.JitCompilation -Version 3.0.2025.115
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CompuMaster.JitCompilation" Version="3.0.2025.115" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CompuMaster.JitCompilation" Version="3.0.2025.115" />
                    
Directory.Packages.props
<PackageReference Include="CompuMaster.JitCompilation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CompuMaster.JitCompilation --version 3.0.2025.115
                    
#r "nuget: CompuMaster.JitCompilation, 3.0.2025.115"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CompuMaster.JitCompilation@3.0.2025.115
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CompuMaster.JitCompilation&version=3.0.2025.115
                    
Install as a Cake Addin
#tool nuget:?package=CompuMaster.JitCompilation&version=3.0.2025.115
                    
Install as a Cake Tool

CompuMaster.JitCompilation

Compile and execute C# or VB.NET code easily on runtime

C# Samples

/// <summary>
/// Simple demonstration of how to compile C# code and running a method from the compiled assembly
/// </summary>
/// <param name="args"></param>
static void CompileSampleSimpleInMemory(string[] args)
{
    string src = "public class TestClass {public static string Answer() {return \"Hello World from inside of a dynamically created assembly!\";}}";
    var cscInMemory = new CompuMaster.JitCompilation.CSharpInMemoryCompiler();
    var cResult = cscInMemory.Compile(src, false);
    System.Console.WriteLine((string)cResult.Invoke("TestClass", "Answer", null)); // result: "Hello World from inside of a dynamically created assembly!"
}

/// <summary>
/// Demonstration of how to compile C# code into an .exe console application assembly and running a method from this assembly by various ways
/// </summary>
/// <param name="args"></param>
static void CompileSampleSimpleToDisk(string[] args)
{
    string src = 
        "public class TestClass {" +
        "   public static void Main(string[] args) {" +
        "       System.Console.WriteLine(\"Running and printing from inside of console application\"); " +
        "       foreach (string greeting in args)" +
        "           System.Console.WriteLine(\"Hello \" + greeting + \"!\"); " +
        "   } " +
        "   public static string Answer() {" +
        "       return \"Hello World from inside of a dynamically created assembly!\";" +
        "   }" +
        "}";
    string tempFilePath = System.IO.Path.GetTempFileName() + ".exe";
    var cscOnDisk = new CompuMaster.JitCompilation.CSharpOnDiskCompiler();
    var cResult = cscOnDisk.Compile(src, Array.Empty<string>(), Array.Empty<string>(), false, tempFilePath, CompuMaster.JitCompilation.Common.TargetType.ConsoleApplication);
    System.Console.WriteLine("Compiled into assembly at location: " + cResult.Assembly.Location + " with name " + cResult.Assembly.FullName);

    System.Console.WriteLine("### Invoking method from compiled assembly:");
    System.Console.WriteLine((string)cResult.Invoke("TestClass", "Answer", null)); // result: "Hello World from inside of a dynamically created assembly!"
            
    System.Console.WriteLine("### Running compiled console application with redirection of standard output:");
    var consoleArgs = new string[] { "Community", "Earth" };
    System.Console.WriteLine(cResult.ExecuteConsoleApp(consoleArgs).StandardOutput);
            
    System.Console.WriteLine("### Running compiled console application via System.Diagnostics.Process.Start:");
    var appProc = System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(tempFilePath, string.Join(" ", consoleArgs)) { UseShellExecute = false }); // run compiled console application
    appProc.WaitForExit();
}

Output of C# Samples

Screenshot of samples

Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.2025.115 216 1/15/2025
3.0.2025.114 167 1/14/2025
3.0.2021.827 530 8/27/2021