Skip to content

Commit 45d8ba0

Browse files
authored
Doc updates and refactoring (#30)
* Updated markdown based on linter - Linter ultimately abandoned as it is too inflexible and not consistent * Refactored getting the named type and context validation to `CommandGenerator.TryGetNamedTypeSymbol()` * Added use of `Microsoft.CodeAnalysis.CSharp` for literal conversions * Added direct testing of the language specific generator support
1 parent a64165f commit 45d8ba0

16 files changed

Lines changed: 213 additions & 30 deletions

File tree

docfx/.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,17 @@ tab_width = 2
3232
# requires: https://marketplace.visualstudio.com/items?itemName=PaulHarrington.EditorGuidelinesPreview
3333
guidelines = 92
3434

35+
# Settings for https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownLint
36+
# Sadly, that is dragged in by https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor2
37+
# while there is a built-in version that doesn't support mermaid diagrams without all the CoPilot cruft.
38+
# see: https://developercommunity.visualstudio.com/t/Mermaid-rendering-does-not-work/10968192#T-N10986717
39+
# so the "third party" (not really) one is used.
40+
# The linter is NOT used in this repo as it is not flexible enough and inconsistently complains about perfectly valid markdown as not consistent.
41+
# sadly, the mdlint package doesn't have configuration for the `lines_above` or 'lines_below` parameters so disable the rule (MD022)
42+
#md_blanks_around_headings = false
43+
#md_ul_indent = 4
44+
#md_fenced_code_language = false # fenced "code" may just be text and no language exists
45+
#md_code_fence_style = backtick
46+
#md_emphasis_style = asterisk
47+
#md_strong_style = asterisk
48+

docfx/CommandLine/Diagnostics/UNC000.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# UNC0000: An internal analyzer exception occurred.
1+
# UNC0000: An internal analyzer exception occurred
22
An internal error occurred in the analyzer. Please [report](https://github.com/UbiquityDotNET/Ubiquity.NET.Utils/issues)
33
the issue with as much detail as possible, ideally with a small repro to help identify the
44
problem. Please include the full stack of the exception as shown in the message details.

docfx/CommandLine/Diagnostics/UNC001.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ type does not contain an attribute that designates it as a command. The generato
44
***ignore*** the property and the ***entire*** class.
55

66
## Example:
7+
78
``` C#
89
using System.IO;
910

@@ -19,6 +20,7 @@ internal class testInput1
1920
```
2021

2122
## Fix:
23+
2224
``` C#
2325
using System.IO;
2426

docfx/CommandLine/Diagnostics/UNC002.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ internal class testInput1
2727
```
2828

2929
## Fix
30+
3031
``` C#
3132
using System.IO;
3233

docfx/CommandLine/Diagnostics/UNC003.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ incorrect type is used. If this is ignored or suppressed the property is ignored
66
generation.
77

88
## Example
9+
910
``` C#
1011
using System.IO;
1112

docfx/CommandLine/Diagnostics/UNC004.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# UNC004 : Property type is nullable but marked as required.
1+
# UNC004 : Property type is nullable but marked as required
22
This diagnostic is reported when a nullable type is marked as `Required`. This usually
33
indicates an error in the source applying the attributes. An explicitly annotated nullable
44
type has a legit value of null, therefore marking it as `Required` makes no sense. Required
55
means that it is validated as specified on the command line, this validation only occurs at
66
the time of ***invoking*** the command. (If a different command is parsed from the command
77
line arguments then no validation occurs).
88

9-
109
## Example
10+
1111
``` C#
1212
using Ubiquity.NET.CommandLine.GeneratorAttributes;
1313

docfx/CommandLine/Diagnostics/UNC005.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
# UNC005 : Arity specified for property type is invalid.
1+
# UNC005 : Arity specified for property type is invalid
22
This diagnostic indicates that the arity specified in an attribute does not match the type
33
of value for that property^1^. The default arity is usually enough but it is sometimes valid
44
to limit the "or more" default to a max value. In particular with collections there may be
5-
a limit to the maximum number of values allowed so the arity specifies that. Not that the
6-
arity applies to the ***values*** of a property. That is:
7-
`--foo true` is ONLY allowed if the minimum arity is > 1, otherwise only the option itself
8-
is allowed (for example: `--foo`). Setting the arity to a maximum that is > 1 requires a
9-
collection type to bind the parsed values to. Setting a minimum > 0 makes it required to
10-
specify a value for the command. That is, with a minimum arity of 1 `--foo` is an error.
5+
a limit to the maximum number of values allowed so the arity specifies that.
116

7+
> [!IMPORTANT]
8+
> The arity applies to the ***values*** of a property. That is, `--foo true` is ONLY allowed
9+
> if the minimum arity is > 1, otherwise only the option itself is allowed (for example:
10+
> `--foo`). Setting the arity to a ***maximum*** that is > 1 requires a collection type to
11+
> bind the parsed values to. Setting a ***minimum*** > 0 makes it required to specify a
12+
> value for the option IFF the option itself is provided. That is, with a minimum arity of 1
13+
> `--foo` is an error. But not specifying the option is not (unless it is marked as
14+
> "Required")
1215
1316
---
1417
^1^ see the [System.CommandLine docs](https://learn.microsoft.com/en-us/dotnet/standard/commandline/syntax#argument-arity)

docfx/CommandLine/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ parsing and binding. Additionally an analyzer is provided to aid in identifying
77
with usage of the attributes for generation.
88

99
## Analyzer Diagnostics
10+
1011
Rule ID | Title |
1112
--------|-------|
1213
[UNC000](https://ubiquitydotnet.github.io/Ubiquity.NET.Utils/CommandLine/diagnostics/UNC000.html) | An internal analyzer exception occurred. |

docfx/IgnoredWords.dic

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1+
antlr
12
arity
3+
bool
4+
initializer
5+
interop
6+
marshalling
7+
namespace
28
nullable
9+
runtimes
10+
src
11+
Theming
12+
utils

src/.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ tab_width = 2
3232
# requires: https://marketplace.visualstudio.com/items?itemName=PaulHarrington.EditorGuidelinesPreview
3333
guidelines = 92
3434

35+
# Settings for https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownLint
36+
# Sadly, that is dragged in by https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor2
37+
# while there is a built-in version that doesn't support mermaid diagrams without all the CoPilot cruft.
38+
# see: https://developercommunity.visualstudio.com/t/Mermaid-rendering-does-not-work/10968192#T-N10986717
39+
# so the "third party" (not really) one is used.
40+
# The linter is NOT used in this repo as it is not flexible enough and inconsistently complains about perfectly valid markdown as not consistent.
41+
# sadly, the mdlint package doesn't have configuration for the `lines_above` or 'lines_below` parameters so disable the rule (MD022)
42+
#md_blanks_around_headings = false
43+
#md_ul_indent = 4
44+
#md_fenced_code_language = false # fenced "code" may just be text and no language exists
45+
#md_code_fence_style = backtick
46+
#md_emphasis_style = asterisk
47+
#md_strong_style = asterisk
48+
3549
# match ISO standard requirement for C/C++
3650
[*.c,*.h,*.cpp]
3751
insert_final_newline = true

0 commit comments

Comments
 (0)