mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-09 16:06:08 +02:00
Fix warnings
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<IsRoslynComponent>true</IsRoslynComponent>
|
<IsRoslynComponent>true</IsRoslynComponent>
|
||||||
|
|||||||
@@ -190,7 +190,9 @@ internal sealed class RuntimeInformation
|
|||||||
IsInFunction = false;
|
IsInFunction = false;
|
||||||
IsLocalSearch = false;
|
IsLocalSearch = false;
|
||||||
LineNumber = 0;
|
LineNumber = 0;
|
||||||
|
#pragma warning disable S2696 // internalTaskId is a shared counter intentionally incremented by each Reset call
|
||||||
TaskId = ++internalTaskId;
|
TaskId = ++internalTaskId;
|
||||||
|
#pragma warning restore S2696
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParentRuntimeInformation_OnExit(string exitMessage, bool stopAllTasks)
|
private void ParentRuntimeInformation_OnExit(string exitMessage, bool stopAllTasks)
|
||||||
|
|||||||
@@ -439,9 +439,11 @@ public class YesNtInterpreter
|
|||||||
string content = runtimeInfo.Lines[i].Content;
|
string content = runtimeInfo.Lines[i].Content;
|
||||||
List<StatementHandler> matchingHandlers = [];
|
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)
|
foreach (StatementHandler handler in statementHandlers)
|
||||||
{
|
{
|
||||||
if (IsPossibleMatch(content, handler))
|
if (IsPossibleMatch(content, handler))
|
||||||
|
#pragma warning restore S3267
|
||||||
{
|
{
|
||||||
matchingHandlers.Add(handler);
|
matchingHandlers.Add(handler);
|
||||||
|
|
||||||
@@ -458,14 +460,11 @@ public class YesNtInterpreter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Track block ends
|
// 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 = endStack.Pop();
|
||||||
{
|
runtimeInfo.BlockBoundaries[startLine] = i;
|
||||||
int startLine = stack.Pop();
|
runtimeInfo.BlockBoundaries[i] = startLine;
|
||||||
runtimeInfo.BlockBoundaries[startLine] = i;
|
|
||||||
runtimeInfo.BlockBoundaries[i] = startLine;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track block intermediates (e.g., else:): pop the opener, record boundary, push self
|
// Track block intermediates (e.g., else:): pop the opener, record boundary, push self
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ internal class CodeFlowStatements : StatementRuntimeInformation
|
|||||||
[Statement("end_if", SearchMode.Exact, SpaceAround.None, ConsoleColor.Green, IsBlockEnd = true)]
|
[Statement("end_if", SearchMode.Exact, SpaceAround.None, ConsoleColor.Green, IsBlockEnd = true)]
|
||||||
public void EndIf(string _)
|
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")]
|
[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);
|
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++)
|
for (int i = 0; i < args.Length; i++)
|
||||||
{
|
{
|
||||||
char current = args[i];
|
char current = args[i];
|
||||||
@@ -50,6 +51,7 @@ internal class StringLiteralStatements : StatementRuntimeInformation
|
|||||||
|
|
||||||
_ = literal.Append(ch);
|
_ = literal.Append(ch);
|
||||||
}
|
}
|
||||||
|
#pragma warning restore S127
|
||||||
|
|
||||||
if (!closed)
|
if (!closed)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Threading;
|
|||||||
|
|
||||||
namespace YesNt.Interpreter.Utilities;
|
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);
|
public delegate void DataReceivedEventHandler(object sender, DataReceivedEventArgs e);
|
||||||
|
|
||||||
internal delegate void UserCallBack(string data);
|
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
|
public class DataReceivedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
internal string _data;
|
internal string _data;
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ namespace YesNt.Interpreter.Utilities;
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static class StringExtensions
|
public static class StringExtensions
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<string, string> reverseReplacementRules;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the table that maps special characters to their safe-string escape codes.
|
/// 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.
|
/// Keys are the original characters; values are the three-letter tilde codes.
|
||||||
@@ -50,10 +48,7 @@ public static class StringExtensions
|
|||||||
{"", "\x01" + "emp" + "\x01" },
|
{"", "\x01" + "emp" + "\x01" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static StringExtensions()
|
private static readonly Dictionary<string, string> reverseReplacementRules = ReplacementRules.ToDictionary(x => x.Value, x => x.Key);
|
||||||
{
|
|
||||||
reverseReplacementRules = ReplacementRules.ToDictionary(x => x.Value, x => x.Key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Encodes a string into safe-string format so that special characters cannot accidentally
|
/// 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);
|
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++)
|
for (int i = 0; i < stripped.Length; i++)
|
||||||
{
|
{
|
||||||
if (stripped[i] == '\x01' && i + 4 < stripped.Length && stripped[i + 4] == '\x01')
|
if (stripped[i] == '\x01' && i + 4 < stripped.Length && stripped[i + 4] == '\x01')
|
||||||
@@ -124,6 +120,7 @@ public static class StringExtensions
|
|||||||
|
|
||||||
_ = output.Append(stripped[i]);
|
_ = output.Append(stripped[i]);
|
||||||
}
|
}
|
||||||
|
#pragma warning restore S127
|
||||||
|
|
||||||
return output.ToString();
|
return output.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user