public static LineEndings GetLineEndings(LineEndingsNoFile lineEndings) { LineEndings endings = LineEndings.SystemDefault; switch (lineEndings) { case LineEndingsNoFile.SystemDefault: endings = LineEndings.SystemDefault; break; case LineEndingsNoFile.Windows: endings = LineEndings.Windows; break; case LineEndingsNoFile.Unix: endings = LineEndings.Unix; break; case LineEndingsNoFile.ClassicMacOS: endings = LineEndings.ClassicMacOS; break; default: endings = LineEndings.SystemDefault; break; } return(endings); }
public DiagramMetaExtendedLine() { MetaLine.IsEndings = false; MetaLine.StrokeThickness = 1; MetaLine.Stroke = (Brush)LineEndings.FindResource("0ForegroundBrush"); MetaLine.StrokeDashArray = new DoubleCollection(new double[] { 5, 3 }); }
public static int LineOfIndexOrDefault( this string self, int index, LineEndings lineEnding) { var lineEndingChar = '\r'; if (lineEnding == LineEndings.LF) { lineEndingChar = '\n'; } var linesCounted = 0; var value = 1; for (int i = 0; i < self.Length; i++) { if (self[i] == lineEndingChar || i == self.Length - 1) { linesCounted++; } if (index == i) { value = linesCounted; break; } } return(value); }
/// <summary> /// Substitutes the current line ending character for a valid given one. /// </summary> /// <param name="lineEndings">The type of line ending to which the file will be changed.</param> public void SetLineEndings(LineEndings lineEndings) { var previousEndOfLineCharacter = EndOfLineCharacter; EndOfLineCharacter = lineEndings; // TODO: Implement the substitution logic via search (or keep a table of all EOL positions). }
public override void Highlight() { base.Highlight(); MetaLine.Stroke = (Brush)LineEndings.FindResource("0LightHighlightBrush"); Panel.SetZIndex(MetaLine, 99999); }
/// <summary> /// Looks up the buffer for a given file and saves the its current line ending character for the undo operation. /// </summary> /// <param name="filePath">The path to the open file whose line endings should change.</param> /// <param name="newLineEnding">The EOL style to which the file should change.</param> public ChangeLineEndings(string filePath, LineEndings newLineEnding) { Name = "Change EOLs to " + newLineEnding; _buffer = ApplicationState.Instance.FileHandlerInstance.GetFileBuffer(filePath); _newLineEndingCharacter = newLineEnding; _previousLineEndingsCharacter = _buffer.FileInstance.EndOfLineCharacter; }
public TestLineProcessor(string filename, LineEndings lineEndings, OutputEncodingType outputEncodingType, bool overwriteExistingFile, bool moveOriginalToRecyclingBin) { m_FileName = filename; m_LineEndings = lineEndings; m_OutputEncodingType = outputEncodingType; m_OverwriteExistingFile = overwriteExistingFile; m_MoveOriginalToRecyclingBin = moveOriginalToRecyclingBin; }
public static string ChangeLineEndings(string text, LineEndings lineEndings, ref int numberOfChanges, out int numberOfIndividualChanges, out int numberOfAllLineEndings) { numberOfIndividualChanges = 0; string replacementString = string.Empty; numberOfAllLineEndings = Regex.Matches(text, LineEndingsPattern).Count; var numberOfWindowsLineEndings = Regex.Matches(text, WindowsLineEndings).Count; var numberOfLinuxLineEndings = Regex.Matches(text, LinuxLineEndings).Count - numberOfWindowsLineEndings; var numberOfMacintoshLineEndings = Regex.Matches(text, MacintoshLineEndings).Count - numberOfWindowsLineEndings; switch (lineEndings) { case LineEndings.Linux: replacementString = LinuxLineEndings; numberOfIndividualChanges = numberOfWindowsLineEndings + numberOfMacintoshLineEndings; break; case LineEndings.Windows: replacementString = WindowsLineEndings; numberOfIndividualChanges = numberOfLinuxLineEndings + numberOfMacintoshLineEndings; break; case LineEndings.Macintosh: replacementString = MacintoshLineEndings; numberOfIndividualChanges = numberOfWindowsLineEndings + numberOfLinuxLineEndings; break; case LineEndings.Dominant: if (numberOfWindowsLineEndings > numberOfLinuxLineEndings && numberOfWindowsLineEndings > numberOfMacintoshLineEndings) { replacementString = WindowsLineEndings; numberOfIndividualChanges = numberOfLinuxLineEndings + numberOfMacintoshLineEndings; } else if (numberOfLinuxLineEndings > numberOfWindowsLineEndings && numberOfLinuxLineEndings > numberOfMacintoshLineEndings) { replacementString = LinuxLineEndings; numberOfIndividualChanges = numberOfWindowsLineEndings + numberOfMacintoshLineEndings; } else { replacementString = MacintoshLineEndings; numberOfIndividualChanges = numberOfWindowsLineEndings + numberOfLinuxLineEndings; } break; } string modifiedText = Regex.Replace(text, LineEndingsPattern, replacementString); numberOfChanges += numberOfIndividualChanges; return(modifiedText); }
public SerialPortTerminalCore([NotNull] SerialPort Port, Encoding Encoding, LineEndings Ending = LineEndings.LF, int BaudRate = 115200) { _port = Port; _port.Open(); _port.ReadTimeout = 200; _port.BaudRate = BaudRate; Output = new StreamReader(_port.BaseStream, Encoding); Input = new StreamWriter(_port.BaseStream, Encoding) { AutoFlush = true, NewLine = Ending.GetString() }; }
/// <summary> /// Initiates the RESTar interface /// </summary> /// <param name="port">The port that RESTar should listen on</param> /// <param name="uri">The URI that RESTar should listen on. E.g. '/rest'</param> /// <param name="configFilePath">The path to the config file containing API keys and /// allowed origins</param> /// <param name="prettyPrint">Should JSON output be pretty print formatted as default? /// (can be changed in settings during runtime)</param> /// <param name="daysToSaveErrors">The number of days to save errors in the Error resource</param> /// <param name="requireApiKey">Should the REST API require an API key?</param> /// <param name="allowAllOrigins">Should any origin be allowed to make CORS requests?</param> /// <param name="lineEndings">The line endings to use when writing JSON</param> /// <param name="entityResourceProviders">External entity resource providers for the RESTar instance</param> /// <param name="protocolProviders">External protocol providers for the RESTar instance</param> /// <param name="contentTypeProviders">External content type providers for the RESTar instance</param> public static void Init ( ushort port = 8282, string uri = "/rest", bool requireApiKey = false, bool allowAllOrigins = true, string configFilePath = null, bool prettyPrint = true, ushort daysToSaveErrors = 30, LineEndings lineEndings = LineEndings.Windows, IEnumerable <IEntityResourceProvider> entityResourceProviders = null, IEnumerable <IProtocolProvider> protocolProviders = null, IEnumerable <IContentTypeProvider> contentTypeProviders = null ) { try { ProcessUri(ref uri); Settings.Init(port, uri, false, prettyPrint, daysToSaveErrors, lineEndings); Log.Init(); DynamitConfig.Init(true, true); ResourceFactory.MakeResources(entityResourceProviders?.ToArray()); ContentTypeController.SetupContentTypeProviders(contentTypeProviders?.ToList()); ProtocolController.SetupProtocolProviders(protocolProviders?.ToList()); RequireApiKey = requireApiKey; AllowAllOrigins = allowAllOrigins; ConfigFilePath = configFilePath; NetworkController.AddNetworkBindings(new ScNetworkProvider()); Initialized = true; UpdateConfiguration(); DatabaseIndex.Init(); DbOutputFormat.Init(); ResourceFactory.BindControllers(); ResourceFactory.FinalCheck(); ProtocolController.OnInit(); Webhook.Check(); WebhookLogSettings.Init(); RegisterStaticIndexes(); RunCustomMigrationLogic(); } catch { Initialized = false; RequireApiKey = default; AllowAllOrigins = default; ConfigFilePath = default; NetworkController.RemoveNetworkBindings(); Settings.Clear(); NewState(); throw; } }
private static EolStyle GetEolStyle() { int value = EditorPrefs.GetInt(targetKeyName); if ((EolStyle)value == EolStyle.Default) { return(LineEndings.GetDefaultOSLineEnding()); } else { return((EolStyle)value); } }
bool IsNewLine(BlockReader blockReader, LineEndings lineEndings, ICharacterReader charReader, long position, out long begin, out long end) { begin = -1; end = -1; uint v = blockReader.ReadValue(position); if (v == LineEndings.CR) { begin = position; position += blockReader.MinCodePointSize; end = position; if (position < blockReader.StreamLength) { v = blockReader.ReadValue(position); if (v == LineEndings.LF) { end += blockReader.MinCodePointSize; } } return(true); } else if (v == LineEndings.LF) { begin = position; end = position + blockReader.MinCodePointSize; position -= blockReader.MinCodePointSize; if (position >= 0) { v = blockReader.ReadValue(position); if (v == LineEndings.CR) { begin = position; } } return(true); } else { if (charReader.TryReadCharacter(blockReader, position, v, out uint ch, out long first, out long last)) { if (lineEndings.IsLNewLine(ch)) { begin = blockReader.PositionFirstByte(first); end = blockReader.PositionFirstByte(last) + blockReader.MinCodePointSize; return(true); } } } return(false); }
public static string ChangeLineEndings(string text, LineEndings lineEndings, ref int numberOfChanges, out int numberOfIndividualChanges, out int numberOfAllLineEndings) { numberOfIndividualChanges = 0; string replacementString = string.Empty; numberOfAllLineEndings = Regex.Matches(text, LineEndingsPattern).Count; var numberOfWindowsLineEndings = Regex.Matches(text, WindowsLineEndings).Count; var numberOfLinuxLineEndings = Regex.Matches(text, LinuxLineEndings).Count - numberOfWindowsLineEndings; var numberOfMacintoshLineEndings = Regex.Matches(text, MacintoshLineEndings).Count - numberOfWindowsLineEndings; switch (lineEndings) { case LineEndings.Linux: replacementString = LinuxLineEndings; numberOfIndividualChanges = numberOfWindowsLineEndings + numberOfMacintoshLineEndings; break; case LineEndings.Windows: replacementString = WindowsLineEndings; numberOfIndividualChanges = numberOfLinuxLineEndings + numberOfMacintoshLineEndings; break; case LineEndings.Macintosh: replacementString = MacintoshLineEndings; numberOfIndividualChanges = numberOfWindowsLineEndings + numberOfLinuxLineEndings; break; case LineEndings.Dominant: if (numberOfWindowsLineEndings > numberOfLinuxLineEndings && numberOfWindowsLineEndings > numberOfMacintoshLineEndings) { replacementString = WindowsLineEndings; numberOfIndividualChanges = numberOfLinuxLineEndings + numberOfMacintoshLineEndings; } else if (numberOfLinuxLineEndings > numberOfWindowsLineEndings && numberOfLinuxLineEndings > numberOfMacintoshLineEndings) { replacementString = LinuxLineEndings; numberOfIndividualChanges = numberOfWindowsLineEndings + numberOfMacintoshLineEndings; } else { replacementString = MacintoshLineEndings; numberOfIndividualChanges = numberOfWindowsLineEndings + numberOfLinuxLineEndings; } break; } string modifiedText = Regex.Replace(text, LineEndingsPattern, replacementString); numberOfChanges += numberOfIndividualChanges; return modifiedText; }
public LineReader(Stream stream, Encoding encoding) { this.encoding = encoding; switch (encoding.WebName) { case "utf-8": blockReader = new BlockReader(stream); lineEndings = new UnicodeLineEndings(); charReader = new UTF8CharacterReader(); break; case "utf-16": blockReader = new BlockReader16(stream, false); lineEndings = new UnicodeLineEndings(); charReader = new UTF16CharacterReader(); break; case "utf-16BE": blockReader = new BlockReader16(stream, true); lineEndings = new UnicodeLineEndings(); charReader = new UTF16CharacterReader(); break; case "utf-32": blockReader = new BlockReader32(stream, false); lineEndings = new UnicodeLineEndings(); charReader = new UTF32CharacterReader(); break; case "utf-32BE": blockReader = new BlockReader32(stream, true); lineEndings = new UnicodeLineEndings(); charReader = new UTF32CharacterReader(); break; default: blockReader = new BlockReader(stream); lineEndings = new LineEndings(); charReader = new SimpleCharacterReader(); break; } InitNewLineMarker(); TrimCharacters = lineEndings.CodePoints .Where(c => c <= char.MaxValue && !char.IsSurrogate((char)c)) .Select(c => (char)c) .Concat(new char[] { BOM }) .ToArray(); }
private LineEndingsMode Convert(LineEndings lineEndings) { switch (lineEndings) { case LineEndings.Unix: return(LineEndingsMode.Unix); case LineEndings.Windows: return(LineEndingsMode.Windows); default: Debug.LogErrorFormat("Found unknown line endings type {0}", lineEndings); return(LineEndingsMode.Unix); } }
internal static void Init(ushort port, string uri, bool viewEnabled, bool prettyPrint, int daysToSaveErrors, LineEndings lineEndings) => Db.TransactAsync(() => { Clear(); new Settings { Port = port, Uri = uri, ViewEnabled = viewEnabled, PrettyPrint = prettyPrint, DaysToSaveErrors = daysToSaveErrors, LineEndings = lineEndings, TempFilePath = Path.GetTempPath(), RESTarVersion = RESTarConfig.Version }; });
public static string ChangeLineEndings(string line, LineEndings lineEndings, ref int numberOfChanges, out int numberOfIndividualChanges) { numberOfIndividualChanges = 0; switch (lineEndings) { case LineEndings.Linux: numberOfIndividualChanges += line.Count(x => x == '\r'); line = line.Replace("\r\n", "\n").Replace('\r', '\n'); break; case LineEndings.Windows: for (int i = 0; i < line.Length; i++) { if (line[i] == '\r') { if (i < line.Length - 1 && line[i + 1] != '\n') { numberOfIndividualChanges++; line = line.Insert(i + 1, "\n"); i++; } else if (i == line.Length - 1) { numberOfIndividualChanges++; line = line.Insert(i + 1, "\n"); } } else if (line[i] == '\n' && i > 0 && line[i - 1] != '\r') { numberOfIndividualChanges++; line = line.Insert(i, "\r"); i++; } } break; case LineEndings.Macintosh: numberOfIndividualChanges += line.Count(x => x == '\n'); line = line.Replace("\r\n", "\r").Replace('\n', '\r'); break; } numberOfChanges += numberOfIndividualChanges; return(line); }
private void SuccessWithEncodingAndLineEndings(OutputEncodingType encoding, LineEndings lineEndings) { string filename = GetCurrentTestResultsFilePath("out.txt"); FileInfo file = GetTestFile("TextFileWithNewlines.txt"); TestLineProcessor p = new TestLineProcessor(filename, lineEndings, encoding, overwriteExistingFile: true, moveOriginalToRecyclingBin: false); p.Init(RunInfo); ProcessingResult result = p.Process(file, MatchResultType.Yes, new string[0], new FileInfo[0], ProcessInput.OriginalFile, CancellationToken.None); Assert.AreEqual(ProcessingResultType.Success, result.Type); Assert.AreEqual(1, result.OutputFiles.Length); p.Cleanup(); }
private void Success(LineEndings lineEndings, OutputEncodingType outputEncoding, string inputFilename) { FileInfo file = GetTestFile(inputFilename); RemoveRepeatedLinesProcessor processor = new RemoveRepeatedLinesProcessor(); processor.SetParameter("LineEndings", lineEndings); processor.SetParameter("OutputEncoding", outputEncoding); processor.SetParameter("FileName", GetCurrentTestResultsFilePath("out.txt")); processor.SetParameter("OverwriteExistingFile", false); processor.SetParameter("MoveOriginalToRecycleBin", false); processor.Init(RunInfo); ProcessingResult result = processor.Process(file, MatchResultType.Yes, new string[0], new FileInfo[0], ProcessInput.OriginalFile, CancellationToken.None); processor.Cleanup(); Assert.AreEqual(ProcessingResultType.Success, result.Type); Assert.AreEqual(1, result.OutputFiles.Length); }
/// Changes all of the line endings in the provided text into the specified format public static string NormalizeLineEndings(string textToFix, LineEndings lineEndings) { //Transform all the line endings into Unix so it's easier to manage in the next step textToFix = textToFix.Replace(WINDOWS_LINE_ENDINGS, UNIX_LINE_ENDINGS); //Perform the final transformation switch (lineEndings) { case LineEndings.windows: textToFix = textToFix.Replace(UNIX_LINE_ENDINGS, WINDOWS_LINE_ENDINGS); break; case LineEndings.unix: //Do nothing break; } //Return the result return(textToFix); }
public static string GetNewline(FileInfo file, LineEndings lineEndings) { switch (lineEndings) { case LineEndings.MatchInput: if (file == null) { return(Environment.NewLine); } using (StreamReader reader = new StreamReader(file.OpenRead())) { DetectedLineEndings detected = GetLineEndings(reader, true, CancellationToken.None); switch (detected) { case DetectedLineEndings.Windows: return("\r\n"); case DetectedLineEndings.Unix: return("\n"); case DetectedLineEndings.ClassicMacOS: return("\r"); default: return(Environment.NewLine); } } case LineEndings.Windows: return("\r\n"); case LineEndings.Unix: return("\n"); case LineEndings.ClassicMacOS: return("\r"); default: return(Environment.NewLine); } }
protected virtual void UpdateLineEnds() { if (Vertex.Get("BackgroundColor:") != null) { BackgroundColor = UIWpf.GetBrushFromColorVertex(Vertex.Get("BackgroundColor:")); } else { BackgroundColor = (Brush)Line.FindResource("0BackgroundBrush"); } if (Vertex.Get("ForegroundColor:") != null) { ForegroundColor = UIWpf.GetBrushFromColorVertex(Vertex.Get("ForegroundColor:")); } else { ForegroundColor = (Brush)Line.FindResource("0ForegroundBrush"); } LineEndings.Stroke = ForegroundColor; Line.Stroke = ForegroundColor; Label.Foreground = ForegroundColor; string StartAnchor = (string)GraphUtil.GetValue(Vertex.Get(@"StartAnchor:")); string EndAnchor = (string)GraphUtil.GetValue(Vertex.Get(@"EndAnchor:")); if (StartAnchor == "Straight") { LineEndings.StartEnding = LineEndEnum.Straight; Line.StartEnding = LineEndEnum.Straight; } if (EndAnchor == "Straight") { LineEndings.EndEnding = LineEndEnum.Straight; Line.EndEnding = LineEndEnum.Straight; } if (StartAnchor == "Arrow") { LineEndings.StartEnding = LineEndEnum.Arrow; Line.StartEnding = LineEndEnum.Arrow; } if (EndAnchor == "Arrow") { LineEndings.EndEnding = LineEndEnum.Arrow; Line.EndEnding = LineEndEnum.Arrow; } if (StartAnchor == "Triangle") { LineEndings.StartEnding = LineEndEnum.Triangle; Line.StartEnding = LineEndEnum.Triangle; FillBrush = BackgroundColor; HighlightFillBrush = BackgroundColor; } if (EndAnchor == "Triangle") { LineEndings.EndEnding = LineEndEnum.Triangle; Line.EndEnding = LineEndEnum.Triangle; FillBrush = BackgroundColor; HighlightFillBrush = BackgroundColor; } if (StartAnchor == "FilledTriangle") { LineEndings.StartEnding = LineEndEnum.FilledTriangle; Line.StartEnding = LineEndEnum.FilledTriangle; FillBrush = ForegroundColor; HighlightFillBrush = (Brush)LineEndings.FindResource("0LightHighlightBrush"); } if (EndAnchor == "FilledTriangle") { LineEndings.EndEnding = LineEndEnum.FilledTriangle; Line.EndEnding = LineEndEnum.FilledTriangle; FillBrush = ForegroundColor; HighlightFillBrush = (Brush)LineEndings.FindResource("0LightHighlightBrush"); } if (StartAnchor == "Diamond") { LineEndings.StartEnding = LineEndEnum.Diamond; Line.StartEnding = LineEndEnum.Diamond; FillBrush = BackgroundColor; HighlightFillBrush = BackgroundColor; } if (EndAnchor == "Diamond") { LineEndings.EndEnding = LineEndEnum.Diamond; Line.EndEnding = LineEndEnum.Diamond; FillBrush = BackgroundColor; HighlightFillBrush = BackgroundColor; } if (StartAnchor == "FilledDiamond") { LineEndings.StartEnding = LineEndEnum.FilledDiamond; Line.StartEnding = LineEndEnum.FilledDiamond; FillBrush = ForegroundColor; HighlightFillBrush = (Brush)LineEndings.FindResource("0LightHighlightBrush"); } if (EndAnchor == "FilledDiamond") { LineEndings.EndEnding = LineEndEnum.FilledDiamond; Line.EndEnding = LineEndEnum.FilledDiamond; FillBrush = ForegroundColor; HighlightFillBrush = (Brush)LineEndings.FindResource("0LightHighlightBrush"); } if (FillBrush != null) { LineEndings.Fill = FillBrush; } LineEndings.ArrowLength = 0; Line.ArrowLength = 0; LineEndings.ArrowLength = 15; Line.ArrowLength = 15; }
/// <summary> /// Convert the line endings of a string to another format. /// </summary> /// <param name="inputText"></param> /// <param name="endings"></param> /// <returns></returns> protected virtual async Task <string> ConvertLineEndingsAsync(string inputText, LineEndings endings) { const char carriageReturnChar = (char)13; const char lineFeedChar = (char)10; StringWriter writer = new StringWriter(); switch (endings) { case LineEndings.Macintosh: writer.NewLine = carriageReturnChar.ToString(); break; case LineEndings.Unix: writer.NewLine = lineFeedChar.ToString(); break; case LineEndings.Windows: writer.NewLine = new string(new char[] { carriageReturnChar, lineFeedChar }); break; } if (this.OutputLineEndings != LineEndings.Default) { await Task.Run(() => { StringReader reader = new StringReader(inputText); string currentLine; while ((currentLine = reader.ReadLine()) != null) { writer.WriteLine(currentLine); } }); return(writer.ToString()); } else { return(inputText); } }
private static void ConvertLineEndings(string path) { EolStyle targetEnding = GetEolStyle(); LineEndings.ConvertAll(path, extensions, targetEnding); }
/// <summary> /// Convert the line endings of a string to another format. /// </summary> /// <param name="inputText"></param> /// <param name="endings"></param> /// <returns></returns> protected virtual async Task<string> ConvertLineEndingsAsync(string inputText, LineEndings endings) { const char carriageReturnChar = (char)13; const char lineFeedChar = (char)10; StringWriter writer = new StringWriter(); switch(endings) { case LineEndings.Macintosh: writer.NewLine = carriageReturnChar.ToString(); break; case LineEndings.Unix: writer.NewLine = lineFeedChar.ToString(); break; case LineEndings.Windows: writer.NewLine = new string(new char[] { carriageReturnChar, lineFeedChar}); break; } if (this.OutputLineEndings != LineEndings.Default) { await Task.Run(() => { StringReader reader = new StringReader(inputText); string currentLine; while ((currentLine = reader.ReadLine()) != null) { writer.WriteLine(currentLine); } }); return writer.ToString(); } else { return inputText; } }
public static string GetString(this LineEndings Ending) { return(_lineEndingStrings[Ending]); }
public void LoadDefaults() { // Line Endings and Serialization this.projectLineEndings = LineEndings.Unix; this.forceSerializationMode = true; this.serializationMode = SerializationMode.ForceText; // Source Control Ignore File this.sourceControlType = SourceControlType.Plastic; this.ignoreTemplateP4 = EditorUtil.GetAssetByGuid <TextAsset>("6d6c8d3e6aeaff34d89c7f2be0a80a0d"); this.ignoreTemplateGit = EditorUtil.GetAssetByGuid <TextAsset>("fae63426d3cf11c4cb39244488e2ec17"); this.ignoreTemplateCollab = EditorUtil.GetAssetByGuid <TextAsset>("075673ae8dd02af42b6e15b9f718e0a7"); this.ignoreTemplatePlastic = EditorUtil.GetAssetByGuid <TextAsset>("aafcbe005eaa6754b921e846efb9043d"); this.p4IgnoreFileName = ".p4ignore"; this.autosetP4IgnoreEnvironmentVariable = true; // Template File Overriding this.overrideTemplateFiles = true; this.templateMonoBehaviour = EditorUtil.GetAssetByGuid <TextAsset>("5ec2f7fdcef1e6f45b2c1a7510be3eaa"); this.templatePlayableAsset = EditorUtil.GetAssetByGuid <TextAsset>("e4d5fd6d65c83d24da92fbd00d7f5499"); this.templatePlayableBehaviour = EditorUtil.GetAssetByGuid <TextAsset>("6ccc7dcc8373b7f4197de5cd7d7e7a16"); this.templateStateMachineBehaviour = EditorUtil.GetAssetByGuid <TextAsset>("fed9948eb87d1be48ae323bd48cf729f"); this.templateSubStateMachineBehaviour = EditorUtil.GetAssetByGuid <TextAsset>("09afd0c31b0565e4a8a74ecb68ceef24"); this.templateEditorTestScript = EditorUtil.GetAssetByGuid <TextAsset>("c31e8a34fb6708144809d22dffdc73f6"); // Editorconfig this.useEditorConfig = true; this.editorConfigFileName = ".editorconfig"; this.editorConfigTemplate = EditorUtil.GetAssetByGuid <TextAsset>("f6c774b1ff43524428c88bc6afaca2d7"); // PlasticSCM Settings this.plasticAutoSetFileCasingError = true; this.plasticAutoSetYamlMergeToolPath = true; // Analyzers this.analyzers = new List <Analyzer> { new Analyzer() { Name = "StyleCop", Ruleset = EditorUtil.GetAssetByGuid <TextAsset>("6d22bf8a5b4217246a8bd27939b3a093"), Config = EditorUtil.GetAssetByGuid <TextAsset>("447a0d2defa062a4cb1ab9f0a161d7f7"), DLLs = new List <TextAsset> { EditorUtil.GetAssetByGuid <TextAsset>("34b2bcdbab6772c43803d97146553550"), EditorUtil.GetAssetByGuid <TextAsset>("fdf22cdd44a87ed4f9ae0c0d6e685ae6"), EditorUtil.GetAssetByGuid <TextAsset>("d86a7268d4b5874478f3bf9019de4dd3"), }, CSProjects = new List <string> { // "Assembly-CSharp", // "Assembly-CSharp.Player", // "Assembly-CSharp-Editor", "LostLibrary", "LostLibrary.Editor", "LostLibrary.LBE", "LostLibrary.LBE.Player", "LostLibrary.Player", "LostLibrary.Test", }, } }; }
public ConversionOptions GetConfiguration() { var options = new ConversionOptions(); if (Path.HasValue()) { options.Paths = Path.Values; } if (File.HasValue()) { options.Files = File.Values; } if (List.HasValue()) { options.ListFile = List.Value(); } if (options.Paths.Count == 0 && options.Files.Count == 0 && String.IsNullOrEmpty(options.ListFile)) { throw new ConfigurationException("Nothing to process, must specify one of --path, --file or --list"); } if (IndentStyle.HasValue()) { var style = IndentStyle.Value().ToLower(); if (style == "tabs") { options.Indentation = IndentationStyle.Tabs; } else if (style == "spaces") { options.Indentation = IndentationStyle.Spaces; } else if (style == "leave") { options.Indentation = IndentationStyle.Leave; } else { throw new ConfigurationException($"'{style}' is an invalid indentation style"); } } if (LineEndings.HasValue()) { var lineEndingStyle = LineEndings.Value().ToLower(); if (lineEndingStyle == "crlf") { options.LineEndingStyle = LineEnding.CRLF; } else if (lineEndingStyle == "lf") { options.LineEndingStyle = LineEnding.LF; } else { throw new ConfigurationException("Line Endings must be crlf or lf"); } } options.StripTrailingSpaces = StripTrailingSpaces.HasValue(); // no point going any further if one of the change options isn't actually specified if (options.StripTrailingSpaces == false && options.Indentation == IndentationStyle.Leave && options.LineEndingStyle == LineEnding.Leave) { throw new ConfigurationException("Nothing to do, you must specify one of --strip-trailing-spaces, --line-endings or --indent"); } if (TabWidth.HasValue()) { if (!Int32.TryParse(TabWidth.Value(), out int tabWidth)) { throw new ConfigurationException("tabwidth must be a valid number"); } options.TabWidth = tabWidth; } if (IncludeExtensions.HasValue()) { options.IncludeExtensions = ParseFileExtensionsOption(IncludeExtensions.Values); } if (ExcludeExtensions.HasValue()) { options.ExcludeExtensions = ParseFileExtensionsOption(ExcludeExtensions.Values); } if (ExcludeFolders.HasValue()) { options.ExcludeFolders = ExcludeFolders.Values; } // the presence of recurse|dryrun means it's on, there is no value options.Recurse = Recurse.HasValue(); options.DryRun = DryRun.HasValue(); options.Verbose = Verbose.HasValue(); return(options); }