diff --git a/RuriLib.Http/RuriLib.Http.csproj b/RuriLib.Http/RuriLib.Http.csproj index 6ab521839..6b36eb660 100644 --- a/RuriLib.Http/RuriLib.Http.csproj +++ b/RuriLib.Http/RuriLib.Http.csproj @@ -6,7 +6,7 @@ Ruri 1.0.1 This is a library that provides a custom HTTP client, in addition to an HttpMessageHandler to be used with the default HttpClient of System.Net - Ruri 2022 + Ruri 2024 https://github.com/openbullet/OpenBullet2/tree/master/RuriLib.Http http; proxy; socks; client; custom; enable diff --git a/RuriLib.Parallelization/RuriLib.Parallelization.csproj b/RuriLib.Parallelization/RuriLib.Parallelization.csproj index b06e1c1a7..85ac8ca68 100644 --- a/RuriLib.Parallelization/RuriLib.Parallelization.csproj +++ b/RuriLib.Parallelization/RuriLib.Parallelization.csproj @@ -4,7 +4,7 @@ net8.0 Ruri This is a library that can perform multiple tasks (yes, a lot, even infinitely many) that act on some input and return a certain output. - Ruri 2022 + Ruri 2024 https://github.com/openbullet/OpenBullet2/tree/master/RuriLib.Parallelization https://github.com/openbullet/OpenBullet2/tree/master/RuriLib.Parallelization parallelization; task; tasks; manager; taskmanager; multithreading; parallel; multithread; async; diff --git a/RuriLib.Proxies/RuriLib.Proxies.csproj b/RuriLib.Proxies/RuriLib.Proxies.csproj index e6ca5c9fb..52d2df6be 100644 --- a/RuriLib.Proxies/RuriLib.Proxies.csproj +++ b/RuriLib.Proxies/RuriLib.Proxies.csproj @@ -2,7 +2,7 @@ net8.0 - Ruri 2022 + Ruri 2024 https://github.com/openbullet/OpenBullet2/tree/master/RuriLib.Proxies This is a library that can proxy a `TcpClient` via a proxy server. Supported protocols: HTTP(S), SOCKS4, SOCKS4a, SOCKS5, No proxy proxy; proxies; http; socks; socks4; socks4a; socks5; tcpclient; diff --git a/RuriLib/Attributes/Variable.cs b/RuriLib/Attributes/Variable.cs index 30dcd3807..db44257b6 100644 --- a/RuriLib/Attributes/Variable.cs +++ b/RuriLib/Attributes/Variable.cs @@ -15,11 +15,17 @@ public class Variable : Attribute // ReSharper disable once InconsistentNaming public string? defaultVariableName; + /// + /// Marks the parameter as a variable with no default name. + /// public Variable() { } + /// + /// Marks the parameter as a variable with the given default name. + /// public Variable(string defaultVariableName) { this.defaultVariableName = defaultVariableName; diff --git a/RuriLib/Exceptions/BlockExecutionException.cs b/RuriLib/Exceptions/BlockExecutionException.cs index 714648614..a7521dbe3 100644 --- a/RuriLib/Exceptions/BlockExecutionException.cs +++ b/RuriLib/Exceptions/BlockExecutionException.cs @@ -2,14 +2,32 @@ namespace RuriLib.Exceptions; +/// +/// The exception that is thrown when a block encounters an error during execution. +/// public class BlockExecutionException : Exception { + /// + /// Initializes a new instance of the class. + /// + /// + /// The message that describes the error. + /// public BlockExecutionException(string message) : base(message) { } + /// + /// Initializes a new instance of the class. + /// + /// + /// The message that describes the error. + /// + /// + /// The exception that is the cause of the current exception. + /// public BlockExecutionException(string message, Exception innerException) : base(message, innerException) { diff --git a/RuriLib/Exceptions/InvalidProxyException.cs b/RuriLib/Exceptions/InvalidProxyException.cs index 97c675b23..c2fe20ea4 100644 --- a/RuriLib/Exceptions/InvalidProxyException.cs +++ b/RuriLib/Exceptions/InvalidProxyException.cs @@ -7,6 +7,12 @@ namespace RuriLib.Exceptions; /// public class InvalidProxyException : Exception { + /// + /// Creates a with a message that contains the invalid proxy. + /// + /// + /// The invalid proxy that could not be parsed. + /// public InvalidProxyException(string proxy) : base($"The proxy {proxy} could not be parsed") { diff --git a/RuriLib/Exceptions/InvalidWordlistTypeException.cs b/RuriLib/Exceptions/InvalidWordlistTypeException.cs index 21bbcf035..f493bb1da 100644 --- a/RuriLib/Exceptions/InvalidWordlistTypeException.cs +++ b/RuriLib/Exceptions/InvalidWordlistTypeException.cs @@ -1,17 +1,22 @@ using System; -namespace RuriLib.Exceptions +namespace RuriLib.Exceptions; + +/// +/// An exception that is thrown when a Wordlist Type with the given name was not present +/// in the Environment settings. +/// +public class InvalidWordlistTypeException : Exception { /// - /// An exception that is thrown when a Wordlist Type with the given name was not present - /// in the Environment settings. + /// Creates a with a message that contains the invalid type. /// - public class InvalidWordlistTypeException : Exception + /// + /// The invalid Wordlist Type that was not found in the Environment settings. + /// + public InvalidWordlistTypeException(string type) + : base($"The Wordlist Type {type} was not found in the Environment settings") { - public InvalidWordlistTypeException(string type) - : base($"The Wordlist Type {type} was not found in the Environment settings") - { - } } } diff --git a/RuriLib/Exceptions/LoliCodeParsingException.cs b/RuriLib/Exceptions/LoliCodeParsingException.cs index 493188b90..968acee92 100644 --- a/RuriLib/Exceptions/LoliCodeParsingException.cs +++ b/RuriLib/Exceptions/LoliCodeParsingException.cs @@ -1,26 +1,59 @@ using System; -namespace RuriLib.Exceptions +namespace RuriLib.Exceptions; + +/// +/// An exception that is thrown when an error occurs while parsing LoliCode. +/// +public class LoliCodeParsingException : Exception { - public class LoliCodeParsingException : Exception - { - public int LineNumber { get; set; } + /// + /// The line number where the error occurred. + /// + public int LineNumber { get; set; } - public LoliCodeParsingException(int lineNumber) - { - LineNumber = lineNumber; - } + /// + /// Creates a new . + /// + /// + /// The line number where the error occurred. + /// + public LoliCodeParsingException(int lineNumber) + { + LineNumber = lineNumber; + } - public LoliCodeParsingException(int lineNumber, string message) - : base($"[Line {lineNumber}] {message}") - { - LineNumber = lineNumber; - } + /// + /// Creates a new . + /// + /// + /// The line number where the error occurred. + /// + /// + /// The error message. + /// + public LoliCodeParsingException(int lineNumber, string message) + : base($"[Line {lineNumber}] {message}") + { + LineNumber = lineNumber; + } - public LoliCodeParsingException(int lineNumber, string message, Exception inner) - : base($"[Line {lineNumber}] {message}", inner) - { - LineNumber = lineNumber; - } + /// + /// Creates a new . + /// + /// + /// The line number where the error occurred. + /// + /// + /// The error message. + /// + /// + /// The inner exception. + /// + public LoliCodeParsingException(int lineNumber, string message, Exception inner) + : base($"[Line {lineNumber}] {message}", inner) + { + LineNumber = lineNumber; } } + diff --git a/RuriLib/Exceptions/NoWordlistTypesException.cs b/RuriLib/Exceptions/NoWordlistTypesException.cs index 007dbc3e8..588ea11b2 100644 --- a/RuriLib/Exceptions/NoWordlistTypesException.cs +++ b/RuriLib/Exceptions/NoWordlistTypesException.cs @@ -1,16 +1,19 @@ using System; -namespace RuriLib.Exceptions +namespace RuriLib.Exceptions; + +/// +/// An exception that is thrown when no Wordlist Types were specified +/// in the Environment settings. +/// +public class NoWordlistTypesExceptions : Exception { /// - /// An exception that is thrown when no Wordlist Types were specified - /// in the Environment settings. + /// Creates a new . /// - public class NoWordlistTypesExceptions : Exception + public NoWordlistTypesExceptions() : + base("No Wordlist Types specified in the Environment settings") { - public NoWordlistTypesExceptions() : base("No Wordlist Types specified in the Environment settings") - { - } } } diff --git a/RuriLib/Extensions/BoolExtensions.cs b/RuriLib/Extensions/BoolExtensions.cs index 5cdac4ad4..875d1f872 100644 --- a/RuriLib/Extensions/BoolExtensions.cs +++ b/RuriLib/Extensions/BoolExtensions.cs @@ -1,29 +1,61 @@ using System; using System.Collections.Generic; -namespace RuriLib.Extensions +namespace RuriLib.Extensions; + +/// +/// Provides extension methods for . +/// +public static class BoolExtensions { - public static class BoolExtensions - { - public static bool AsBool(this bool b) - => b; + /// + /// Converts a to a . + /// + public static bool AsBool(this bool b) + => b; - public static int AsInt(this bool b) - => Convert.ToInt32(b); + /// + /// Converts a to an . + /// Returns 1 if true, 0 if false. + /// + public static int AsInt(this bool b) + => Convert.ToInt32(b); - public static float AsFloat(this bool b) - => Convert.ToSingle(b); + /// + /// Converts a to a . + /// Returns 1.0f if true, 0.0f if false. + /// + /// + /// + public static float AsFloat(this bool b) + => Convert.ToSingle(b); - public static byte[] AsBytes(this bool b) - => BitConverter.GetBytes(b); + /// + /// Converts a to a . + /// Returns a single byte with value 1 if true, 0 if false. + /// + public static byte[] AsBytes(this bool b) + => BitConverter.GetBytes(b); - public static string AsString(this bool b) - => b.ToString(); + /// + /// Converts a to a . + /// Returns "True" if true, "False" if false. + /// + public static string AsString(this bool b) + => b.ToString(); - public static List AsList(this bool b) - => new List { b.ToString() }; + /// + /// Converts a to a of . + /// Returns a list with a single element containing the string representation of the bool. + /// + public static List AsList(this bool b) + => [b.ToString()]; - public static Dictionary AsDict(this bool b) - => new Dictionary { { b.ToString(), "" } }; - } + /// + /// Converts a to a of . + /// Returns a dictionary with a single key-value pair containing the string representation of the bool + /// as the key and an empty string as the value. + /// + public static Dictionary AsDict(this bool b) + => new() { { b.ToString(), "" } }; } diff --git a/RuriLib/Extensions/ByteArrayExtensions.cs b/RuriLib/Extensions/ByteArrayExtensions.cs index 1b8c7d322..cc554a298 100644 --- a/RuriLib/Extensions/ByteArrayExtensions.cs +++ b/RuriLib/Extensions/ByteArrayExtensions.cs @@ -1,30 +1,76 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; -namespace RuriLib.Extensions +namespace RuriLib.Extensions; + +/// +/// Provides extension methods for . +/// +public static class ByteArrayExtensions { - public static class ByteArrayExtensions - { - public static bool AsBool(this byte[] bytes) - => BitConverter.ToBoolean(bytes, 0); + /// + /// Converts a to a . + /// Returns true if the first byte is not 0, false otherwise. + /// + /// + /// When the byte array is empty. + /// + public static bool AsBool(this byte[] bytes) + => BitConverter.ToBoolean(bytes, 0); - public static int AsInt(this byte[] bytes) - => BitConverter.ToInt32(bytes, 0); + /// + /// Converts a to an . + /// Returns the integer representation of the first 4 bytes. + /// + /// + /// When the byte array cannot be converted to an integer. + /// + /// + /// When the byte array is too short to be converted to an integer. + /// + public static int AsInt(this byte[] bytes) + => BitConverter.ToInt32(bytes, 0); - public static float AsFloat(this byte[] bytes) - => BitConverter.ToSingle(bytes, 0); + /// + /// Converts a to a . + /// Returns the float representation of the first 4 bytes. + /// + /// + /// When the byte array cannot be converted to a float. + /// + /// + /// When the byte array is too short to be converted to a float. + /// + public static float AsFloat(this byte[] bytes) + => BitConverter.ToSingle(bytes, 0); - public static byte[] AsBytes(this byte[] bytes) - => bytes; + /// + /// Converts a to a . + /// Copies the byte array to a new one. + /// + public static byte[] AsBytes(this byte[] bytes) + => bytes.ToArray(); - public static string AsString(this byte[] bytes) - => Encoding.UTF8.GetString(bytes); + /// + /// Converts a to a . + /// Returns the UTF8 string representation of the byte array. + /// + public static string AsString(this byte[] bytes) + => Encoding.UTF8.GetString(bytes); - public static List AsList(this byte[] bytes) - => new List { bytes.ToString() }; + /// + /// Converts a to a of . + /// Returns a list with a single element containing the string representation of the byte array. + /// + public static List AsList(this byte[] bytes) => [bytes.ToString()!]; - public static Dictionary AsDict(this byte[] bytes) - => new Dictionary { { bytes.ToString(), "" } }; - } + /// + /// Converts a to a of . + /// Returns a dictionary with a single key-value pair containing the string representation of the byte array + /// as the key and an empty string as the value. + /// + public static Dictionary AsDict(this byte[] bytes) + => new() { { bytes.ToString()!, "" } }; } diff --git a/RuriLib/RuriLib.csproj b/RuriLib/RuriLib.csproj index 07a5fa2e5..c526df2a4 100644 --- a/RuriLib/RuriLib.csproj +++ b/RuriLib/RuriLib.csproj @@ -3,7 +3,10 @@ net8.0 Ruri + The library that powers OpenBullet. + Ruri 2024 enable + True