public override void Write(string value) { using (ConsoleColorScope.CreateFrom(m_ConsoleColors[DefaultColor])) { Console.WriteLine(value); } }
public override void WriteDebugLine(string message) { using (ConsoleColorScope.CreateFrom(m_ConsoleColors[DebugColor])) { Console.WriteLine($"[DEBUG] {message}"); } }
public override void WriteVerboseLine(string message) { using (ConsoleColorScope.CreateFrom(m_ConsoleColors[VerboseColor])) { Console.WriteLine($"[VERBOSE] {message}"); } }
public override void WriteWarningLine(string message) { using (ConsoleColorScope.CreateFrom(m_ConsoleColors[WarningColor])) { Console.WriteLine($"[WARNING] {message}"); } }
private static void AddLangVersionElement(this XContainer document, XNamespace @namespace, string langVersion) { var propertyGroups = document .Descendants(@namespace + "PropertyGroup") .ToList(); var langVersionElement = propertyGroups.Descendants(@namespace + "LangVersion").FirstOrDefault(); if (langVersionElement != null) { // If we already have an element, just set the value. langVersionElement.SetValue(langVersion); return; } var emptyPropertyGroup = propertyGroups.FirstOrDefault(x => !x.HasAttributes); var globalPropertyGroup = emptyPropertyGroup ?? propertyGroups.FirstOrDefault(); if (globalPropertyGroup == null) { using (ConsoleColorScope.Start(ConsoleColor.Yellow)) { Console.WriteLine("No PropertyGroup element found in file."); } } else { globalPropertyGroup.Add(new XElement(@namespace + "LangVersion") { Value = langVersion }); } }
public override void WriteErrorLine(string value) { using (ConsoleColorScope.CreateFrom(m_ConsoleColors[ErrorColor])) { Console.WriteLine($"[ERROR] {value}"); } }
public static int Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage: LangVersionFixer <folder-with-csprojs> <lang-version-number> [<clean-document>]"); return(-1); } var directoryPath = args[0]; var langVersion = args[1]; var cleanDocument = true; if (args.Length > 2) { var parseOk = Boolean.TryParse(args[2], out cleanDocument); if (!parseOk) { using (ConsoleColorScope.Start(ConsoleColor.Red)) { Console.WriteLine($"Could not convert '{args[2].ToString()}' to boolean."); return(-1); } } } int parsedLangVersion; if (!int.TryParse(langVersion, out parsedLangVersion)) { if (!langVersion.Equals("default", StringComparison.OrdinalIgnoreCase)) { using (ConsoleColorScope.Start(ConsoleColor.Red)) { Console.WriteLine($"'{langVersion}' is not a valid LangVersion parameter."); return(-1); } } } var directory = new DirectoryInfo(directoryPath); if (!directory.Exists) { using (ConsoleColorScope.Start(ConsoleColor.Red)) { Console.WriteLine($"Folder '{directoryPath}' does not exist."); return(-1); } } directory.FixLangVersion(langVersion, cleanDocument); using (ConsoleColorScope.Start(ConsoleColor.Green)) { Console.WriteLine($"Successfully set LangVersion to {langVersion} in all projects."); return(0); } }
public void Error(string message) { message.ThrowIfNull(nameof(message)); using var colorScope = new ConsoleColorScope(ConsoleColor.Red); Console.Error.WriteLine($"Error: {_prefix} {message}"); }
public void Warning(string message) { message.ThrowIfNull(nameof(message)); using var colorScope = new ConsoleColorScope(ConsoleColor.Yellow); Console.Out.WriteLine($"Warning: {_prefix} {message}"); }
public void Message(string message) { message.ThrowIfNull(nameof(message)); using var colorScope = new ConsoleColorScope(ConsoleColor.Green); Console.Out.WriteLine($"Message: {_prefix} {message}"); }
public void Debug(string message) { message.ThrowIfNull(nameof(message)); using var colorScope = new ConsoleColorScope(ConsoleColor.Cyan); Console.Out.WriteLine($"Debug: {_prefix} {message}"); }
public static IDisposable Start(ConsoleColor foregroundColor) { var scope = new ConsoleColorScope(Console.ForegroundColor); Console.ForegroundColor = foregroundColor; return(scope); }
public void Exception(Exception ex, string?message = null) { using var colorScope = new ConsoleColorScope(ConsoleColor.Red); if (message != null) { Console.Error.WriteLine($"Exception: {_prefix} {message}"); } Console.Error.WriteLine($"Exception: {_prefix} {ex}"); }
protected void PrintList() { if (Config.Paths.Count == 0) { using var scope = new ConsoleColorScope(Console, ConsoleColor.Yellow); Console.WriteLine("There are currently no aliases registered. You can register a new alias by using the 'add' verb."); Console.WriteLine("Execute 'cdx add --help' for more information."); } else { Console.WriteLine("The following aliases are available:"); Console.WriteLine(); new TableControl(Console) { Margin = new(3, 0, 0, 0), ShowColumnHeaders = false, Columns = { new() { WidthMode = ColumnWidthMode.Auto, MaxWidth = Console.BufferSize.Width / 3 }, new() { WidthMode = ColumnWidthMode.Star }, },
public static IDisposable Start(ConsoleColor foregroundColor) { var scope = new ConsoleColorScope(Console.ForegroundColor); Console.ForegroundColor = foregroundColor; return scope; }