diff options
Diffstat (limited to 'ThirdParty/CsvHelper-master/docs-src')
23 files changed, 1578 insertions, 0 deletions
diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/ConsoleHost.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/ConsoleHost.cs new file mode 100644 index 0000000..c7c3bc1 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/ConsoleHost.cs @@ -0,0 +1,117 @@ +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace CsvHelper.DocsGenerator +{ + public static class ConsoleHost + { + /// <summary> + /// Block the calling thread until shutdown is triggered via Ctrl+C or SIGTERM. + /// </summary> + public static void WaitForShutdown() + { + WaitForShutdownAsync().GetAwaiter().GetResult(); + } + + /// <summary> + /// Returns a Task that completes when shutdown is triggered via the given token, Ctrl+C or SIGTERM. + /// </summary> + /// <param name="token">The token to trigger shutdown.</param> + public static async Task WaitForShutdownAsync(CancellationToken token = default(CancellationToken)) + { + var done = new ManualResetEventSlim(false); + using (var cts = CancellationTokenSource.CreateLinkedTokenSource(token)) + { + AttachCtrlcSigtermShutdown(cts, done, shutdownMessage: string.Empty); + await WaitForTokenShutdownAsync(cts.Token); + done.Set(); + } + } + + /// <summary> + /// Runs an application and block the calling thread until host shutdown. + /// </summary> + /// <param name="host">The <see cref="IWebHost"/> to run.</param> + public static void Wait() + { + WaitAsync().GetAwaiter().GetResult(); + } + + /// <summary> + /// Runs an application and returns a Task that only completes when the token is triggered or shutdown is triggered. + /// </summary> + /// <param name="host">The <see cref="IConsoleHost"/> to run.</param> + /// <param name="token">The token to trigger shutdown.</param> + public static async Task WaitAsync(CancellationToken token = default(CancellationToken)) + { + //Wait for the token shutdown if it can be cancelled + if (token.CanBeCanceled) + { + await WaitAsync(token, shutdownMessage: null); + return; + } + + //If token cannot be cancelled, attach Ctrl+C and SIGTERN shutdown + var done = new ManualResetEventSlim(false); + using (var cts = new CancellationTokenSource()) + { + AttachCtrlcSigtermShutdown(cts, done, shutdownMessage: "Application is shutting down..."); + await WaitAsync(cts.Token, "Application running. Press Ctrl+C to shut down."); + done.Set(); + } + } + + private static async Task WaitAsync(CancellationToken token, string shutdownMessage) + { + if (!string.IsNullOrEmpty(shutdownMessage)) + { + Console.WriteLine(shutdownMessage); + } + + await WaitForTokenShutdownAsync(token); + } + + private static void AttachCtrlcSigtermShutdown(CancellationTokenSource cts, ManualResetEventSlim resetEvent, string shutdownMessage) + { + Action ShutDown = () => + { + if (!cts.IsCancellationRequested) + { + if (!string.IsNullOrWhiteSpace(shutdownMessage)) + { + Console.WriteLine(shutdownMessage); + } + + try + { + cts.Cancel(); + } + catch (ObjectDisposedException) { } + } + + // Wait on the given reset event + resetEvent.Wait(); + }; + + AppDomain.CurrentDomain.ProcessExit += delegate { ShutDown(); }; + Console.CancelKeyPress += (sender, eventArgs) => + { + ShutDown(); + //Don't terminate the process immediately, wait for the Main thread to exit gracefully. + eventArgs.Cancel = true; + }; + } + + private static async Task WaitForTokenShutdownAsync(CancellationToken token) + { + var waitForStop = new TaskCompletionSource<object>(); + token.Register(obj => + { + var tcs = (TaskCompletionSource<object>)obj; + tcs.TrySetResult(null); + }, waitForStop); + await waitForStop.Task; + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/CsvHelper.DocsGenerator.csproj b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/CsvHelper.DocsGenerator.csproj new file mode 100644 index 0000000..f9884a4 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/CsvHelper.DocsGenerator.csproj @@ -0,0 +1,17 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>netcoreapp2.2</TargetFramework> + <LangVersion>latest</LangVersion> + </PropertyGroup> + + <ItemGroup> + <PackageReference Include="Newtonsoft.Json" Version="12.0.1" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="..\CsvHelper\CsvHelper.csproj" /> + </ItemGroup> + +</Project>
\ No newline at end of file diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/EncodingType.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/EncodingType.cs new file mode 100644 index 0000000..d31b524 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/EncodingType.cs @@ -0,0 +1,14 @@ +namespace CsvHelper.DocsGenerator +{ + public enum EncodingType + { + // Generic<Parameter> + Html = 0, + + // Generic<Parameter> + Code = 1, + + // Generic{Parameter} + Xml = 2 + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Extensions.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Extensions.cs new file mode 100644 index 0000000..fd7ae72 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Extensions.cs @@ -0,0 +1,459 @@ +using CsvHelper.DocsGenerator.Formatters; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text.RegularExpressions; +using System.Xml; +using System.Xml.Linq; + +namespace CsvHelper.DocsGenerator +{ + public static class Extensions + { + // Assembly + + public static string GetHtmlName(Assembly assembly) + { + throw new NotImplementedException(); + } + + // Type + + public static string GetTypeName(this Type type) + { + if (type.IsEnum) + { + return "Enum"; + } + + if (type.IsInterface) + { + return "Interface"; + } + + if (type.IsClass) + { + return "Class"; + } + + throw new InvalidOperationException($"No type name found for type '{type.GetFullName()}'."); + } + + public static string GetHtmlName(this Type type) + { + return HtmlFormat(type); + } + + public static string GetCodeName(this Type type) + { + return HtmlFormat(type, isCodeBlock: true); + } + + public static string GetFullName(this Type type) + { + return $"{type.Namespace}.{type.Name}"; + } + + public static string GetFullHtmlName(this Type type) + { + return $"{type.Namespace}.{type.GetHtmlName()}"; + } + + public static string GetFullCodeName(this Type type) + { + return $"{type.Namespace}.{type.GetCodeName()}"; + } + + public static string GetSummary(this Type type) + { + return GetSummary($"T:{type.GetFullName()}"); + } + + // Property + + public static string GetHtmlName(this PropertyInfo property) + { + return property.Name; + } + + public static string GetCodeName(this PropertyInfo property) + { + throw new NotImplementedException(); + } + + public static string GetFullName(this PropertyInfo property) + { + return $"{property.DeclaringType.FullName}.{property.Name}"; + } + + public static string GetFullHtmlName(this PropertyInfo property) + { + throw new NotImplementedException(); + } + + public static string GetFullCodeName(this PropertyInfo property) + { + throw new NotImplementedException(); + } + + public static string GetSummary(this PropertyInfo property) + { + var parameters = property.GetIndexParameters().ToList(); + var parametersText = string.Empty; + if (parameters.Count > 0) + { + parametersText = $"({string.Join(",", parameters.Select(p => p.ParameterType.FullName))})"; + } + + return GetSummary($"P:{property.GetFullName()}{parametersText}"); + } + + // Field + + public static string GetHtmlName(this FieldInfo field) + { + return field.Name; + } + + public static string GetCodeName(this FieldInfo field) + { + return field.Name; + } + + public static string GetFullName(this FieldInfo field) + { + return $"{field.DeclaringType.FullName}.{field.Name}"; + } + + public static string GetFullHtmlName(this FieldInfo field) + { + throw new NotImplementedException(); + } + + public static string GetFullCodeName(this FieldInfo field) + { + throw new NotImplementedException(); + } + + public static string GetSummary(this FieldInfo field) + { + return GetSummary($"F:{field.GetFullName()}"); + } + + // Constructor + + public static string GetHtmlName(this ConstructorInfo constructor) + { + return HtmlFormat(constructor); + } + + public static string GetCodeName(this ConstructorInfo constructor) + { + throw new NotImplementedException(); + } + + public static string GetFullName(this ConstructorInfo constructor) + { + throw new NotImplementedException(); + } + + public static string GetFullHtmlName(this ConstructorInfo constructor) + { + throw new NotImplementedException(); + } + + public static string GetFullCodeName(this ConstructorInfo constructor) + { + throw new NotImplementedException(); + } + + public static string GetSummary(this ConstructorInfo constructor) + { + return GetSummary($"M:{XmlDocFormat(constructor)}"); + } + + // Method + + public static string GetHtmlName(this MethodInfo method) + { + return HtmlFormat(method); + } + + public static string GetCodeName(this MethodInfo method) + { + throw new NotImplementedException(); + } + + public static string GetFullName(this MethodInfo method) + { + throw new NotImplementedException(); + } + + public static string GetFullHtmlName(this MethodInfo method) + { + throw new NotImplementedException(); + } + + public static string GetFullCodeName(this MethodInfo method) + { + throw new NotImplementedException(); + } + + public static string GetSummary(this MethodInfo method) + { + return GetSummary($"M:{XmlDocFormat(method)}"); + } + + // Private + + private static Type GetType(string typeName) + { + Type type = null; + if (typeName.StartsWith("CsvHelper")) + { + var assembly = Assembly.GetAssembly(typeof(CsvHelperException)); + type = assembly.GetType(typeName); + + var currentTypeName = typeName; + while (type == null && !string.IsNullOrWhiteSpace(currentTypeName) && currentTypeName.Contains('.')) + { + currentTypeName = currentTypeName.Substring(0, currentTypeName.LastIndexOf('.')); + type = assembly.GetType(typeName); + } + } + else + { + type = Type.GetType(typeName); + } + + return type; + } + + private static string GetSummary(string memberName) + { + var members = XmlDocs.XElement.Descendants("member"); + var member = members?.SingleOrDefault(m => m.Attribute("name")?.Value == memberName); + var summary = member?.Element("summary"); + if (summary != null) + { + var summaryText = new List<string>(); + foreach (var node in summary.Nodes()) + { + string text; + if (node.NodeType == XmlNodeType.Element) + { + string typeName = string.Empty; + var el = (XElement)node; + switch (el.Name.ToString()) + { + case "paramref": + typeName = el.Attribute("name").Value; + break; + case "see": + typeName = el.Attribute("cref").Value.Substring(2); + break; + case "c": + typeName = el.Value; + break; + default: + throw new InvalidOperationException($"Unhandled element '{el.Name}'."); + } + + var type = GetType(typeName); + text = type == null ? typeName : type.GetFullCodeName(); + + text = $"``{text.Trim()}``"; + } + else if (node.NodeType == XmlNodeType.Text) + { + text = node.ToString(); + } + else + { + throw new InvalidOperationException($"Unhandled node type '{node.NodeType}'."); + } + + // Replace multiple spaces with a single space. + text = Regex.Replace(text, @"\s{2,}", " ").Trim(); + + summaryText.Add(text); + } + + return string.Join(" ", summaryText); + } + + if (memberName.Substring(2).StartsWith("CsvHelper")) + { + Console.WriteLine($"No summary found for '{memberName}'."); + } + + return null; + } + + private static string HtmlFormat(Type type, bool generateLinks = false, bool isCodeBlock = false) + { + var symbols = isCodeBlock ? Symbols.Code : Symbols.Html; + + var @namespace = type.Namespace; + var name = type.Name; + + if (type.IsByRef) + { + name = name.TrimEnd('&'); + } + + if (generateLinks) + { + if (@namespace.StartsWith("CsvHelper")) + { + name = $"[{name}](/api/{@namespace}/{name})"; + } + else + { + name = $"[{name}](https://docs.microsoft.com/en-us/dotnet/api/{@namespace.ToLower()}.{name.ToLower()})"; + } + } + + var genericArgumentsText = string.Empty; + var genericArguments = type.GetGenericArguments().ToList(); + if (genericArguments.Count > 0) + { + name = name.Substring(0, name.IndexOf('`')); + genericArgumentsText = $"{symbols["<"]}{string.Join(", ", genericArguments.Select(a => HtmlFormat(a)))}{symbols[">"]}"; + } + + return $"{name}{genericArgumentsText}"; + } + + private static string HtmlFormat(MethodBase methodInfo, bool generateLinks = false, bool isCodeBlock = false) + { + var symbols = isCodeBlock ? Symbols.Code : Symbols.Html; + + var @namespace = methodInfo.DeclaringType.Namespace; + var typeName = methodInfo.DeclaringType.Name; + var methodName = methodInfo.Name; + + var name = methodName; + if (methodInfo.IsConstructor) + { + name = methodInfo.DeclaringType.IsGenericType + ? typeName.Substring(0, typeName.IndexOf('`')) + : typeName; + } + + var genericArgumentsText = string.Empty; + var genericArguments = new List<Type>(); + if (!methodInfo.IsConstructor) + { + genericArguments = methodInfo.GetGenericArguments().ToList(); + if (genericArguments.Count > 0) + { + genericArgumentsText = $"{symbols["<"]}{string.Join(", ", genericArguments.Select(a => HtmlFormat(a)))}{symbols[">"]}"; + } + } + + var parametersText = string.Empty; + var parameters = methodInfo.GetParameters().ToList(); + if (parameters.Count > 0) + { + var typeGenericArguments = methodInfo.DeclaringType.GetGenericArguments(); + + parametersText = string.Join(", ", parameters.Select(p => + { + // Don't generate links if the type is a generic parameter. + var shouldGenerateLinks = generateLinks && + !( + typeGenericArguments.Any(a => $"{a.Namespace}.{a.Name}" == $"{p.ParameterType.Namespace}.{p.ParameterType.Name}") || + genericArguments.Any(a => $"{a.Namespace}.{a.Name}" == $"{p.ParameterType.Namespace}.{p.ParameterType.Name}") + ); + + var outText = p.IsOut ? "out " : string.Empty; + return $"{outText}{HtmlFormat(p.ParameterType, shouldGenerateLinks)}"; + })); + } + + return $"{name}{genericArgumentsText}({parametersText})"; + } + + private static string XmlDocFormat(Type type) + { + var @namespace = type.Namespace; + var name = type.Name; + + return $"{@namespace}.{name}"; + } + + private static string XmlDocFormat(MethodBase methodInfo) + { + var typeText = XmlDocFormat(methodInfo.DeclaringType); + + var methodName = methodInfo.Name.Replace('.', '#'); + + var typeGenericArguments = methodInfo.DeclaringType.GetGenericArguments().ToList(); + + var methodGenericArguments = new List<Type>(); + if (!methodInfo.IsConstructor) + { + methodGenericArguments = methodInfo.GetGenericArguments().ToList(); + if (methodGenericArguments.Count > 0) + { + methodName = $"{methodName}``{methodGenericArguments.Count}"; + } + } + + var parametersText = string.Empty; + var parameters = methodInfo.GetParameters().ToList(); + if (parameters.Count > 0) + { + parametersText = $"({string.Join(",", parameters.Select(p => XmlDocFormat(p.ParameterType, typeGenericArguments, methodGenericArguments)))})"; + } + + return $"{typeText}.{methodName}{parametersText}"; + } + + private static string XmlDocFormat(Type parameterType, List<Type> typeGenericParameters, List<Type> methodGenericParameters) + { + var @namespace = parameterType.Namespace; + var name = parameterType.Name; + + if (parameterType.IsByRef) + { + name = name.TrimEnd('&'); + } + + var typeName = $"{@namespace}.{name}"; + + // Check if the parameter is a generic argument of a type. + var index = typeGenericParameters.FindIndex(t => $"{t.Namespace}.{t.Name}" == typeName); + if (index >= 0) + { + var refText = parameterType.IsByRef ? "@" : string.Empty; + return $"`{index}{refText}"; + } + + // Check if the parameter is a generic argument of a method. + index = methodGenericParameters.FindIndex(t => $"{t.Namespace}.{t.Name}" == typeName); + if (index >= 0) + { + var refText = parameterType.IsByRef ? "@" : string.Empty; + return $"``{index}{refText}"; + } + + var genericArgumentsText = string.Empty; + var genericArguments = parameterType.GetGenericArguments().ToList(); + if (genericArguments.Count > 0) + { + name = name.Substring(0, name.IndexOf('`')); + genericArgumentsText = $"{{{string.Join(",", genericArguments.Select(a => XmlDocFormat(a, typeGenericParameters, methodGenericParameters)))}}}"; + } + + if (parameterType.IsByRef) + { + name += "@"; + } + + return $"{@namespace}.{name}{genericArgumentsText}"; + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Formatters/HtmlFormatter.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Formatters/HtmlFormatter.cs new file mode 100644 index 0000000..c557199 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Formatters/HtmlFormatter.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace CsvHelper.DocsGenerator.Formatters +{ + public class HtmlFormatter + { + public string Format(Type type, bool generateLinks = false, bool isCodeBlock = false) + { + var symbols = isCodeBlock ? Symbols.Code : Symbols.Html; + + var @namespace = type.Namespace; + var name = type.Name; + + if (type.IsByRef) + { + name = name.TrimEnd('&'); + } + + if (generateLinks) + { + if (@namespace.StartsWith("CsvHelper")) + { + name = $"[{name}](/api/{@namespace}/{name})"; + } + else + { + name = $"[{name}](https://docs.microsoft.com/en-us/dotnet/api/{@namespace.ToLower()}.{name.ToLower()})"; + } + } + + var genericArgumentsText = string.Empty; + var genericArguments = type.GetGenericArguments().ToList(); + if (genericArguments.Count > 0) + { + name = name.Substring(0, name.IndexOf('`')); + genericArgumentsText = $"{symbols["<"]}{string.Join(", ", genericArguments.Select(a => Format(a)))}{symbols[">"]}"; + } + + return $"{name}{genericArgumentsText}"; + } + + public string Format(MethodBase methodInfo, bool generateLinks = false, bool isCodeBlock = false) + { + var symbols = isCodeBlock ? Symbols.Code : Symbols.Html; + + var @namespace = methodInfo.DeclaringType.Namespace; + var typeName = methodInfo.DeclaringType.Name; + var methodName = methodInfo.Name; + + var name = methodInfo.IsConstructor ? typeName : methodName; + + var genericArgumentsText = string.Empty; + var genericArguments = new List<Type>(); + if (!methodInfo.IsConstructor) + { + genericArguments = methodInfo.GetGenericArguments().ToList(); + if (genericArguments.Count > 0) + { + genericArgumentsText = $"{symbols["<"]}{string.Join(", ", genericArguments.Select(a => Format(a)))}{symbols[">"]}"; + } + } + + var parametersText = string.Empty; + var parameters = methodInfo.GetParameters().ToList(); + if (parameters.Count > 0) + { + var typeGenericArguments = methodInfo.DeclaringType.GetGenericArguments(); + + parametersText = string.Join(", ", parameters.Select(p => + { + // Don't generate links if the type is a generic parameter. + var shouldGenerateLinks = generateLinks && + !( + typeGenericArguments.Any(a => $"{a.Namespace}.{a.Name}" == $"{p.ParameterType.Namespace}.{p.ParameterType.Name}") || + genericArguments.Any(a => $"{a.Namespace}.{a.Name}" == $"{p.ParameterType.Namespace}.{p.ParameterType.Name}") + ); + + var outText = p.IsOut ? "out " : string.Empty; + return $"{outText}{Format(p.ParameterType, shouldGenerateLinks)}"; + })); + } + + return $"{name}{genericArgumentsText}({parametersText})"; + } + + public string Format(MemberInfo memberInfo, bool generateLinks = false, bool isCodeBlock = false) + { + return memberInfo.Name; + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Formatters/Symbols.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Formatters/Symbols.cs new file mode 100644 index 0000000..52b4846 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Formatters/Symbols.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Linq; + +namespace CsvHelper.DocsGenerator.Formatters +{ + public static class Symbols + { + public static readonly Dictionary<string, string> Html = new Dictionary<string, string> + { + { "<", "<" }, + { ">", ">" }, + { "[", "[" }, + { "]", "]" } + }; + + public static readonly Dictionary<string, string> Code = new Dictionary<string, string>(Html.Select(pair => new KeyValuePair<string, string>(pair.Key, pair.Key))); + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Formatters/XmlDocFormatter.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Formatters/XmlDocFormatter.cs new file mode 100644 index 0000000..5d24338 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Formatters/XmlDocFormatter.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace CsvHelper.DocsGenerator.Formatters +{ + public class XmlDocFormatter + { + public string Format(Type type) + { + return $"T:{FormatType(type)}"; + } + + public string Format(MethodBase methodInfo) + { + return $"M:{FormatMethod(methodInfo)}"; + } + + private string FormatType(Type type) + { + var @namespace = type.Namespace; + var name = type.Name; + + return $"{@namespace}.{name}"; + } + + private string FormatMethod(MethodBase methodInfo) + { + var typeText = FormatType(methodInfo.DeclaringType); + + var methodName = methodInfo.Name.Replace('.', '#'); + + var typeGenericArguments = methodInfo.DeclaringType.GetGenericArguments().ToList(); + + var methodGenericArguments = new List<Type>(); + if (!methodInfo.IsConstructor) + { + methodGenericArguments = methodInfo.GetGenericArguments().ToList(); + if (methodGenericArguments.Count > 0) + { + methodName = $"{methodName}``{methodGenericArguments.Count}"; + } + } + + var parametersText = string.Empty; + var parameters = methodInfo.GetParameters().ToList(); + if (parameters.Count > 0) + { + parametersText = $"({string.Join(",", parameters.Select(p => FormatParameter(p.ParameterType, typeGenericArguments, methodGenericArguments)))})"; + } + + return $"{typeText}.{methodName}{parametersText}"; + } + + private string FormatParameter(Type parameterType, List<Type> typeGenericParameters, List<Type> methodGenericParameters) + { + var @namespace = parameterType.Namespace; + var name = parameterType.Name; + + if (parameterType.IsByRef) + { + name = name.TrimEnd('&'); + } + + var typeName = $"{@namespace}.{name}"; + + // Check if the parameter is a generic argument of a type. + var index = typeGenericParameters.FindIndex(t => $"{t.Namespace}.{t.Name}" == typeName); + if (index >= 0) + { + var refText = parameterType.IsByRef ? "@" : string.Empty; + return $"`{index}{refText}"; + } + + // Check if the parameter is a generic argument of a method. + index = methodGenericParameters.FindIndex(t => $"{t.Namespace}.{t.Name}" == typeName); + if (index >= 0) + { + var refText = parameterType.IsByRef ? "@" : string.Empty; + return $"``{index}{refText}"; + } + + var genericArgumentsText = string.Empty; + var genericArguments = parameterType.GetGenericArguments().ToList(); + if (genericArguments.Count > 0) + { + name = name.Substring(0, name.IndexOf('`')); + genericArgumentsText = $"{{{string.Join(",", genericArguments.Select(a => FormatParameter(a, typeGenericParameters, methodGenericParameters)))}}}"; + } + + if (parameterType.IsByRef) + { + name += "@"; + } + + return $"{@namespace}.{name}{genericArgumentsText}"; + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/AssemblyGenerator.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/AssemblyGenerator.cs new file mode 100644 index 0000000..76c4749 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/AssemblyGenerator.cs @@ -0,0 +1,22 @@ +using CsvHelper.DocsGenerator.Infos; + +namespace CsvHelper.DocsGenerator.Generators +{ + public class AssemblyGenerator : DocumentGenerator + { + public AssemblyGenerator(AssemblyInfo assemblyInfo) : base(assemblyInfo) { } + + protected override void GenerateContent() + { + content.AppendLine($"# {assemblyInfo.Assembly.GetName().Name} Namespaces"); + content.AppendLine(); + content.AppendLine("## Namespaces"); + content.AppendLine(" | "); + content.AppendLine("- | -"); + foreach (var @namespace in assemblyInfo.Namespaces) + { + content.AppendLine($"[{@namespace.Namespace}](/api/{@namespace.Namespace}) | "); + } + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/DocumentGenerator.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/DocumentGenerator.cs new file mode 100644 index 0000000..614e182 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/DocumentGenerator.cs @@ -0,0 +1,42 @@ +using CsvHelper.DocsGenerator.Infos; +using System; +using System.Text; + +namespace CsvHelper.DocsGenerator.Generators +{ + public abstract class DocumentGenerator + { + //protected readonly HtmlFormatter htmlFormatter = new HtmlFormatter(); + protected readonly LinkGenerator linkGenerator = new LinkGenerator(); + protected readonly AssemblyInfo assemblyInfo; + protected readonly NamespaceInfo namespaceInfo; + protected readonly TypeInfo typeInfo; + protected readonly StringBuilder content = new StringBuilder(); + + public DocumentGenerator(AssemblyInfo assemblyInfo) + { + this.assemblyInfo = assemblyInfo ?? throw new ArgumentNullException(nameof(assemblyInfo)); + } + + public DocumentGenerator(NamespaceInfo namespaceInfo) + { + this.namespaceInfo = namespaceInfo; + } + + public DocumentGenerator(TypeInfo typeInfo) + { + this.typeInfo = typeInfo ?? throw new ArgumentNullException(nameof(typeInfo)); + } + + public string Generate() + { + content.Clear(); + + GenerateContent(); + + return content.ToString(); + } + + protected abstract void GenerateContent(); + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/DocumentGeneratorFactory.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/DocumentGeneratorFactory.cs new file mode 100644 index 0000000..d9ece33 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/DocumentGeneratorFactory.cs @@ -0,0 +1,22 @@ +using CsvHelper.DocsGenerator.Infos; + +namespace CsvHelper.DocsGenerator.Generators +{ + public class DocumentGeneratorFactory + { + public DocumentGenerator Create(AssemblyInfo assemblyInfo) + { + return new AssemblyGenerator(assemblyInfo); + } + + public DocumentGenerator Create(NamespaceInfo namespaceInfo) + { + return new NamespaceGenerator(namespaceInfo); + } + + public DocumentGenerator Create(TypeInfo typeInfo) + { + return new TypeGenerator(typeInfo); + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/NamespaceGenerator.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/NamespaceGenerator.cs new file mode 100644 index 0000000..b3a9314 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/NamespaceGenerator.cs @@ -0,0 +1,50 @@ +using CsvHelper.DocsGenerator.Infos; + +namespace CsvHelper.DocsGenerator.Generators +{ + public class NamespaceGenerator : DocumentGenerator + { + public NamespaceGenerator(NamespaceInfo namespaceInfo) : base(namespaceInfo) { } + + protected override void GenerateContent() + { + content.AppendLine($"# {namespaceInfo.Namespace} Namespace"); + + if (namespaceInfo.Classes.Count > 0) + { + content.AppendLine(); + content.AppendLine("## Classes"); + content.AppendLine(" | "); + content.AppendLine("- | -"); + foreach (var typeInfo in namespaceInfo.Classes) + { + content.AppendLine($"[{typeInfo.Type.GetHtmlName()}](/api/{namespaceInfo.Namespace}/{typeInfo.Type.GetHtmlName()}) | {typeInfo.Type.GetSummary()}"); + } + } + + if (namespaceInfo.Interfaces.Count > 0) + { + content.AppendLine(); + content.AppendLine("## Interfaces"); + content.AppendLine(" | "); + content.AppendLine("- | -"); + foreach (var typeInfo in namespaceInfo.Interfaces) + { + content.AppendLine($"[{typeInfo.Type.GetHtmlName()}](/api/{namespaceInfo.Namespace}/{typeInfo.Type.Name}) | {typeInfo.Type.GetSummary()}"); + } + } + + if (namespaceInfo.Enums.Count > 0) + { + content.AppendLine(); + content.AppendLine("## Enums"); + content.AppendLine(" | "); + content.AppendLine("- | -"); + foreach (var typeInfo in namespaceInfo.Enums) + { + content.AppendLine($"[{typeInfo.Type.GetHtmlName()}](/api/{namespaceInfo.Namespace}/{typeInfo.Type.Name}) | {typeInfo.Type.GetSummary()}"); + } + } + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/TypeGenerator.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/TypeGenerator.cs new file mode 100644 index 0000000..fa7533e --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Generators/TypeGenerator.cs @@ -0,0 +1,118 @@ +using CsvHelper.DocsGenerator.Infos; +using System.Linq; + +namespace CsvHelper.DocsGenerator.Generators +{ + public class TypeGenerator : DocumentGenerator + { + public TypeGenerator(TypeInfo typeInfo) : base(typeInfo) { } + + protected override void GenerateContent() + { + // Title + content.AppendLine($"# {typeInfo.Type.GetHtmlName()} {typeInfo.Type.GetTypeName()}"); + + // Namespace + content.AppendLine(); + content.AppendLine($"Namespace: [{typeInfo.Type.Namespace}](/api/{typeInfo.Type.Namespace})"); + + // Summary + content.AppendLine(); + content.AppendLine(typeInfo.Type.GetSummary()); + + // Definition + content.AppendLine(); + content.AppendLine("```cs"); + foreach (var attribute in typeInfo.Attributes) + { + content.AppendLine($"[{attribute.GetFullCodeName()}]"); + } + + var inheritanceText = string.Empty; + if (!typeInfo.Type.IsEnum && typeInfo.Implementers.Count > 0) + { + inheritanceText = $": {string.Join(", ", typeInfo.Implementers.Select(i => i.GetCodeName()))}"; + } + + var typeModifier = string.Empty; + if (typeInfo.Type.IsAbstract && typeInfo.Type.IsSealed && !typeInfo.Type.IsInterface) + { + typeModifier = "static "; + } + else if (typeInfo.Type.IsAbstract && !typeInfo.Type.IsSealed && !typeInfo.Type.IsInterface) + { + typeModifier = "abstract "; + } + + content.AppendLine($"public {typeModifier}{typeInfo.Type.GetTypeName().ToLower()} {typeInfo.Type.GetCodeName()} {inheritanceText}"); + content.AppendLine("```"); + + // Inheritance + if (typeInfo.Inheritance.Count > 0) + { + content.AppendLine(); + content.AppendLine($"Inheritance {string.Join(" -> ", typeInfo.Inheritance.Select(t => t.GetHtmlName()))}"); + } + + // Constructors + if (typeInfo.Constructors.Count > 0) + { + content.AppendLine(""); + content.AppendLine("## Constructors"); + content.AppendLine(" | "); + content.AppendLine("- | -"); + foreach (var constructorInfo in typeInfo.Constructors) + { + content.AppendLine($"{constructorInfo.Constructor.GetHtmlName()} | {constructorInfo.Constructor.GetSummary()}"); + } + } + + // Fields + if (typeInfo.Fields.Count > 0) + { + content.AppendLine(); + content.AppendLine("## Fields"); + content.AppendLine(" | "); + content.AppendLine("- | -"); + foreach (var field in typeInfo.Fields) + { + content.AppendLine($"{field.GetHtmlName()} | {field.GetSummary()}"); + } + } + + // Properties + if (typeInfo.Properties.Count > 0) + { + content.AppendLine(); + content.AppendLine("## Properties"); + content.AppendLine(" | "); + content.AppendLine("- | -"); + foreach (var property in typeInfo.Properties) + { + if (property.IndexParameters.Count > 0) + { + var parameters = string.Join(", ", property.IndexParameters.Select(ip => ip.ParameterType.GetHtmlName())); + content.AppendLine($"this[{parameters}] | {property.Property.GetSummary()}"); + } + else + { + content.AppendLine($"{property.Property.GetHtmlName()} | {property.Property.GetSummary()}"); + } + } + } + + // Methods + if (typeInfo.Methods.Count > 0) + { + content.AppendLine(); + content.AppendLine("## Methods"); + content.AppendLine(" | "); + content.AppendLine("- | -"); + foreach (var method in typeInfo.Methods) + { + content.AppendLine($"{method.Method.GetHtmlName()} | {method.Method.GetSummary()}"); + } + } + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/AssemblyInfo.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/AssemblyInfo.cs new file mode 100644 index 0000000..8e14d42 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Xml.Linq; + +namespace CsvHelper.DocsGenerator.Infos +{ + [DebuggerDisplay("Name = {Name}")] + public class AssemblyInfo : Info + { + public Assembly Assembly { get; protected set; } + + public List<NamespaceInfo> Namespaces { get; private set; } + + public AssemblyInfo(Assembly assembly, XElement xmlDocs) + { + Assembly = assembly; + + Namespaces = + ( + from type in assembly.GetTypes() + where type.IsPublic + orderby type.Namespace ascending, type.Name ascending + group type by type.Namespace into g + select new NamespaceInfo(this, g.Key, g.ToList(), xmlDocs) + ).ToList(); + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/ConstructorInfo.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/ConstructorInfo.cs new file mode 100644 index 0000000..3a00b19 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/ConstructorInfo.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using System.Linq; +using System.Xml.Linq; + +namespace CsvHelper.DocsGenerator.Infos +{ + public class ConstructorInfo : Info + { + public System.Reflection.ConstructorInfo Constructor { get; private set; } + + public List<System.Reflection.ParameterInfo> Parameters { get; private set; } + + public ConstructorInfo(System.Reflection.ConstructorInfo constructorInfo, XElement xmlDocs) + { + Constructor = constructorInfo; + + Parameters = constructorInfo.GetParameters().ToList(); + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/Info.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/Info.cs new file mode 100644 index 0000000..fda1943 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/Info.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text.RegularExpressions; +using System.Xml; +using System.Xml.Linq; + +namespace CsvHelper.DocsGenerator.Infos +{ + [DebuggerDisplay("Name = {Name}, DisplayName = {DisplayName}, Namespace = {NameSpace}, FullName = {FullName}")] + public abstract class Info + { + //private string fullName; + //private string fullHtmlName; + //private string fullCodeName; + + //protected readonly HtmlFormatter htmlFormatter = new HtmlFormatter(); + //protected readonly XmlDocFormatter xmlDocFormatter = new XmlDocFormatter(); + + //public string Namespace { get; protected set; } + + //public string Name { get; protected set; } + + //public string HtmlName { get; protected set; } + + //public string CodeName { get; protected set; } + + //public string FullName + //{ + // get => fullName ?? $"{Namespace}.{Name}"; + // protected set => fullName = value; + //} + + //public string FullHtmlName + //{ + // get => fullHtmlName ?? $"{Namespace}.{HtmlName}"; + // protected set => fullHtmlName = value; + //} + + //public string FullCodeName + //{ + // get => fullCodeName ?? $"{Namespace}.{CodeName}"; + // protected set => fullCodeName = value; + //} + + //public string Summary { get; protected set; } + + protected string ParseSummary(string memberName, XElement xmlDocs) + { + var members = xmlDocs.Descendants("member"); + var member = members?.SingleOrDefault(m => m.Attribute("name")?.Value == memberName); + var summary = member?.Element("summary"); + if (summary != null) + { + var summaryText = new List<string>(); + foreach (var node in summary.Nodes()) + { + string text; + if (node.NodeType == XmlNodeType.Element) + { + var el = (XElement)node; + switch (el.Name.ToString()) + { + case "paramref": + text = el.Attribute("name").Value; + break; + case "see": + text = el.Attribute("cref").Value.Substring(2); + break; + case "c": + text = el.Value; + break; + default: + throw new InvalidOperationException($"Unhandled element '{el.Name}'."); + } + + text = $"``{text.Trim()}``"; + } + else if (node.NodeType == XmlNodeType.Text) + { + text = node.ToString(); + } + else + { + throw new InvalidOperationException($"Unhandled node type '{node.NodeType}'."); + } + + text = Regex.Replace(text, @"\s{2,}", " ").Trim(); + + summaryText.Add(text); + } + + return string.Join(" ", summaryText); + } + + if (memberName.Substring(2).StartsWith("CsvHelper")) + { + Console.WriteLine($"No summary found for '{memberName}'."); + } + + return null; + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/MethodInfo.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/MethodInfo.cs new file mode 100644 index 0000000..c73913e --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/MethodInfo.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml.Linq; + +namespace CsvHelper.DocsGenerator.Infos +{ + public class MethodInfo : Info + { + public System.Reflection.MethodInfo Method { get; private set; } + + public List<System.Reflection.ParameterInfo> Parameters { get; private set; } + + public List<Type> GenericArguments { get; private set; } + + public MethodInfo(System.Reflection.MethodInfo methodInfo, XElement xmlDocs) + { + Method = methodInfo; + + Parameters = methodInfo.GetParameters().ToList(); + + GenericArguments = methodInfo.GetGenericArguments().ToList(); + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/NamespaceInfo.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/NamespaceInfo.cs new file mode 100644 index 0000000..a143391 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/NamespaceInfo.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Xml.Linq; + +namespace CsvHelper.DocsGenerator.Infos +{ + [DebuggerDisplay("Name = {Name}")] + public class NamespaceInfo : Info + { + public AssemblyInfo Assembly { get; protected set; } + + public string Namespace { get; protected set; } + + public List<TypeInfo> Types { get; private set; } = new List<TypeInfo>(); + + public List<TypeInfo> Classes { get; private set; } = new List<TypeInfo>(); + + public List<TypeInfo> Interfaces { get; private set; } = new List<TypeInfo>(); + + public List<TypeInfo> Enums { get; private set; } = new List<TypeInfo>(); + + public NamespaceInfo(AssemblyInfo assemblyInfo, string @namespace, List<Type> types, XElement xmlDocs) + { + Assembly = assemblyInfo; + + Namespace = @namespace; + + foreach (var type in types) + { + var typeInfo = new TypeInfo(type, xmlDocs); + Types.Add(typeInfo); + + if (type.IsClass) + { + Classes.Add(typeInfo); + } + else if (type.IsInterface) + { + Interfaces.Add(typeInfo); + } + else if (type.IsEnum) + { + Enums.Add(typeInfo); + } + } + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/PropertyInfo.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/PropertyInfo.cs new file mode 100644 index 0000000..2d53638 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/PropertyInfo.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using System.Linq; +using System.Xml.Linq; + +namespace CsvHelper.DocsGenerator.Infos +{ + public class PropertyInfo : Info + { + public List<System.Reflection.ParameterInfo> IndexParameters { get; protected set; } + + public TypeInfo Type { get; protected set; } + + public System.Reflection.PropertyInfo Property { get; protected set; } + + public PropertyInfo(TypeInfo type, System.Reflection.PropertyInfo propertyInfo, XElement xmlDocs) + { + Type = type; + + Property = propertyInfo; + + IndexParameters = propertyInfo.GetIndexParameters().ToList(); + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/TypeInfo.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/TypeInfo.cs new file mode 100644 index 0000000..18d67f3 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Infos/TypeInfo.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Xml.Linq; + +namespace CsvHelper.DocsGenerator.Infos +{ + public class TypeInfo : Info + { + private static readonly LinkGenerator linkGenerator = new LinkGenerator(); + + public Type Type { get; protected set; } + + public List<Type> Attributes { get; protected set; } + + public List<ConstructorInfo> Constructors { get; protected set; } + + public List<Type> Interfaces { get; protected set; } + + public List<FieldInfo> Fields { get; protected set; } + + public List<PropertyInfo> Properties { get; protected set; } + + public List<MethodInfo> Methods { get; protected set; } + + public Stack<Type> Inheritance { get; protected set; } + + public List<Type> Implementers { get; protected set; } + + public TypeInfo(Type type, XElement xmlDocs) + { + Type = type; + + Interfaces = type.GetInterfaces().ToList(); + + Constructors = type + .GetConstructors(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) + .Select(c => new ConstructorInfo(c, xmlDocs)) + .Where(c => !(c.Parameters.Count == 0 && string.IsNullOrEmpty(c.Constructor.GetSummary()))) + .OrderBy(c => c.Parameters.Count) + .ToList(); + + Attributes = type + .GetCustomAttributes() + .Select(a => a.GetType()) + .OrderBy(t => t.Name) + .ToList(); + + var fieldsFlags = type.IsEnum + ? BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly + : BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly; + Fields = type + .GetFields(fieldsFlags) + .OrderBy(f => f.Name) + .ToList(); + + Properties = type + .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly) + .Select(p => new PropertyInfo(this, p, xmlDocs)) + .OrderBy(p => p.Property.Name) + .ToList(); + + Methods = type + .GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly) + .Where(m => !m.IsSpecialName) + .Select(m => new MethodInfo(m, xmlDocs)) + .OrderBy(m => m.Method.Name) + .ToList(); + + Inheritance = new Stack<Type>(); + if (type.BaseType != null) + { + Inheritance.Push(type); + var currentType = type.BaseType; + do + { + Inheritance.Push(currentType); + currentType = currentType.BaseType; + } + while (currentType != null); + } + + Implementers = new List<Type>(); + if (type.BaseType != null && type.BaseType != typeof(object)) + { + Implementers.Add(type.BaseType); + } + + Implementers.AddRange(Interfaces.Select(i => i)); + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/LinkGenerator.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/LinkGenerator.cs new file mode 100644 index 0000000..4e8dcc8 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/LinkGenerator.cs @@ -0,0 +1,19 @@ +using System; + +namespace CsvHelper.DocsGenerator +{ + public class LinkGenerator + { + public string GenerateLink(Type type) + { + if (type.Namespace.StartsWith("CsvHelper")) + { + return $"[{type.Name}](/api/{type.Namespace}/{type.Name})"; + } + + var fullName = $"{type.Namespace}.{type.Name}"; + + return $"[{type.Name}](https://docs.microsoft.com/en-us/dotnet/api/{fullName.ToLower()})"; + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Program.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Program.cs new file mode 100644 index 0000000..5d430d9 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Program.cs @@ -0,0 +1,18 @@ +using System; + +namespace CsvHelper.DocsGenerator +{ + class Program + { + static void Main(string[] args) + { + new Startup() + .Configure() + .Run(); + + Console.WriteLine(); + Console.WriteLine("Press any key to exit."); + Console.ReadKey(); + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Startup.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Startup.cs new file mode 100644 index 0000000..698a60d --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/Startup.cs @@ -0,0 +1,110 @@ +using CsvHelper.DocsGenerator.Generators; +using CsvHelper.DocsGenerator.Infos; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System.IO; +using System.Linq; +using System.Xml.Linq; + +namespace CsvHelper.DocsGenerator +{ + public class Startup + { + public Startup Configure() + { + return this; + } + + public Startup Run() + { + var outputDirectoryPath = Path.Combine(Directory.GetCurrentDirectory(), "Output"); + if (Directory.Exists(outputDirectoryPath)) + { + Directory.Delete(outputDirectoryPath, true); + } + + Directory.CreateDirectory(outputDirectoryPath); + + var xmlDocs = XElement.Load("CsvHelper.xml"); + + var assemblyInfo = new AssemblyInfo(typeof(CsvHelperException).Assembly, xmlDocs); + + GenerateMarkdownFiles(outputDirectoryPath, assemblyInfo); + GenerateToc(outputDirectoryPath, assemblyInfo); + + return this; + } + + private void GenerateMarkdownFiles(string outputDirectoryPath, AssemblyInfo assemblyInfo) + { + var documentGeneratorFactory = new DocumentGeneratorFactory(); + + // Write assembly file. + var documentGenerator = documentGeneratorFactory.Create(assemblyInfo); + var content = documentGenerator.Generate(); + var filePath = Path.Combine(outputDirectoryPath, "api.md"); + File.WriteAllText(filePath, content); + + outputDirectoryPath = Path.Combine(outputDirectoryPath, "api"); + Directory.CreateDirectory(outputDirectoryPath); + + // Write namespace files and directories. + foreach (var @namespace in assemblyInfo.Namespaces) + { + var directoryPath = Path.Combine(outputDirectoryPath, @namespace.Namespace); + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + + documentGenerator = documentGeneratorFactory.Create(@namespace); + content = documentGenerator.Generate(); + filePath = Path.Join(outputDirectoryPath, $"{@namespace.Namespace}.md"); + File.WriteAllText(filePath, content); + } + + // Write type files. + foreach (var @namespace in assemblyInfo.Namespaces) + { + var directoryPath = Path.Combine(outputDirectoryPath, @namespace.Namespace); + foreach (var typeInfo in @namespace.Types) + { + documentGenerator = documentGeneratorFactory.Create(typeInfo); + content = documentGenerator.Generate(); + filePath = Path.Combine(directoryPath, $"{typeInfo.Type.Name}.md"); + File.WriteAllText(filePath, content); + } + } + } + + private void GenerateToc(string outputDirectoryPath, AssemblyInfo assemblyInfo) + { + var toc = new JObject + ( + new JProperty("api", new JObject + ( + new JProperty("title", "CsvHelper Namespaces"), + new JProperty("path", "api"), + new JProperty("children", new JArray + ( + assemblyInfo.Namespaces.Select(namespaceInfo => new JObject( + new JProperty("title", namespaceInfo.Namespace), + new JProperty("path", $"api/{namespaceInfo.Namespace}"), + new JProperty("children", new JArray + ( + namespaceInfo.Types.Select(typeInfo => new JObject + ( + new JProperty("title", typeInfo.Type.Name), + new JProperty("path", $"api/{namespaceInfo.Namespace}/{typeInfo.Type.Name}") + )) + )) + )) + )) + )) + ); + + var filePath = Path.Combine(outputDirectoryPath, "api.json"); + File.WriteAllText(filePath, JsonConvert.SerializeObject(toc, Formatting.Indented)); + } + } +} diff --git a/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/XmlDocs.cs b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/XmlDocs.cs new file mode 100644 index 0000000..b1c9c83 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs-src/CsvHelper.DocsGenerator/XmlDocs.cs @@ -0,0 +1,12 @@ +using System; +using System.Xml.Linq; + +namespace CsvHelper.DocsGenerator +{ + public static class XmlDocs + { + private static readonly Lazy<XElement> lazy = new Lazy<XElement>(() => XElement.Load("CsvHelper.xml")); + + public static XElement XElement => lazy.Value; + } +} |