A collection of C# development tools built on the Roslyn compiler platform, including a code analyzer with code fixes and a standalone formatting CLI tool.
| Package | Description | |
|---|---|---|
| Reihitsu.Analyzer | Roslyn-based analyzer package enforcing coding rules for clarity, design, naming, formatting, documentation, ordering, and performance. | |
| Reihitsu.Cli | Command-line formatting tool for C# source files. |
dotnet add package Reihitsu.Analyzerdotnet tool install -g Reihitsu.Cli
reihitsu-format src/The following is a code snippet that complies with the rules of the analyzer and formatter.
/// <summary>
/// Builds report instances from a list of customer orders
/// </summary>
internal sealed class ReportBuilder
{
#region Fields
/// <summary>
/// The orders that can are used to build the report
/// </summary>
private readonly IReadOnlyList<Order> _orders;
#endregion // Fields
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="ReportBuilder"/> class
/// </summary>
/// <param name="orders">The orders that can be used to build reports</param>
public ReportBuilder(IReadOnlyList<Order> orders)
{
_orders = orders ?? throw new ArgumentNullException(nameof(orders));
}
#endregion // Constructor
#region Methods
/// <summary>
/// Builds a report for a specific customer
/// </summary>
/// <param name="customerId">The customer identifier to filter for</param>
/// <param name="createdOn">The date assigned to the generated report</param>
/// <param name="includeInactive">A value indicating whether inactive orders should be included</param>
/// <returns>The generated report</returns>
public Report Build(string customerId, DateOnly createdOn, bool includeInactive)
{
var items = _orders.Where(order => order.CustomerId == customerId)
.Where(order => includeInactive || order.IsActive)
.Select(order => new ReportItem
{
Id = order.Id,
Lines = order.Lines
.Select(line => new ReportLine
{
Name = line.Name,
Total = line.UnitPrice
* line.Quantity
})
.ToArray()
})
.OrderBy(item => item.Id)
.ToArray();
return new Report(customerId,
createdOn,
items,
new ReportOptions
{
IncludeTotals = true,
UseShortDates = false,
Labels = [
"stable",
"demo"
]
});
}
#endregion // Methods
}This project is licensed under the terms of the LICENSE file.