This repository has been archived by the owner on Dec 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.MarkdownParser.cs
100 lines (99 loc) · 4.81 KB
/
Program.MarkdownParser.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System;
using System.IO;
using System.Text;
namespace WinErrorParser
{
public partial class Program
{
public static void ParseToMarkdown()
{
var writer = new StreamWriter("output.md", false, Encoding.UTF8) { AutoFlush = true };
void o(string input = "") { writer.WriteLine(input); }
o("# List of Windows HResult Error Codes");
o();
o($"Generated by winerror parser, version `{version}`.");
o();
o($"Time: `{DateTime.Now:o}`");
o();
o("## Table of Contents");
o();
o("> - [List of Facility Codes](#list-of-facility-codes)");
o("> - [Old HResult Layout](#old-hresult-layout)");
o("> - [List of HResult Codes in Old Format](#list-of-hresult-codes-in-old-format)");
o("> - [New HResult Layout](#new-hresult-layout)");
o("> - [List of HResult Codes in New Format](#list-of-hresult-codes-in-new-format)");
o();
o("## List of Facility Codes");
o();
o("| Code | Value |");
o("| :----- | :----- |");
foreach (var facilityCode in facilityCodes)
o($"| `{facilityCode.FullErrorCode}` | `{facilityCode.Value}` |");
o();
o("## Old HResult Layout");
o();
o("HResult is a 32-bit number (`long` in C, `int` in C# and some other languages) laid out as follows:");
o();
o("```");
o(" 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1");
o(" 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0");
o("+---+-+-+-----------------------+-------------------------------+");
o("|Sev|C|R| Facility | Code |");
o("+---+-+-+-----------------------+-------------------------------+");
o("```");
o();
o("| Name | Description");
o("| :----- | :----- |");
o("| `Sev` | Severity code |");
o("| `C` | Customer code flag |");
o("| `R` | Reserved |");
o("| `Facility` | Facility code |");
o("| `Code` | Facility's status code |");
o();
o("| Sev | Severity |");
o("| :----- | :----- |");
o("| `00` | Success |");
o("| `01` | Informational |");
o("| `10` | Warning |");
o("| `11` | Error |");
o();
o("### List of HResult Codes in Old Format");
o();
o("| Code | HResult (Dec) | HResult (Hex) | Message |");
o("| :----- | :----- | :----- | :----- |");
foreach (var oldHResult in winErrorCodesOldHResult)
o($"| `{oldHResult.ErrorCode}` | `{oldHResult.HResult}` | `0x{oldHResult.HResult:x}` | {oldHResult.Message.Replace("\r", @"\r").Replace("\n", @"\n")} |");
o();
o("## New HResult Layout");
o();
o("HResult is a 32-bit number (`long` in C, `int` in C# and some other languages) laid out as follows:");
o();
o("```");
o(" 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1");
o(" 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0");
o("+-+-+-+-+-+---------------------+-------------------------------+");
o("|S|R|C|N|r| Facility | Code |");
o("+-+-+-+-+-+---------------------+-------------------------------+");
o("```");
o();
o("| Name | Description");
o("| :----- | :----- |");
o("| `S` | Severity, `0 = Success`, `1 = Fail (Error)` |");
o("| `R` | Reserved portion of the facility code, corresponds to NT's second severity bit |");
o("| `C` | Reserved portion of the facility code, corresponds to NT's C field |");
o("| `N` | Reserved portion of the facility code. Used to indicate a mapped NT status value |");
o("| `r` | Reserved portion of the facility code. Reserved for internal use. Used to indicate HRESULT values that are not status values, but are instead message ids for display strings |");
o("| `Facility` | Facility code |");
o("| `Code` | Facility's status code |");
o();
o("### List of HResult Codes in New Format");
o();
o("| Code | HResult (Dec) | HResult (Hex) | Message |");
o("| :----- | :----- | :----- | :----- |");
foreach (var newHResult in winErrorCodesNewHResult)
o($"| `{newHResult.ErrorCode}` | `{newHResult.HResult}` | `0x{newHResult.HResult:x}` | {newHResult.Message.Replace("\r", @"\r").Replace("\n", @"\n")} |");
o();
writer.Close();
}
}
}