using System.Reflection;
using System.Text;
Type[] s_types = Type.EmptyTypes;
Init();
var source = new StringBuilder();
using var writer = new StringWriter(source);
foreach (Type type in s_types)
{
writer.WriteLine("// This file was generated by X10D.");
writer.WriteLine("// Do not edit it manually.");
writer.WriteLine();
writer.WriteLine("namespace X10D");
writer.WriteLine();
writer.WriteLine("public static partial class EnumerableExtensions");
writer.WriteLine("{");
writer.WriteLine(" /// ");
writer.WriteLine($" /// Computes the product of a sequence of values.");
writer.WriteLine(" /// ");
writer.WriteLine(
$" /// The sequence of values that are used to calculate the product.");
writer.WriteLine(" /// The product of the values in the sequence.");
if (type.GetCustomAttribute() is { } compliant)
writer.WriteLine($" [CLSCompliant({compliant.IsCompliant.ToString().ToLower()})]");
writer.WriteLine($" public static {type.FullName} Product(this IEnumerable<{type.FullName}> source)");
writer.WriteLine(" {");
writer.WriteLine(" if (source is null)");
writer.WriteLine(" throw new ArgumentNullException(nameof(source));");
writer.WriteLine();
writer.WriteLine(" var result = 1m;");
writer.WriteLine();
writer.WriteLine(" foreach (var item in source)");
writer.WriteLine(" result *= item;");
writer.WriteLine();
writer.WriteLine(" return result;");
writer.WriteLine(" }");
writer.WriteLine("}");
}
return;
void Init()
{
s_types = new[]
{
typeof(int), typeof(uint)
};
}