KestrunHostScriptValidationExtensions.IsCSharpScriptValid method

Checks if a C# script has compilation errors.

public static bool IsCSharpScriptValid(this KestrunHost host, string code, 
    string[]? extraImports = null, Assembly[]? extraRefs = null, 
    LanguageVersion languageVersion = LanguageVersion.CSharp12)
parameter description
host The KestrunHost instance used for validation
code The C# script code to check
extraImports Optional additional imports
extraRefs Optional additional assembly references
languageVersion C# language version to use

Return Value

True if the script compiles without errors, false otherwise

See Also