switch to global usings

This commit is contained in:
Ben Harris 2024-03-26 16:10:54 -04:00
parent a7b45f1e36
commit 325b3bb30d
21 changed files with 1739 additions and 1814 deletions

View File

@ -29,7 +29,7 @@ internal class Client(string host, int port, string nick)
while (true)
{
while (_encoder.PendingBytes.Any())
while (_encoder.PendingBytes.Length != 0)
{
foreach (var line in _encoder.Pop(_socket.Send(_encoder.PendingBytes)))
Console.WriteLine($"> {line.Format()}");

View File

@ -17,6 +17,16 @@
<ProjectReference Include="..\IRCTokens\IRCTokens.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="IRCTokens" />
<Using Include="IRCStates" />
<Using Include="System" />
<Using Include="System.Collections.Generic" />
<Using Include="System.Linq" />
<Using Include="System.Text" />
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>
<ItemGroup>
<None Update="Tokenization\Data\msg-join.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

View File

@ -1,9 +1,5 @@
using System.Collections.Generic;
using IRCStates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.State;
namespace IRCSharp.Tests.State
{
[TestClass]
public class Cap
{
@ -128,4 +124,3 @@ namespace IRCSharp.Tests.State
CollectionAssert.AreEqual(new List<string>(), _server.AgreedCaps);
}
}
}

View File

@ -1,8 +1,5 @@
using IRCStates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.State;
namespace IRCSharp.Tests.State
{
[TestClass]
public class Casemap
{
@ -55,4 +52,3 @@ namespace IRCSharp.Tests.State
Assert.AreEqual("newnickname", server.NickNameLower);
}
}
}

View File

@ -1,11 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using IRCStates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.State;
namespace IRCSharp.Tests.State
{
[TestClass]
public class Channel
{
@ -103,16 +97,16 @@ namespace IRCSharp.Tests.State
public void QuitSelf()
{
_server.Parse(new("QUIT :i'm outta here"));
Assert.IsFalse(_server.Users.Any());
Assert.IsFalse(_server.Channels.Any());
Assert.IsFalse(_server.Users.Count != 0);
Assert.IsFalse(_server.Channels.Count != 0);
}
[TestMethod]
public void QuitSelfWithSource()
{
_server.Parse(new(":nickname QUIT :i'm outta here"));
Assert.IsFalse(_server.Users.Any());
Assert.IsFalse(_server.Channels.Any());
Assert.IsFalse(_server.Users.Count != 0);
Assert.IsFalse(_server.Channels.Count != 0);
}
[TestMethod]
@ -198,4 +192,3 @@ namespace IRCSharp.Tests.State
channel.Users);
}
}
}

View File

@ -1,9 +1,5 @@
using System.Collections.Generic;
using IRCStates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.State;
namespace IRCSharp.Tests.State
{
[TestClass]
public class Emit
{
@ -114,4 +110,3 @@ namespace IRCSharp.Tests.State
}, emit.Tokens);
}
}
}

View File

@ -1,11 +1,6 @@
using System.Collections.Generic;
using IRCStates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
// ReSharper disable InconsistentNaming
namespace IRCSharp.Tests.State;
// ReSharper disable InconsistentNaming
namespace IRCSharp.Tests.State
{
[TestClass]
public class ISupport
{
@ -207,4 +202,3 @@ namespace IRCSharp.Tests.State
Assert.AreEqual(-1, _server.ISupport.Watch);
}
}
}

View File

@ -1,9 +1,5 @@
using System.Collections.Generic;
using IRCStates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.State;
namespace IRCSharp.Tests.State
{
[TestClass]
public class Mode
{
@ -176,4 +172,3 @@ namespace IRCSharp.Tests.State
CollectionAssert.AreEqual(new List<string> {"i", "w"}, _server.Modes);
}
}
}

View File

@ -1,9 +1,5 @@
using System.Collections.Generic;
using IRCStates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.State;
namespace IRCSharp.Tests.State
{
[TestClass]
public class Motd
{
@ -20,4 +16,3 @@ namespace IRCSharp.Tests.State
server.Motd);
}
}
}

View File

@ -1,8 +1,5 @@
using IRCStates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.State;
namespace IRCSharp.Tests.State
{
[TestClass]
public class Sasl
{
@ -35,4 +32,3 @@ namespace IRCSharp.Tests.State
Assert.IsTrue(string.IsNullOrEmpty(_server.Account));
}
}
}

View File

@ -1,8 +1,5 @@
using IRCStates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.State;
namespace IRCSharp.Tests.State
{
[TestClass]
public class User
{
@ -295,4 +292,3 @@ namespace IRCSharp.Tests.State
Assert.AreEqual("tyrannosaurus hex", user.RealName);
}
}
}

View File

@ -1,8 +1,5 @@
using IRCStates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.State;
namespace IRCSharp.Tests.State
{
[TestClass]
public class Who
{
@ -58,4 +55,3 @@ namespace IRCSharp.Tests.State
Assert.AreEqual(user.Account, _server.Account);
}
}
}

View File

@ -1,8 +1,7 @@
using System.Collections.Generic;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization;
namespace IRCSharp.Tests.Tokenization.Data;
namespace IRCSharp.Tests.Tokenization.Data
{
public class JoinModel
{
public List<Test> Tests { get; set; }
@ -27,4 +26,3 @@ namespace IRCSharp.Tests.Tokenization.Data
public List<string> Params { get; set; }
}
}
}

View File

@ -1,7 +1,5 @@
using System.Collections.Generic;
namespace IRCSharp.Tests.Tokenization.Data;
namespace IRCSharp.Tests.Tokenization.Data
{
public class SplitModel
{
public List<Test> Tests { get; set; }
@ -12,4 +10,3 @@ namespace IRCSharp.Tests.Tokenization.Data
public JoinModel.Atoms Atoms { get; set; }
}
}
}

View File

@ -1,9 +1,5 @@
using System;
using IRCTokens;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.Tokenization;
namespace IRCSharp.Tests.Tokenization
{
[TestClass]
public class Format
{
@ -15,7 +11,7 @@ namespace IRCSharp.Tests.Tokenization
Tags = new() {{"id", "\\" + " " + ";" + "\r\n"}}
}.Format();
Assert.AreEqual("@id=\\\\\\s\\:\\r\\n PRIVMSG #channel hello", line);
Assert.AreEqual(@"@id=\\\s\:\r\n PRIVMSG #channel hello", line);
}
[TestMethod]
@ -102,4 +98,3 @@ namespace IRCSharp.Tests.Tokenization
Assert.ThrowsException<ArgumentException>(() => { new Line("PRIVMSG", ":#channel", "hello").Format(); });
}
}
}

View File

@ -1,8 +1,5 @@
using IRCTokens;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.Tokenization;
namespace IRCSharp.Tests.Tokenization
{
[TestClass]
public class Hostmask
{
@ -62,4 +59,3 @@ namespace IRCSharp.Tests.Tokenization
Assert.IsNull(line.Hostmask.NickName);
}
}
}

View File

@ -1,14 +1,11 @@
using System.Collections.Generic;
using System.Globalization;
using System.Globalization;
using System.IO;
using IRCSharp.Tests.Tokenization.Data;
using IRCTokens;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
namespace IRCSharp.Tests.Tokenization
{
namespace IRCSharp.Tests.Tokenization;
[TestClass]
public class Parser
{
@ -33,7 +30,7 @@ namespace IRCSharp.Tests.Tokenization
$"command failed on: '{test.Input}'");
Assert.AreEqual(atoms.Source, tokens.Source, $"source failed on: '{test.Input}'");
CollectionAssert.AreEqual(atoms.Tags, tokens.Tags, $"tags failed on: '{test.Input}'");
CollectionAssert.AreEqual(atoms.Params ?? new List<string>(), tokens.Params,
CollectionAssert.AreEqual(atoms.Params ?? [], tokens.Params,
$"params failed on: '{test.Input}'");
}
}
@ -53,4 +50,3 @@ namespace IRCSharp.Tests.Tokenization
}
}
}
}

View File

@ -1,10 +1,5 @@
using System.Collections.Generic;
using System.Text;
using IRCTokens;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.Tokenization;
namespace IRCSharp.Tests.Tokenization
{
[TestClass]
public class StatefulDecoder
{
@ -86,4 +81,3 @@ namespace IRCSharp.Tests.Tokenization
Assert.AreEqual(string.Empty, _decoder.Pending);
}
}
}

View File

@ -1,9 +1,5 @@
using System.Text;
using IRCTokens;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.Tokenization;
namespace IRCSharp.Tests.Tokenization
{
[TestClass]
public class StatefulEncoder
{
@ -82,4 +78,3 @@ namespace IRCSharp.Tests.Tokenization
CollectionAssert.AreEqual(iso8859.GetBytes("PRIVMSG #channel :hello Ç\r\n"), _encoder.PendingBytes);
}
}
}

View File

@ -1,11 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IRCTokens;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace IRCSharp.Tests.Tokenization;
namespace IRCSharp.Tests.Tokenization
{
[TestClass]
public class Tokenization
{
@ -41,7 +35,7 @@ namespace IRCSharp.Tests.Tokenization
public void TagsOverlap()
{
var line = new Line(@"@id=1\\\s\\s PRIVMSG #channel");
Assert.AreEqual("1\\ \\s", line.Tags["id"]);
Assert.AreEqual(@"1\ \s", line.Tags["id"]);
}
[TestMethod]
@ -122,13 +116,12 @@ namespace IRCSharp.Tests.Tokenization
public void NulByte()
{
var decoder = new IRCTokens.StatefulDecoder();
var bytes = Encoding.UTF8.GetBytes(":nick!user@host PRIVMSG #channel :hello")
.Concat(Encoding.UTF8.GetBytes("\0"))
.Concat(Encoding.UTF8.GetBytes("world"))
var bytes = ":nick!user@host PRIVMSG #channel :hello"u8.ToArray()
.Concat("\0"u8.ToArray())
.Concat("world"u8.ToArray())
.ToArray();
var line = decoder.Push(bytes, bytes.Length).First();
CollectionAssert.AreEqual(new List<string> {"#channel", "hello"}, line.Params);
}
}
}

View File

@ -212,10 +212,10 @@ namespace IRCTokens
foreach (var p in withoutLast)
{
if (p.Contains(' ', StringComparison.Ordinal))
throw new ArgumentException(@"non-last parameters cannot have spaces", p);
throw new ArgumentException("non-last parameters cannot have spaces", p);
if (p.StartsWith(':'))
throw new ArgumentException(@"non-last parameters cannot start with colon", p);
throw new ArgumentException("non-last parameters cannot start with colon", p);
}
outs.AddRange(withoutLast);