Skip to content

Commit

Permalink
✨ WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tacosontitan committed Feb 20, 2024
1 parent 36bff43 commit e9bd00c
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 44 deletions.
8 changes: 0 additions & 8 deletions src/Hussy.Net.Analyzers/AnalyzerReleases.Shipped.md

This file was deleted.

4 changes: 0 additions & 4 deletions src/Hussy.Net.Analyzers/AnalyzerReleases.Unshipped.md

This file was deleted.

5 changes: 3 additions & 2 deletions src/Hussy.Net.Analyzers/Hussy.Net.Analyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Hussy.Net\Hussy.Net.csproj" />
<AdditionalFiles Remove="AnalyzerReleases.Shipped.md" />
<AdditionalFiles Remove="AnalyzerReleases.Unshipped.md" />
</ItemGroup>

</Project>
29 changes: 0 additions & 29 deletions src/Hussy.Net.Analyzers/Readme.md

This file was deleted.

43 changes: 43 additions & 0 deletions src/Hussy.Net/Generators/BatchedRange.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace Hussy.Net;

/// <summary>
/// Defines static methods for common programming tasks.
/// </summary>
public static partial class Hussy
{
/// <summary>
/// Generates a range of values starting with <c>1</c> through the specified <paramref name="count"/> value.
/// </summary>
/// <param name="count">The maximum value to include in the range.</param>
/// <returns>A range of values starting with <c>1</c> through the specified <paramref name="count"/> value.</returns>
public static IEnumerable<IEnumerable<int>> Gbr(int count, int batchSize) =>
Enumerable.Range(1, count).Chunk(batchSize);

/// <summary>
/// Generates a range of values from the specified <paramref name="start"/> through the specified <paramref name="count"/> value.
/// </summary>
/// <param name="start">The starting value for the range.</param>
/// <param name="count">The maximum value to include in the range.</param>
/// <returns>A range of values starting with <paramref name="start"/> through the specified <paramref name="count"/> value.</returns>
public static IEnumerable<IEnumerable<int>> Gbr(int start, int count, int batchSize) =>
Enumerable.Range(start, count).Chunk(batchSize);

/// <summary>
/// Generates a range of values from the specified <paramref name="start"/> through the specified <paramref name="count"/> value.
/// </summary>
/// <param name="start">The starting value for the range.</param>
/// <param name="count">The maximum value to include in the range.</param>
/// <param name="stepSize">The step value to use when generating the range.</param>
/// <returns>A range of values starting with <paramref name="start"/> through the specified <paramref name="count"/> value.</returns>
public static IEnumerable<IEnumerable<int>> Gbr(int start, int count, int stepSize, int batchSize)
{
List<int> range = new(capacity: count);
for (int i = 0; i < count; i++)
{
range.Add(start);
start += stepSize;
}

return range.Chunk(batchSize);
}
}
3 changes: 2 additions & 1 deletion src/Hussy.Net/Hussy.Net.csproj.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=modules/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=output/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=primitives/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=primitives_005Clogical/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=primitives_005Clogical/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=text/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
17 changes: 17 additions & 0 deletions src/Hussy.Net/Linq/Batch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Hussy.Net;

/// <summary>
/// Defines static methods for common programming tasks.
/// </summary>
public static partial class Hussy
{
/// <summary>
/// Batches the specified <paramref name="source"/> sequence into chunks of the specified <paramref name="size"/>.
/// </summary>
/// <param name="source">Specifies the source sequence to batch.</param>
/// <param name="size">Specifies the size of the individual batches.</param>
/// <typeparam name="T">Specifies the type of the data in the <paramref name="source"/> sequence.</typeparam>
/// <returns>A collection of batches created from the specified <paramref name="source"/> sequence.</returns>
public static IEnumerable<IEnumerable<T>> B<T>(this IEnumerable<T> source, int size = 2) =>
source.Chunk(size);
}
10 changes: 10 additions & 0 deletions src/Hussy.Net/Linq/Join.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Hussy.Net;

/// <summary>
/// Defines static methods for common programming tasks.
/// </summary>
public static partial class Hussy
{
public static string J<T>(this IEnumerable<T> source, string separator = ", ") =>
string.Join(separator, source);
}
36 changes: 36 additions & 0 deletions src/Hussy.Net/Text/ArrayFormat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace Hussy.Net;

/// <summary>
/// Defines static methods for common programming tasks.
/// </summary>
public static partial class Hussy
{
/// <summary>
/// Creates a classic array string (e.g. <c>[1, 2, 3]</c>) for the specified sequence.
/// </summary>
/// <param name="sequence">The sequence to create the array string for.</param>
/// <typeparam name="T">Specifies the type of data in the sequence.</typeparam>
/// <returns>The input sequence wrapped in square brackets and separated by commas and spaces.</returns>
/// <example>
/// Behind the scenes, this method simply interpolates a call to <c>string.Join</c> with <c>", "</c> as the
/// separator. This results in an output string of <c>[1, 2, 3, ...]</c>, to use it, simply specify a collection
/// parameter:
///
/// <code>
/// // Generate a range to work with:
/// var sequence = Gr(5);
///
/// // Create the formatted string:
/// var output = Far(sequence);
///
/// // Append the output to the output stream:
/// A(output);
/// </code>
///
/// The expected output of the above snippet is:
///
/// > [1, 2, 3, 4, 5]
/// </example>
public static string Far<T>(IEnumerable<T> sequence) =>
$"[{string.Join(", ", sequence)}]";
}

0 comments on commit e9bd00c

Please sign in to comment.