mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-04 09:06:41 +02:00
Fix warnings
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsRoslynComponent>true</IsRoslynComponent>
|
||||
|
||||
@@ -190,7 +190,9 @@ internal sealed class RuntimeInformation
|
||||
IsInFunction = false;
|
||||
IsLocalSearch = false;
|
||||
LineNumber = 0;
|
||||
#pragma warning disable S2696 // internalTaskId is a shared counter intentionally incremented by each Reset call
|
||||
TaskId = ++internalTaskId;
|
||||
#pragma warning restore S2696
|
||||
}
|
||||
|
||||
private void ParentRuntimeInformation_OnExit(string exitMessage, bool stopAllTasks)
|
||||
|
||||
@@ -439,9 +439,11 @@ public class YesNtInterpreter
|
||||
string content = runtimeInfo.Lines[i].Content;
|
||||
List<StatementHandler> matchingHandlers = [];
|
||||
|
||||
#pragma warning disable S3267 // foreach + if is intentional here; LINQ .Where() would add overhead in this scan loop
|
||||
foreach (StatementHandler handler in statementHandlers)
|
||||
{
|
||||
if (IsPossibleMatch(content, handler))
|
||||
#pragma warning restore S3267
|
||||
{
|
||||
matchingHandlers.Add(handler);
|
||||
|
||||
@@ -458,15 +460,12 @@ public class YesNtInterpreter
|
||||
}
|
||||
|
||||
// Track block ends
|
||||
if (handler.Attribute.IsBlockEnd)
|
||||
if (handler.Attribute.IsBlockEnd && openBlocks.TryGetValue(handler.Attribute.Name, out Stack<int> endStack) && endStack.Count > 0)
|
||||
{
|
||||
if (openBlocks.TryGetValue(handler.Attribute.Name, out Stack<int> stack) && stack.Count > 0)
|
||||
{
|
||||
int startLine = stack.Pop();
|
||||
int startLine = endStack.Pop();
|
||||
runtimeInfo.BlockBoundaries[startLine] = i;
|
||||
runtimeInfo.BlockBoundaries[i] = startLine;
|
||||
}
|
||||
}
|
||||
|
||||
// Track block intermediates (e.g., else:): pop the opener, record boundary, push self
|
||||
if (handler.Attribute.IsBlockIntermediate)
|
||||
|
||||
@@ -170,6 +170,7 @@ internal class CodeFlowStatements : StatementRuntimeInformation
|
||||
[Statement("end_if", SearchMode.Exact, SpaceAround.None, ConsoleColor.Green, IsBlockEnd = true)]
|
||||
public void EndIf(string _)
|
||||
{
|
||||
// Intentionally empty: end_if is a block-boundary marker only; no runtime action needed.
|
||||
}
|
||||
|
||||
[Statement("while", SearchMode.StartOfLine, SpaceAround.End, ConsoleColor.Green, Priority = Priority.VeryLow, Separator = ":", BlockPair = "end_while")]
|
||||
|
||||
@@ -19,6 +19,7 @@ internal class StringLiteralStatements : StatementRuntimeInformation
|
||||
|
||||
StringBuilder output = new StringBuilder(args.Length);
|
||||
|
||||
#pragma warning disable S127 // i is intentionally advanced to track position within quoted literals and escape sequences
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
char current = args[i];
|
||||
@@ -50,6 +51,7 @@ internal class StringLiteralStatements : StatementRuntimeInformation
|
||||
|
||||
_ = literal.Append(ch);
|
||||
}
|
||||
#pragma warning restore S127
|
||||
|
||||
if (!closed)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Threading;
|
||||
|
||||
namespace YesNt.Interpreter.Utilities;
|
||||
|
||||
/// <summary>Represents the method that handles the <see cref="FixedProcess.OutputDataReceived"/> and <see cref="FixedProcess.ErrorDataReceived"/> events.</summary>
|
||||
public delegate void DataReceivedEventHandler(object sender, DataReceivedEventArgs e);
|
||||
|
||||
internal delegate void UserCallBack(string data);
|
||||
@@ -81,6 +82,7 @@ internal class FixedProcess : Process
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Provides data for the <see cref="FixedProcess.OutputDataReceived"/> and <see cref="FixedProcess.ErrorDataReceived"/> events.</summary>
|
||||
public class DataReceivedEventArgs : EventArgs
|
||||
{
|
||||
internal string _data;
|
||||
|
||||
@@ -25,8 +25,6 @@ namespace YesNt.Interpreter.Utilities;
|
||||
/// </remarks>
|
||||
public static class StringExtensions
|
||||
{
|
||||
private static readonly Dictionary<string, string> reverseReplacementRules;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the table that maps special characters to their safe-string escape codes.
|
||||
/// Keys are the original characters; values are the three-letter tilde codes.
|
||||
@@ -50,10 +48,7 @@ public static class StringExtensions
|
||||
{"", "\x01" + "emp" + "\x01" },
|
||||
};
|
||||
|
||||
static StringExtensions()
|
||||
{
|
||||
reverseReplacementRules = ReplacementRules.ToDictionary(x => x.Value, x => x.Key);
|
||||
}
|
||||
private static readonly Dictionary<string, string> reverseReplacementRules = ReplacementRules.ToDictionary(x => x.Value, x => x.Key);
|
||||
|
||||
/// <summary>
|
||||
/// Encodes a string into safe-string format so that special characters cannot accidentally
|
||||
@@ -109,6 +104,7 @@ public static class StringExtensions
|
||||
}
|
||||
|
||||
StringBuilder output = new StringBuilder(stripped.Length);
|
||||
#pragma warning disable S127 // i is intentionally advanced by 4 when a 5-char escape code is consumed
|
||||
for (int i = 0; i < stripped.Length; i++)
|
||||
{
|
||||
if (stripped[i] == '\x01' && i + 4 < stripped.Length && stripped[i + 4] == '\x01')
|
||||
@@ -124,6 +120,7 @@ public static class StringExtensions
|
||||
|
||||
_ = output.Append(stripped[i]);
|
||||
}
|
||||
#pragma warning restore S127
|
||||
|
||||
return output.ToString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user