KestrunHostScriptValidationExtensions.ValidateCSharpScript method
Validates a C# script and returns compilation diagnostics without throwing exceptions. Useful for testing scripts before adding routes.
public static ImmutableArray<Diagnostic> ValidateCSharpScript(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 validate |
extraImports | Optional additional imports |
extraRefs | Optional additional assembly references |
languageVersion | C# language version to use |
Return Value
Compilation diagnostics including errors and warnings
See Also
- class KestrunHost
- class KestrunHostScriptValidationExtensions
- namespace Kestrun.Hosting