#if LEGACY using System.Collections.Generic; using System.Threading.Tasks; using System.Management.Automation.Language; namespace System.Management.Automation.Subsystem.Prediction { /// /// Kinds of prediction clients. /// public enum PredictionClientKind { /// /// A terminal client, representing the command-line experience. /// Terminal, /// /// An editor client, representing the editor experience. /// Editor, } /// /// The class represents a client that interacts with predictors. /// public sealed class PredictionClient { /// /// Gets the client name. /// [HiddenAttribute] public string Name { get; } /// /// Gets the client kind. /// [HiddenAttribute] public PredictionClientKind Kind { get; } /// /// Initializes a new instance of the class. /// /// Name of the interactive client. /// Kind of the interactive client. [HiddenAttribute] public PredictionClient(string name, PredictionClientKind kind) { Name = name; Kind = kind; } } /// /// The class represents the prediction result from a predictor. /// public sealed class PredictionResult { /// /// Gets the Id of the predictor. /// [HiddenAttribute] public Guid Id { get; } /// /// Gets the name of the predictor. /// [HiddenAttribute] public string Name { get; } /// /// Gets the mini-session id that represents a specific invocation that returns this result. /// When it's not specified, it's considered by a client that the predictor doesn't expect feedback. /// [HiddenAttribute] public uint? Session { get; } /// /// Gets the suggestions. /// [HiddenAttribute] public IReadOnlyList Suggestions { get; } internal PredictionResult(Guid id, string name, uint? session, List suggestions) { Id = id; Name = name; Session = session; Suggestions = suggestions; } } /// /// The class represents a predictive suggestion generated by a predictor. /// public sealed class PredictiveSuggestion { /// /// Gets the suggestion. /// [HiddenAttribute] public string SuggestionText { get; } /// /// Gets the tooltip of the suggestion. /// [HiddenAttribute] public string ToolTip { get; } /// /// Initializes a new instance of the class. /// /// The predictive suggestion text. [HiddenAttribute] public PredictiveSuggestion(string suggestion) : this(suggestion, toolTip: null) { } /// /// Initializes a new instance of the class. /// /// The predictive suggestion text. /// The tooltip of the suggestion. [HiddenAttribute] public PredictiveSuggestion(string suggestion, string toolTip) { if (string.IsNullOrEmpty(suggestion)) { throw new ArgumentNullException(nameof(suggestion)); } SuggestionText = suggestion; ToolTip = toolTip; } } /// /// Provides a set of possible predictions for given input. /// public static class CommandPrediction { /// /// Collect the predictive suggestions from registered predictors using the default timeout. /// /// Represents the client that initiates the call. /// The object from parsing the current command line input. /// The objects from parsing the current command line input. /// A list of objects. [HiddenAttribute] public static Task> PredictInputAsync(PredictionClient client, Ast ast, Token[] astTokens) { return null; } /// /// Collect the predictive suggestions from registered predictors using the specified timeout. /// /// Represents the client that initiates the call. /// The object from parsing the current command line input. /// The objects from parsing the current command line input. /// The milliseconds to timeout. /// A list of objects. [HiddenAttribute] public static Task> PredictInputAsync(PredictionClient client, Ast ast, Token[] astTokens, int millisecondsTimeout) { return null; } /// /// Allow registered predictors to do early processing when a command line is accepted. /// /// Represents the client that initiates the call. /// History command lines provided as references for prediction. [HiddenAttribute] public static void OnCommandLineAccepted(PredictionClient client, IReadOnlyList history) { } /// /// Allow registered predictors to know the execution result (success/failure) of the last accepted command line. /// /// Represents the client that initiates the call. /// The last accepted command line. /// Whether the execution of the last command line was successful. [HiddenAttribute] public static void OnCommandLineExecuted(PredictionClient client, string commandLine, bool success) { } /// /// Send feedback to a predictor when one or more suggestions from it were displayed to the user. /// /// Represents the client that initiates the call. /// The identifier of the predictor whose prediction result was accepted. /// The mini-session where the displayed suggestions came from. /// /// When the value is > 0, it's the number of displayed suggestions from the list returned in , starting from the index 0. /// When the value is <= 0, it means a single suggestion from the list got displayed, and the index is the absolute value. /// [HiddenAttribute] public static void OnSuggestionDisplayed(PredictionClient client, Guid predictorId, uint session, int countOrIndex) { } /// /// Send feedback to predictors about their last suggestions. /// /// Represents the client that initiates the call. /// The identifier of the predictor whose prediction result was accepted. /// The mini-session where the accepted suggestion came from. /// The accepted suggestion text. [HiddenAttribute] public static void OnSuggestionAccepted(PredictionClient client, Guid predictorId, uint session, string suggestionText) { } } } #else using System.Management.Automation.Subsystem.Prediction; using System.Runtime.CompilerServices; [assembly: TypeForwardedTo(typeof(PredictionClientKind))] [assembly: TypeForwardedTo(typeof(PredictionClient))] [assembly: TypeForwardedTo(typeof(PredictiveSuggestion))] [assembly: TypeForwardedTo(typeof(PredictionResult))] [assembly: TypeForwardedTo(typeof(CommandPrediction))] #endif