Exemplo n.º 1
1
        public ExecuteReplCommand(
            string scriptName,
            string[] scriptArgs,
            IFileSystem fileSystem,
            IScriptPackResolver scriptPackResolver,
            IRepl repl,
            ILogProvider logProvider,
            IConsole console,
            IAssemblyResolver assemblyResolver,
            IFileSystemMigrator fileSystemMigrator,
            IScriptLibraryComposer composer)
        {
            Guard.AgainstNullArgument("fileSystem", fileSystem);
            Guard.AgainstNullArgument("scriptPackResolver", scriptPackResolver);
            Guard.AgainstNullArgument("repl", repl);
            Guard.AgainstNullArgument("logProvider", logProvider);
            Guard.AgainstNullArgument("console", console);
            Guard.AgainstNullArgument("assemblyResolver", assemblyResolver);
            Guard.AgainstNullArgument("fileSystemMigrator", fileSystemMigrator);
            Guard.AgainstNullArgument("composer", composer);

            _scriptName = scriptName;
            _scriptArgs = scriptArgs;
            _fileSystem = fileSystem;
            _scriptPackResolver = scriptPackResolver;
            _repl = repl;
            _logger = logProvider.ForCurrentType();
            _console = console;
            _assemblyResolver = assemblyResolver;
            _fileSystemMigrator = fileSystemMigrator;
            _composer = composer;
        }
Exemplo n.º 2
0
 public Shell(IConsole consoleWindow, ShellConfiguration shellConfiguration)
 {
     _threadStopEvent = new ManualResetEvent(false);
     _writePromptEvent = new ManualResetEvent(false);
     _consoleWindow = consoleWindow;
     _shellConfiguration = shellConfiguration;
 }
		public FollowCommandHandler(
			IConsole console,
			IUserRepository userRepository)
			: base(console)
		{
			_userRepository = userRepository;
		}
Exemplo n.º 4
0
        /// <summary>
        /// Executes the comand line - depending upon the options provided we will
        /// either run a single file, a single command, or enter the interactive loop.
        /// </summary>
        public int Run(IScriptEngine engine, IConsole console, ConsoleOptions options) {
            Contract.RequiresNotNull(engine, "engine");
            Contract.RequiresNotNull(console, "console");
            Contract.RequiresNotNull(options, "options");

            _engine = engine;
            _options = options;
            _console = console;

            Initialize();
            
            try {
                return Run();

#if !SILVERLIGHT // ThreadAbortException.ExceptionState
            } catch (System.Threading.ThreadAbortException tae) {
                if (tae.ExceptionState is KeyboardInterruptException) {
                    Thread.ResetAbort();
                }
                return -1;
#endif
            } finally {
                Shutdown(engine);
            }
        }
Exemplo n.º 5
0
 public Options(IEnvironment environment, IConsole console)
 {
     _environment = environment;
     _console = console;
     AvailableOptions = new List<Option>();
     AvailableOptions.Add(Help);
 }
 public ScriptServices(
     IFileSystem fileSystem,
     IPackageAssemblyResolver packageAssemblyResolver, 
     IScriptExecutor executor,
     IScriptEngine engine,
     IFilePreProcessor filePreProcessor,
     IReplCommandService replCommandService,
     IScriptPackResolver scriptPackResolver, 
     IPackageInstaller packageInstaller,
     ILog logger,
     IAssemblyResolver assemblyResolver,
     IConsole console = null,
     IInstallationProvider installationProvider = null 
     )
 {
     FileSystem = fileSystem;
     PackageAssemblyResolver = packageAssemblyResolver;
     Executor = executor;
     Engine = engine;
     FilePreProcessor = filePreProcessor;
     ReplCommandService = replCommandService;
     ScriptPackResolver = scriptPackResolver;
     PackageInstaller = packageInstaller;
     Logger = logger;
     Console = console;
     AssemblyResolver = assemblyResolver;
     InstallationProvider = installationProvider;
 }
Exemplo n.º 7
0
 public Program(IConsole console, ITranslator translator, ICommandLineArgumentParser argumentParser, ISubRoutineLocator subRoutineLocator)
 {
     this.console = console;
     this.translator = translator;
     this.argumentParser = argumentParser;
     this.subRoutineLocator = subRoutineLocator;
 }
Exemplo n.º 8
0
        public FileConsole(string path, IConsole innerConsole)
        {
            Guard.AgainstNullArgument("innerConsole", innerConsole);

            _path = path;
            _innerConsole = innerConsole;
        }
Exemplo n.º 9
0
 public CakeBuildLog(IConsole console, Verbosity verbosity = Verbosity.Normal)
 {
     _console = console;
     _lock = new object();
     _palettes = CreatePalette();
     Verbosity = verbosity;
 }
Exemplo n.º 10
0
 public ScriptServices(
     IFileSystem fileSystem,
     IPackageAssemblyResolver packageAssemblyResolver,
     IScriptExecutor executor,
     IRepl repl,
     IScriptEngine engine,
     IFilePreProcessor filePreProcessor,
     IScriptPackResolver scriptPackResolver,
     IPackageInstaller packageInstaller,
     IObjectSerializer objectSerializer,
     ILog logger,
     IAssemblyResolver assemblyResolver,
     IEnumerable<IReplCommand> replCommands,
     IConsole console = null,
     IInstallationProvider installationProvider = null)
 {
     FileSystem = fileSystem;
     PackageAssemblyResolver = packageAssemblyResolver;
     Executor = executor;
     Repl = repl;
     Engine = engine;
     FilePreProcessor = filePreProcessor;
     ScriptPackResolver = scriptPackResolver;
     PackageInstaller = packageInstaller;
     ObjectSerializer = objectSerializer;
     Logger = logger;
     Console = console;
     AssemblyResolver = assemblyResolver;
     InstallationProvider = installationProvider;
     ReplCommands = replCommands;
 }
Exemplo n.º 11
0
        public DisplayTodoListHeaderState(IConsole console, ILog log, ITodoList todoList)
            : base(console, log, todoList)
        {
            SetNextState(typeof(ReadTodoState));

            RegisterState(typeof(DisplayTodoListHeaderState), this);
        }
Exemplo n.º 12
0
		public IProcessAsyncOperation Execute (ExecutionCommand command, IConsole console)
		{
			var cmd = (AspNetExecutionCommand) command;
			var xspPath = GetXspPath (cmd);
			
			//if it's a script, use a native execution handler
			if (xspPath.Extension != ".exe") {
				//set mono debug mode if project's in debug mode
				var envVars = cmd.TargetRuntime.GetToolsExecutionEnvironment (cmd.TargetFramework).Variables; 
				if (cmd.DebugMode) {
					envVars = new Dictionary<string, string> (envVars);
					envVars ["MONO_OPTIONS"] = "--debug";
				}
				
				var ncmd = new NativeExecutionCommand (
					xspPath, cmd.XspParameters.GetXspParameters () + " --nonstop",
					cmd.BaseDirectory, envVars);
				
				return Runtime.ProcessService.GetDefaultExecutionHandler (ncmd).Execute (ncmd, console);
			}

			// Set DEVPATH when running on Windows (notice that this has no effect unless
			// <developmentMode developerInstallation="true" /> is set in xsp2.exe.config

			var evars = cmd.TargetRuntime.GetToolsExecutionEnvironment (cmd.TargetFramework).Variables;
			if (cmd.TargetRuntime is MsNetTargetRuntime)
				evars["DEVPATH"] = Path.GetDirectoryName (xspPath);
			
			var netCmd = new DotNetExecutionCommand (
				xspPath, cmd.XspParameters.GetXspParameters () + " --nonstop",
				cmd.BaseDirectory, evars);
			netCmd.DebugMode = cmd.DebugMode;
			
			return cmd.TargetRuntime.GetExecutionHandler ().Execute (netCmd, console);
		}
Exemplo n.º 13
0
		public static bool GetEV3Configuration(IConsole console)
		{

			if (UserSettings.Instance.IPAddress == "0" ||
				UserSettings.Instance.DebugPort == "")
				return false;

			string EV3IPAddress = UserSettings.Instance.IPAddress;
			string EV3DebuggerPort = UserSettings.Instance.DebugPort;

			bool bValid = true;

			try
			{
				IPAddress.Parse(EV3IPAddress);
				int.Parse(EV3DebuggerPort);
			}
			catch (Exception ex)
			{
				console.Log.WriteLine(ex.Message);
				bValid = false;
			}

			return bValid;
		}
Exemplo n.º 14
0
 public Dispatcher(IArgumentParser argumentParser, IArgumentMapFactory argumentMapFactory,
     IConsole console)
 {
     _argumentParser = argumentParser;
     _console = console;
     _argumentMapFactory = argumentMapFactory;
 }
Exemplo n.º 15
0
        public ColoredConsoleLogProvider(LogLevel logLevel, IConsole console)
        {
            Guard.AgainstNullArgument("console", console);

            _logLevel = logLevel;
            _console = console;
        }
Exemplo n.º 16
0
 public Prompt(IConsole console, ICalculator calculator, IValidator validator, ILogger logger)
 {
     _console = console;
     _calculator = calculator;
     _validator = validator;
     _logger = logger;
 }
Exemplo n.º 17
0
 public virtual void Execute(IConsole console)
 {
     if (callback == null)
         throw new NotImplementedException("Callback delegate not defined for this entry");
     else
         callback(console);
 }
 public void SetUp()
 {
     stubSpriteBatch = MockRepository.GenerateStub<ISpriteBatch>();
     stubFont = MockRepository.GenerateStub<IFont>();
     stubConsole = MockRepository.GenerateStub<IConsole<string>>();
     stubConsole.Log = log;
 }
Exemplo n.º 19
0
 public static void Initialize(         
  IConsole console,
  ISurface surface,
  IStyle style,
  IDrawings drawing,
  IShapes shapes,
  IImages images,
  IControls controls,
  ISounds sounds,         
  IKeyboard keyboard,
  IMouse mouse,
  ITimer timer,
  IFlickr flickr,
  ISpeech speech,
  CancellationToken token)
 {
     TextWindow.Init(console);
      Desktop.Init(surface);
      GraphicsWindow.Init(style, surface, drawing, keyboard, mouse);
      Shapes.Init(shapes);
      ImageList.Init(images);
      Turtle.Init(surface, drawing, shapes);
      Controls.Init(controls);
      Sound.Init(sounds);
      Timer.Init(timer);
      Stack.Init();
      Flickr.Init(flickr);
      Speech.Init(speech);
      Program.Init(token);
 }
 public void Init()
 {
     _taskRepository = new TaskRepository();
     _console = new RealConsole();
     _projectRepository = new ProjectRepository();
     _taskCommandFactory = new TaskCommandFactory(_console, _projectRepository, _taskRepository);
 }
Exemplo n.º 21
0
        public RemoveTodoItemState(IConsole console, ILog log, ITodoList todoList)
            : base(console, log, todoList)
        {
            SetNextState(typeof(ReadTodoState));

            RegisterState(typeof(RemoveTodoItemState), this);
        }
Exemplo n.º 22
0
        public CloneRoutine(ISolutionCloner solutionCloner, ICommandLineArgumentParser argumentParser, IConsole console, ITranslator translator)
            : base(argumentParser, console, translator)
        {
            this.solutionCloner = solutionCloner;

            solutionCloner.CurrentPathChanged += solutionCloner_CurrentPathChanged;
        }
Exemplo n.º 23
0
        public TestResults RunTests(IEnumerable<IProject> projects, string baseDirectory, string buildEngine, IConsole console)
        {
            try
            {
                string processName = string.Format("{0}", Path.Combine(_currentdirectory, "mspec-clr4.exe"));

                var process = new Process
                                  {
                                      StartInfo =
                                          {
                                              FileName = processName,
                                              Arguments = BuildArguments(projects),
                                              RedirectStandardOutput = false,
                                              RedirectStandardError = true,
                                              UseShellExecute = false
                                          },

                                      EnableRaisingEvents = false
                                  };

                process.Start();
                process.WaitForExit();
                process.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return CompileResults();
        }
		public IProcessAsyncOperation Execute (ExecutionCommand command, IConsole console)
		{
			if (!CanExecute (command))
			    return null;
			DebugExecutionHandler h = new DebugExecutionHandler (null);
			return h.Execute (command, console);
		}
Exemplo n.º 25
0
		public IProcessAsyncOperation Execute (ExecutionCommand command, IConsole console)
		{
			DotNetExecutionCommand cmd = (DotNetExecutionCommand) command;
			if (cmd.TargetRuntime == null)
				cmd.TargetRuntime = Runtime.SystemAssemblyService.DefaultRuntime;
			return cmd.TargetRuntime.GetExecutionHandler ().Execute (cmd, console);
		}
        public ApplicationRuntime(IConsole console, BaseRuntime commandRuntime)
        {
            this.console = console;
            this.commandRuntime = commandRuntime;

            this.console.CancelKeyPressed += CancelKeyPressed;
        }
		public SshCommandHelper(string IPAddress, ManualResetEvent executed = null, IConsole console = null, bool verbose = false)
		{
			_executed = executed;
			_console = console;
			_verbose = verbose;
			_sshClient = new SshClient(IPAddress, "root", "");
		}
Exemplo n.º 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AlfredSpeechConsole" /> class.
        /// </summary>
        /// <param name="console">The console that events should be logged to.</param>
        /// <param name="factory">The event factory.</param>
        public AlfredSpeechConsole([CanBeNull] IConsole console, [CanBeNull] ConsoleEventFactory factory)
        {
            // This class can decorate other consoles, but for an empty implementation it can rely on an internal collection
            if (console == null)
            {
                console = new SimpleConsole();
            }
            _console = console;

            // Set up the event factory
            if (factory == null) { factory = new ConsoleEventFactory(); }
            EventFactory = factory;

            // Tell it what log levels we care about
            _speechEnabledLogLevels = new HashSet<LogLevel> { LogLevel.ChatResponse, LogLevel.Warning, LogLevel.Error };

            try
            {
                // Give the speech provider the existing console and not this console since it won't be online yet
                _speech = new AlfredSpeechProvider(console);
            }
            catch (InvalidOperationException ex)
            {
                // On failure creating the speech provider, just have speech be null and we'll just be a decorator
                _speech = null;
                Log("Init.Console", $"Speech could not be initialized: {ex.Message}", LogLevel.Error);
            }
        }
Exemplo n.º 29
0
		/// <summary>
		/// Initializes a new instance of the <see cref="SelfMediaDatabase.Console.UserInterface.ConsoleDialog"/> class.
		/// </summary>
		/// <param name="console">Console.</param>
		public ConsoleDialog(IConsole console)
		{
			if (console == null)
				throw new ArgumentNullException("console");
		
			_console = console;
		}
Exemplo n.º 30
0
 public ExecuteReplCommand(
     string scriptName,
     string[] scriptArgs,
     IFileSystem fileSystem,
     IScriptPackResolver scriptPackResolver,
     IScriptEngine scriptEngine,
     IFilePreProcessor filePreProcessor,
     IObjectSerializer serializer,
     ILog logger,
     IConsole console,
     IAssemblyResolver assemblyResolver,
     IEnumerable<IReplCommand> replCommands)
 {
     _scriptName = scriptName;
     _scriptArgs = scriptArgs;
     _fileSystem = fileSystem;
     _scriptPackResolver = scriptPackResolver;
     _scriptEngine = scriptEngine;
     _filePreProcessor = filePreProcessor;
     _serializer = serializer;
     _logger = logger;
     _console = console;
     _assemblyResolver = assemblyResolver;
     _replCommands = replCommands;
 }
 public AuroraRepository(IAwsConfiguration configuration, IConsole console)
 {
     this._configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
     this._console       = console ?? throw new ArgumentNullException(nameof(console));
 }
Exemplo n.º 32
0
        internal static void InternalRun(ExecutionCommand cmd, DebuggerEngine factory, IConsole c)
        {
            if (factory == null)
            {
                factory = GetFactoryForCommand(cmd);
                if (factory == null)
                {
                    throw new InvalidOperationException("Unsupported command: " + cmd);
                }
            }

            if (session != null)
            {
                throw new InvalidOperationException("A debugger session is already started");
            }

            DebuggerStartInfo startInfo = factory.CreateDebuggerStartInfo(cmd);

            startInfo.UseExternalConsole         = c is ExternalConsole;
            startInfo.CloseExternalConsoleOnExit = c.CloseOnDispose;
            currentEngine            = factory;
            session                  = factory.CreateSession();
            session.ExceptionHandler = ExceptionHandler;

            // When using an external console, create a new internal console which will be used
            // to show the debugger log
            if (startInfo.UseExternalConsole)
            {
                console = (IConsole)IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor();
            }
            else
            {
                console = c;
            }

            SetupSession();

            SetDebugLayout();

            try {
                session.Run(startInfo, GetUserOptions());
            } catch {
                Cleanup();
                throw;
            }
        }
Exemplo n.º 33
0
 public abstract ProcessResult Size(IConsole console, IStandardProject project, LinkResult linkResult);
Exemplo n.º 34
0
 public abstract LinkResult Link(IConsole console, IStandardProject superProject, IStandardProject project,
                                 CompileResult assemblies, string outputPath);
Exemplo n.º 35
0
 public abstract CompileResult Compile(IConsole console, IStandardProject superProject, IStandardProject project,
                                       ISourceFile file, string outputFile);
Exemplo n.º 36
0
 public ProjectCommand(IConsole console, ILogger <ProjectCommand> logger) : base(console, logger)
 {
 }
Exemplo n.º 37
0
 public App(IDateTimeOffset dateTimeOffset, IFortuneCookie fortuneCookie, IConsole console)
 {
     _dateTimeOffset = dateTimeOffset;
     _fortuneCookie  = fortuneCookie;
     _console        = console;
 }
Exemplo n.º 38
0
 public HelpWriter(IVersionWriter versionWriter, IConsole console)
 {
     this.versionWriter = versionWriter ?? throw new ArgumentNullException(nameof(versionWriter));
     this.console       = console ?? throw new ArgumentNullException(nameof(console));
 }
Exemplo n.º 39
0
 public static IProcessAsyncOperation Run(string file, IConsole console)
 {
     return(Run(file, null, null, null, console));
 }
Exemplo n.º 40
0
        public static IProcessAsyncOperation Run(string file, string args, string workingDir, IDictionary <string, string> envVars, IConsole console)
        {
            var h   = new DebugExecutionHandler(null);
            var cmd = Runtime.ProcessService.CreateCommand(file);

            if (args != null)
            {
                cmd.Arguments = args;
            }
            if (workingDir != null)
            {
                cmd.WorkingDirectory = workingDir;
            }
            if (envVars != null)
            {
                cmd.EnvironmentVariables = envVars;
            }

            return(h.Execute(cmd, console));
        }
Exemplo n.º 41
0
        public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console)
        {
            var h = new DebugExecutionHandler(engine);

            return(h.Execute(command, console));
        }
Exemplo n.º 42
0
        static void Cleanup()
        {
            DebuggerSession currentSession;
            StatusBarIcon   currentIcon;
            IConsole        currentConsole;

            lock (cleanup_lock) {
                if (!IsDebugging)
                {
                    return;
                }

                currentIcon    = busyStatusIcon;
                currentSession = session;
                currentConsole = console;

                nextStatementLocations.Clear();
                currentBacktrace = null;
                busyStatusIcon   = null;
                session          = null;
                console          = null;
                pinnedWatches.InvalidateAll();
            }

            UnsetDebugLayout();

            currentSession.BusyStateChanged -= OnBusyStateChanged;
            currentSession.TargetEvent      -= OnTargetEvent;
            currentSession.TargetStarted    -= OnStarted;

            currentSession.BreakpointTraceHandler = null;
            currentSession.GetExpressionEvaluator = null;
            currentSession.TypeResolverHandler    = null;
            currentSession.OutputWriter           = null;
            currentSession.LogWriter = null;

            if (currentConsole != null)
            {
                currentConsole.CancelRequested -= OnCancelRequested;
                currentConsole.Dispose();
            }

            DispatchService.GuiDispatch(delegate {
                HideExceptionCaughtDialog();

                if (currentIcon != null)
                {
                    currentIcon.Dispose();
                    currentIcon = null;
                }

                if (StoppedEvent != null)
                {
                    StoppedEvent(null, new EventArgs());
                }

                NotifyCallStackChanged();
                NotifyCurrentFrameChanged();
                NotifyLocationChanged();
            });

            currentSession.Dispose();
        }
Exemplo n.º 43
0
        private static void RegisterExtensions(AggregateCatalog catalog, IEnumerable <string> enumerateFiles, IConsole console)
        {
            foreach (var item in enumerateFiles)
            {
                AssemblyCatalog assemblyCatalog = null;
                try
                {
                    assemblyCatalog = new AssemblyCatalog(item);

                    // get the parts - throw if something went wrong
                    var parts = assemblyCatalog.Parts;

                    // load all the types - throw if assembly cannot load (missing dependencies is a good example)
                    var assembly = Assembly.LoadFile(item);
                    assembly.GetTypes();

                    catalog.Catalogs.Add(assemblyCatalog);
                }
                catch (BadImageFormatException ex)
                {
                    if (assemblyCatalog != null)
                    {
                        assemblyCatalog.Dispose();
                    }

                    // Ignore if the dll wasn't a valid assembly
                    console.WriteWarning(ex.Message);
                }
                catch (FileLoadException ex)
                {
                    // Ignore if we couldn't load the assembly.

                    if (assemblyCatalog != null)
                    {
                        assemblyCatalog.Dispose();
                    }

                    var message =
                        String.Format(LocalizedResourceManager.GetString(nameof(NuGetResources.FailedToLoadExtension)),
                                      item);

                    console.WriteWarning(message);
                    console.WriteWarning(ex.Message);
                }
                catch (ReflectionTypeLoadException rex)
                {
                    // ignore if the assembly is missing dependencies

                    var resource =
                        LocalizedResourceManager.GetString(nameof(NuGetResources.FailedToLoadExtensionDuringMefComposition));

                    var perAssemblyError = string.Empty;

                    if (rex?.LoaderExceptions.Length > 0)
                    {
                        var builder = new StringBuilder();

                        builder.AppendLine(string.Empty);

                        var errors = rex.LoaderExceptions.Select(e => e.Message).Distinct(StringComparer.Ordinal);

                        foreach (var error in errors)
                        {
                            builder.AppendLine(error);
                        }

                        perAssemblyError = builder.ToString();
                    }

                    var warning = string.Format(resource, item, perAssemblyError);

                    console.WriteWarning(warning);
                }
            }
        }
Exemplo n.º 44
0
 public IProcessAsyncOperation Execute(ExecutionCommand cmd, IConsole console)
 {
     // Never called
     throw new NotImplementedException();
 }
Exemplo n.º 45
0
 /// <summary>
 /// Sets the console used for writing and writing.
 /// </summary>
 /// <param name="console">The console to use for IO.</param>
 internal static void SetConsole(IConsole console) => _console = console;
Exemplo n.º 46
0
 public UnpackVerbExecutor(UnpackVerb verb, IConsole console) : base(verb, console)
 {
 }
 public GetLandingPagesDemo(HttpClient httpClient, IConsole console, AuthenticationHelper authHelper) : base(httpClient, console, authHelper)
 {
 }
Exemplo n.º 48
0
 public UpdateImpactVerbExecutor(UpdateImpactVerb verb, IConsole console) : base(verb, console)
 {
 }
Exemplo n.º 49
0
        private LinkResult Link(IConsole console, IStandardProject superProject, CompileResult compileResult,
                                CompileResult linkResults, string label = "")
        {
            var binDirectory = compileResult.Project.GetBinDirectory(superProject);

            if (!Directory.Exists(binDirectory))
            {
                Directory.CreateDirectory(binDirectory);
            }

            var outputLocation = binDirectory;

            var executable = Path.Combine(outputLocation, compileResult.Project.Name);

            if (!string.IsNullOrEmpty(label))
            {
                executable += string.Format("-{0}", label);
            }

            if (compileResult.Project.Type == ProjectType.StaticLibrary)
            {
                executable  = Path.Combine(outputLocation, "lib" + compileResult.Project.Name);
                executable += StaticLibraryExtension;
            }
            else
            {
                executable += ExecutableExtension;
            }

            if (!Directory.Exists(outputLocation))
            {
                Directory.CreateDirectory(outputLocation);
            }

            var link = false;

            foreach (var objectFile in compileResult.ObjectLocations)
            {
                if (!System.IO.File.Exists(executable) || (System.IO.File.GetLastWriteTime(objectFile) > System.IO.File.GetLastWriteTime(executable)))
                {
                    link = true;
                    break;
                }
            }

            if (!link)
            {
                foreach (var library in compileResult.LibraryLocations)
                {
                    if (!System.IO.File.Exists(executable) || (System.IO.File.GetLastWriteTime(library) > System.IO.File.GetLastWriteTime(executable)))
                    {
                        link = true;
                        break;
                    }
                }
            }

            var linkResult = new LinkResult {
                Executable = executable
            };

            if (link)
            {
                console.OverWrite(string.Format("[LL]    [{0}]", compileResult.Project.Name));
                linkResult = Link(console, superProject, compileResult.Project, compileResult, executable);
            }

            if (linkResult.ExitCode == 0)
            {
                if (compileResult.Project.Type == ProjectType.StaticLibrary)
                {
                    if (compileResult.ObjectLocations.Count > 0)
                    {
                        // This is where we have a libray with just headers.
                        linkResults.LibraryLocations.Add(executable);
                    }
                }
                else
                {
                    superProject.Executable = superProject.Location.MakeRelativePath(linkResult.Executable).ToAvalonPath();
                    superProject.Save();
                    console.WriteLine();
                    Size(console, compileResult.Project, linkResult);
                    linkResults.ExecutableLocations.Add(executable);
                }
            }
            else if (linkResults.ExitCode == 0)
            {
                linkResults.ExitCode = linkResult.ExitCode;
            }

            return(linkResult);
        }
Exemplo n.º 50
0
 public ClearCommand(IConsole console, DrawHeaderCommand drawHeaderCommand)
     : base(console)
 {
     _drawHeaderCommand = drawHeaderCommand;
 }
Exemplo n.º 51
0
 internal ConsoleMessageBox(IConsole console)
 {
     this.console = console;
 }
Exemplo n.º 52
0
 public SetupBuildScripts(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) : base(console, fileSystem, log, stepFactory)
 {
 }
Exemplo n.º 53
0
 protected override Task <int> Handle(CArgument argument, IConsole console, InvocationContext context, PipelineContext operation, CancellationToken cancellationToken) => Task.FromResult(0);
Exemplo n.º 54
0
        public static async Task <int> Run(
            string?workspace,
            bool folder,
            bool fixWhitespace,
            string?fixStyle,
            string?fixAnalyzers,
            string[] diagnostics,
            string?verbosity,
            bool check,
            string[] include,
            string[] exclude,
            string?report,
            bool includeGenerated,
            IConsole console = null !)
        {
            if (s_parseResult == null)
            {
                return(1);
            }

            // Setup logging.
            var logLevel = GetLogLevel(verbosity);
            var logger   = SetupLogging(console, minimalLogLevel: logLevel, minimalErrorLevel: LogLevel.Warning);

            // Hook so we can cancel and exit when ctrl+c is pressed.
            var cancellationTokenSource = new CancellationTokenSource();

            Console.CancelKeyPress += (sender, e) =>
            {
                e.Cancel = true;
                cancellationTokenSource.Cancel();
            };

            var currentDirectory = string.Empty;

            try
            {
                currentDirectory = Environment.CurrentDirectory;

                var formatVersion = GetVersion();
                logger.LogDebug(Resources.The_dotnet_format_version_is_0, formatVersion);

                string?       workspaceDirectory;
                string        workspacePath;
                WorkspaceType workspaceType;

                // The folder option means we should treat the project path as a folder path.
                if (folder)
                {
                    // If folder isn't populated, then use the current directory
                    workspacePath      = Path.GetFullPath(workspace ?? ".", Environment.CurrentDirectory);
                    workspaceDirectory = workspacePath;
                    workspaceType      = WorkspaceType.Folder;
                }
                else
                {
                    var(isSolution, workspaceFilePath) = MSBuildWorkspaceFinder.FindWorkspace(currentDirectory, workspace);

                    workspacePath = workspaceFilePath;
                    workspaceType = isSolution
                        ? WorkspaceType.Solution
                        : WorkspaceType.Project;

                    // To ensure we get the version of MSBuild packaged with the dotnet SDK used by the
                    // workspace, use its directory as our working directory which will take into account
                    // a global.json if present.
                    workspaceDirectory = Path.GetDirectoryName(workspacePath);
                    if (workspaceDirectory is null)
                    {
                        throw new Exception($"Unable to find folder at '{workspacePath}'");
                    }
                }

                if (workspaceType != WorkspaceType.Folder)
                {
                    var runtimeVersion = GetRuntimeVersion();
                    logger.LogDebug(Resources.The_dotnet_runtime_version_is_0, runtimeVersion);

                    // Load MSBuild
                    Environment.CurrentDirectory = workspaceDirectory;

                    if (!TryGetDotNetCliVersion(out var dotnetVersion))
                    {
                        logger.LogError(Resources.Unable_to_locate_dotnet_CLI_Ensure_that_it_is_on_the_PATH);
                        return(UnableToLocateDotNetCliExitCode);
                    }

                    logger.LogTrace(Resources.The_dotnet_CLI_version_is_0, dotnetVersion);

                    if (!TryLoadMSBuild(out var msBuildPath))
                    {
                        logger.LogError(Resources.Unable_to_locate_MSBuild_Ensure_the_NET_SDK_was_installed_with_the_official_installer);
                        return(UnableToLocateMSBuildExitCode);
                    }

                    logger.LogTrace(Resources.Using_msbuildexe_located_in_0, msBuildPath);
                }

                var fixType = FixCategory.None;
                if (s_parseResult.WasOptionUsed("--fix-style", "-s"))
                {
                    fixType |= FixCategory.CodeStyle;
                }

                if (s_parseResult.WasOptionUsed("--fix-analyzers", "-a"))
                {
                    fixType |= FixCategory.Analyzers;
                }

                if (fixType == FixCategory.None && diagnostics.Length > 0)
                {
                    logger.LogWarning(Resources.The_diagnostics_option_only_applies_when_fixing_style_or_running_analyzers);
                }

                if (fixType == FixCategory.None || fixWhitespace)
                {
                    fixType |= FixCategory.Whitespace;
                }

                HandleStandardInput(logger, ref include, ref exclude);

                var fileMatcher = SourceFileMatcher.CreateMatcher(include, exclude);

                var formatOptions = new FormatOptions(
                    workspacePath,
                    workspaceType,
                    logLevel,
                    fixType,
                    codeStyleSeverity: GetSeverity(fixStyle ?? FixSeverity.Error),
                    analyzerSeverity: GetSeverity(fixAnalyzers ?? FixSeverity.Error),
                    diagnostics: diagnostics.ToImmutableHashSet(),
                    saveFormattedFiles: !check,
                    changesAreErrors: check,
                    fileMatcher,
                    reportPath: report,
                    includeGenerated);

                var formatResult = await CodeFormatter.FormatWorkspaceAsync(
                    formatOptions,
                    logger,
                    cancellationTokenSource.Token,
                    createBinaryLog : logLevel == LogLevel.Trace).ConfigureAwait(false);

                return(GetExitCode(formatResult, check));
            }
            catch (FileNotFoundException fex)
            {
                logger.LogError(fex.Message);
                return(UnhandledExceptionExitCode);
            }
            catch (OperationCanceledException)
            {
                return(UnhandledExceptionExitCode);
            }
            finally
            {
                if (!string.IsNullOrEmpty(currentDirectory))
                {
                    Environment.CurrentDirectory = currentDirectory;
                }
            }
        }
Exemplo n.º 55
0
 public ScheduleActionHandler(IAppointmentScheduler appointmentScheduler, CalendarUiConsoleSettings configuration, IConsole console)
     : base(console, "Schedule period")
 {
     this.appointmentScheduler = appointmentScheduler;
     this.configuration        = configuration;
 }
Exemplo n.º 56
0
 public override async Task ExecuteAsync(IConsole console) => await ExportAsync(console, ChannelId);
Exemplo n.º 57
0
 public ServerMessageListener(IClientWrapper client, IConsole console)
 {
     _console   = console;
     _retriever = new ServerMessageRetriever(client);
 }
Exemplo n.º 58
0
 public UninstallHelpBuilder(IConsole console) : base(console)
 {
 }
        private static Tuple <RunspaceDispatcher, NuGetPSHost> CreateAndSetupRunspace(IConsole console, string hostName)
        {
            Tuple <RunspaceDispatcher, NuGetPSHost> runspace = CreateRunspace(console, hostName);

            SetupExecutionPolicy(runspace.Item1);
            LoadModules(runspace.Item1);
            LoadProfilesIntoRunspace(runspace.Item1);

            return(Tuple.Create(runspace.Item1, runspace.Item2));
        }
Exemplo n.º 60
0
 public ManageSubscriberDemo(HttpClient httpClient, IConsole console, AuthenticationHelper authHelper) : base(httpClient, console, authHelper)
 {
 }