ICompilerExtensions
Provides extension methods for the ICompiler interface and compilation results.
プロパティ
public static string RuntimePath { get; }
value = ICompilerExtensions.RuntimePath
Gets the runtime directory path where the System.Object assembly is located.
メソッド
public static Task<CompilationResult> Compile(ICompiler compiler, string name, string source, IEnumerable<string> refs, IFileSystem fileSystem, CancellationToken cancellationToken)
result = ICompilerExtensions.Compile(compiler, name, source, refs, fileSystem, cancellationToken)
Compiles the provided source code using the specified compiler and references.
- compiler
- The compiler instance.
- name
- The name of the compilation unit.
- source
- The source code as a string.
- refs
- A collection of reference paths.
- fileSystem
- The file system to use.
- cancellationToken
- A token to monitor for cancellation requests.
戻り値: A task representing the asynchronous compilation, containing the compilation result.
public static Task<CompilationResult> Compile(ICompiler compiler, string name, IEnumerable<string> sources, IEnumerable<string> refs, IFileSystem fileSystem, CancellationToken cancellationToken)
result = ICompilerExtensions.Compile(compiler, name, sources, refs, fileSystem, cancellationToken)
Compiles the provided source code using the specified compiler and references.
- compiler
- The compiler instance.
- name
- The name of the compilation unit.
- sources
- The source code files as strings.
- refs
- A collection of reference paths.
- fileSystem
- The file system to use.
- cancellationToken
- A token to monitor for cancellation requests.
戻り値: A task representing the asynchronous compilation, containing the compilation result.
public static IEnumerable<CompilationError> ErrorsOnly(IEnumerable<CompilationError> errors)
result = ICompilerExtensions.ErrorsOnly(errors)
Filters and returns only the errors (excluding warnings and info) from the collection of compilation errors.
- errors
- The collection of compilation errors to filter.
戻り値: A filtered collection containing only errors.
public static bool HasErrors(CompilationResult result)
result = ICompilerExtensions.HasErrors(result)
Determines whether the given compilation result contains any errors.
- result
- The compilation result to check.
戻り値: true if there are errors; otherwise, false.
public static bool HasErrors(IEnumerable<CompilationError> errors)
result = ICompilerExtensions.HasErrors(errors)
Determines whether the given collection of compilation errors contains any errors.
- errors
- The collection of compilation errors to check.
戻り値: true if there are errors; otherwise, false.
public static bool IsFSharp(EventInfo evt)
result = ICompilerExtensions.IsFSharp(evt)
Determines whether the specified event is an F# event.
- evt
- The event information to check.
戻り値: true if the event is an F# event; otherwise, false.
public static bool IsFSharpHandler(Type evtHandler)
result = ICompilerExtensions.IsFSharpHandler(evtHandler)
Determines whether the specified event handler type is an F# handler.
- evtHandler
- The event handler type to check.
戻り値: true if the type is an F# handler; otherwise, false.
public static CompilationResult ThrowIfErrors(CompilationResult res)
result = ICompilerExtensions.ThrowIfErrors(res)
Throws an exception if the compilation result contains errors.
- res
- The compilation result.
戻り値: The original compilation result if no errors are found.
public static IEnumerable<CompilationError> ThrowIfErrors(IEnumerable<CompilationError> errors)
result = ICompilerExtensions.ThrowIfErrors(errors)
Throws an exception if the collection of compilation errors contains any errors.
- errors
- The collection of compilation errors.
戻り値: The original collection of errors if no errors are found.
public static CompilationError ToError(Exception ex)
result = ICompilerExtensions.ToError(ex)
Converts an exception to a compilation error.
- ex
- The exception to convert.
戻り値: A new CompilationError instance representing the exception.
public static string ToFullRuntimePath(string assemblyName)
result = ICompilerExtensions.ToFullRuntimePath(assemblyName)
Combines the runtime directory path with the given assembly name.
- assemblyName
- The name of the assembly file.
戻り値: The full path to the assembly in the runtime directory.
public static ValueTuple<string, byte[]> ToRef(string path, IFileSystem fileSystem)
result = ICompilerExtensions.ToRef(path, fileSystem)
Reads the file at the given path and returns its file name and binary content. The content is cached per file system and re-read only once the file's last write time or length changes, so the same image instance is handed out to repeated compilations.
- path
- The path to the reference file.
- fileSystem
- The file system to use.
戻り値: A tuple containing the file name and its binary content.
public static ValueTask<IEnumerable<ValueTuple<string, byte[]>>> ToValidRefImages<TRef>(IEnumerable<TRef> references, CancellationToken cancellationToken)
result = ICompilerExtensions.ToValidRefImages(references, cancellationToken)
Asynchronously extracts valid reference images from the provided references.
- references
- The collection of code references.
- cancellationToken
- A token to monitor for cancellation requests.
戻り値: A task representing the asynchronous operation that returns an array of reference image tuples.