Skip to content

Commit 70f2e68

Browse files
committed
require .NET SDK version 8.0 or later
1 parent 6915e55 commit 70f2e68

File tree

2 files changed

+1
-72
lines changed

2 files changed

+1
-72
lines changed

src/Smdn.Net.MuninNode/Smdn.Net.MuninNode.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ SPDX-License-Identifier: MIT
1010
<PackageValidationBaselineVersion>1.2.0</PackageValidationBaselineVersion>
1111
<RootNamespace/> <!-- empty the root namespace so that the namespace is determined only by the directory name, for code style rule IDE0030 -->
1212
<Nullable>enable</Nullable>
13-
<DefineConstants
14-
Condition="$([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '7.0.0'))"
15-
>$(DefineConstants);LANG_VERSION_11_OR_GREATER</DefineConstants> <!-- required to use the UTF-8 string literals in C# 11 -->
1613
<NoWarn>CS1591;$(NoWarn)</NoWarn> <!-- CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' -->
1714
</PropertyGroup>
1815

src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/NodeBase.cs

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -457,20 +457,13 @@ static bool TryReadLine(ref ReadOnlySequence<byte> buffer, out ReadOnlySequence<
457457
var reader = new SequenceReader<byte>(buffer);
458458
const byte LF = (byte)'\n';
459459

460-
#pragma warning disable SA1003
461460
if (
462-
#if LANG_VERSION_11_OR_GREATER
463-
!reader.TryReadTo(out line, delimiter: "\r\n"u8, advancePastDelimiter: true)
464-
#else
465-
!reader.TryReadTo(out line, delimiter: CRLF.Span, advancePastDelimiter: true)
466-
#endif
467-
&&
461+
!reader.TryReadTo(out line, delimiter: "\r\n"u8, advancePastDelimiter: true) &&
468462
!reader.TryReadTo(out line, delimiter: LF, advancePastDelimiter: true)
469463
) {
470464
line = default;
471465
return false;
472466
}
473-
#pragma warning restore SA1003
474467

475468
#if SYSTEM_BUFFERS_SEQUENCEREADER_UNREADSEQUENCE
476469
buffer = reader.UnreadSequence;
@@ -482,10 +475,6 @@ static bool TryReadLine(ref ReadOnlySequence<byte> buffer, out ReadOnlySequence<
482475
}
483476
}
484477

485-
#if !LANG_VERSION_11_OR_GREATER
486-
private static readonly ReadOnlyMemory<byte> CRLF = Encoding.ASCII.GetBytes("\r\n");
487-
#endif
488-
489478
private static bool ExpectCommand(
490479
ReadOnlySequence<byte> commandLine,
491480
ReadOnlySpan<byte> expectedCommand,
@@ -521,7 +510,6 @@ out ReadOnlySequence<byte> arguments
521510

522511
private static readonly byte CommandQuitShort = (byte)'.';
523512

524-
#if LANG_VERSION_11_OR_GREATER
525513
private ValueTask RespondToCommandAsync(
526514
Socket client,
527515
ReadOnlySequence<byte> commandLine,
@@ -566,62 +554,6 @@ CancellationToken cancellationToken
566554
);
567555
}
568556
}
569-
#else
570-
private static readonly ReadOnlyMemory<byte> commandFetch = Encoding.ASCII.GetBytes("fetch");
571-
private static readonly ReadOnlyMemory<byte> commandNodes = Encoding.ASCII.GetBytes("nodes");
572-
private static readonly ReadOnlyMemory<byte> commandList = Encoding.ASCII.GetBytes("list");
573-
private static readonly ReadOnlyMemory<byte> commandConfig = Encoding.ASCII.GetBytes("config");
574-
private static readonly ReadOnlyMemory<byte> commandQuit = Encoding.ASCII.GetBytes("quit");
575-
private static readonly ReadOnlyMemory<byte> commandCap = Encoding.ASCII.GetBytes("cap");
576-
private static readonly ReadOnlyMemory<byte> commandVersion = Encoding.ASCII.GetBytes("version");
577-
578-
private ValueTask RespondToCommandAsync(
579-
Socket client,
580-
ReadOnlySequence<byte> commandLine,
581-
CancellationToken cancellationToken
582-
)
583-
{
584-
cancellationToken.ThrowIfCancellationRequested();
585-
586-
if (ExpectCommand(commandLine, commandFetch.Span, out var fetchArguments)) {
587-
return ProcessCommandFetchAsync(client, fetchArguments, cancellationToken);
588-
}
589-
else if (ExpectCommand(commandLine, commandNodes.Span, out _)) {
590-
return ProcessCommandNodesAsync(client, cancellationToken);
591-
}
592-
else if (ExpectCommand(commandLine, commandList.Span, out var listArguments)) {
593-
return ProcessCommandListAsync(client, listArguments, cancellationToken);
594-
}
595-
else if (ExpectCommand(commandLine, commandConfig.Span, out var configArguments)) {
596-
return ProcessCommandConfigAsync(client, configArguments, cancellationToken);
597-
}
598-
else if (
599-
ExpectCommand(commandLine, commandQuit.Span, out _) ||
600-
(commandLine.Length == 1 && commandLine.FirstSpan[0] == commandQuitShort)
601-
) {
602-
client.Close();
603-
#if SYSTEM_THREADING_TASKS_VALUETASK_COMPLETEDTASK
604-
return ValueTask.CompletedTask;
605-
#else
606-
return default;
607-
#endif
608-
}
609-
else if (ExpectCommand(commandLine, commandCap.Span, out var capArguments)) {
610-
return ProcessCommandCapAsync(client, capArguments, cancellationToken);
611-
}
612-
else if (ExpectCommand(commandLine, commandVersion.Span, out _)) {
613-
return ProcessCommandVersionAsync(client, cancellationToken);
614-
}
615-
else {
616-
return SendResponseAsync(
617-
client: client,
618-
encoding: Encoding,
619-
responseLine: "# Unknown command. Try cap, list, nodes, config, fetch, version or quit",
620-
cancellationToken: cancellationToken
621-
);
622-
}
623-
}
624-
#endif
625557

626558
#pragma warning disable IDE0230
627559
private static readonly ReadOnlyMemory<byte> EndOfLine = new[] { (byte)'\n' };

0 commit comments

Comments
 (0)