From 9813426f0667c16108348334c077352f8f125b63 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Wed, 4 Mar 2026 18:12:08 +0100 Subject: [PATCH] Code cleanup --- YesNt.Interpreter.Generator/StatementRegistryGenerator.cs | 4 ++-- YesNt.Interpreter.Tests/YesNtAssert.cs | 2 +- YesNt.Interpreter/Runtime/YesNtInterpreter.cs | 4 ++-- YesNt.Interpreter/Utilities/FixedProcess.cs | 8 +++----- YesNt.Interpreter/Utilities/StringExtentions.cs | 2 -- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/YesNt.Interpreter.Generator/StatementRegistryGenerator.cs b/YesNt.Interpreter.Generator/StatementRegistryGenerator.cs index a228de1..dbf028f 100644 --- a/YesNt.Interpreter.Generator/StatementRegistryGenerator.cs +++ b/YesNt.Interpreter.Generator/StatementRegistryGenerator.cs @@ -1,10 +1,10 @@ +using Microsoft.CodeAnalysis; + using System; using System.Collections.Generic; using System.Linq; using System.Text; -using Microsoft.CodeAnalysis; - namespace YesNt.Interpreter.Generator; [Generator] diff --git a/YesNt.Interpreter.Tests/YesNtAssert.cs b/YesNt.Interpreter.Tests/YesNtAssert.cs index 25c86f3..75380e7 100644 --- a/YesNt.Interpreter.Tests/YesNtAssert.cs +++ b/YesNt.Interpreter.Tests/YesNtAssert.cs @@ -2,8 +2,8 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; -using System.Text.RegularExpressions; using System.Text; +using System.Text.RegularExpressions; using System.Threading; using YesNt.Interpreter.Runtime; diff --git a/YesNt.Interpreter/Runtime/YesNtInterpreter.cs b/YesNt.Interpreter/Runtime/YesNtInterpreter.cs index da6aa9a..28192bd 100644 --- a/YesNt.Interpreter/Runtime/YesNtInterpreter.cs +++ b/YesNt.Interpreter/Runtime/YesNtInterpreter.cs @@ -160,7 +160,7 @@ public class YesNtInterpreter { if (statementAttribute.SearchMode == SearchMode.StartOfLine && runtimeInfo.CurrentLine.StartsWith(name)) { - string copyLine = statementAttribute.KeepStatementInArgs ? runtimeInfo.CurrentLine : runtimeInfo.CurrentLine.Remove(0, name.Length); + string copyLine = statementAttribute.KeepStatementInArgs ? runtimeInfo.CurrentLine : runtimeInfo.CurrentLine[name.Length..]; statement.Value.Invoke(copyLine); statementFound = true; } @@ -172,7 +172,7 @@ public class YesNtInterpreter } else if (statementAttribute.SearchMode == SearchMode.EndOfLine && runtimeInfo.CurrentLine.EndsWith(name)) { - string copyLine = statementAttribute.KeepStatementInArgs ? runtimeInfo.CurrentLine : runtimeInfo.CurrentLine.Remove(runtimeInfo.CurrentLine.Length - name.Length); + string copyLine = statementAttribute.KeepStatementInArgs ? runtimeInfo.CurrentLine : runtimeInfo.CurrentLine[..^name.Length]; statement.Value.Invoke(copyLine); statementFound = true; } diff --git a/YesNt.Interpreter/Utilities/FixedProcess.cs b/YesNt.Interpreter/Utilities/FixedProcess.cs index 1117d27..28b401a 100644 --- a/YesNt.Interpreter/Utilities/FixedProcess.cs +++ b/YesNt.Interpreter/Utilities/FixedProcess.cs @@ -170,11 +170,9 @@ internal class AsyncStreamReader : IDisposable byteBuffer = null; charBuffer = null; } - if (eofEvent != null) - { - eofEvent.Close(); - eofEvent = null; - } + + eofEvent?.Close(); + eofEvent = null; } private void Init(Stream stream, UserCallBack callback, Encoding encoding, int bufferSize) diff --git a/YesNt.Interpreter/Utilities/StringExtentions.cs b/YesNt.Interpreter/Utilities/StringExtentions.cs index 49d00f9..a28f1ea 100644 --- a/YesNt.Interpreter/Utilities/StringExtentions.cs +++ b/YesNt.Interpreter/Utilities/StringExtentions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Text; @@ -30,7 +29,6 @@ public static class StringExtensions {"", "~emp" }, }; - [SuppressMessage("Minor Code Smell", "S3963:\"static\" fields should be initialized inline", Justification = "Doesn't work because it throws a TypeInitializationException")] static StringExtensions() { reverseReplacementRules = ReplacementRules.ToDictionary(x => x.Value, x => x.Key);