Skip to content

Commit ebd26a5

Browse files
committed
Inline doc template.
1 parent c916cb8 commit ebd26a5

6 files changed

Lines changed: 22 additions & 28 deletions

File tree

AspNetCoreAnalyzers.Tests/Documentation/Tests.cs

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace AspNetCoreAnalyzers.Tests.Documentation
1212
using System.Text;
1313
using Gu.Roslyn.AnalyzerExtensions;
1414
using Gu.Roslyn.Asserts;
15+
using Gu.Roslyn.CodeFixExtensions;
1516
using Microsoft.CodeAnalysis;
1617
using Microsoft.CodeAnalysis.Diagnostics;
1718
using NUnit.Framework;
@@ -131,37 +132,37 @@ public void Index()
131132
private static string CreateStub(DescriptorInfo descriptorInfo)
132133
{
133134
var descriptor = descriptorInfo.Descriptor;
134-
var stub = @"# {ID}
135-
## ADD TITLE HERE
135+
var stub = $@"# {descriptor.Id}
136+
## {descriptor.Title.ToString(CultureInfo.InvariantCulture)}
136137
137138
<!-- start generated table -->
138139
<table>
139140
<tr>
140141
<td>CheckId</td>
141-
<td>{ID}</td>
142+
<td>{descriptor.Id}</td>
142143
</tr>
143144
<tr>
144145
<td>Severity</td>
145-
<td>{SEVERITY}</td>
146+
<td>{descriptor.DefaultSeverity.ToString()}</td>
146147
</tr>
147148
<tr>
148149
<td>Enabled</td>
149-
<td>{ENABLED}</td>
150+
<td>{(descriptor.IsEnabledByDefault ? "True" : "False")}</td>
150151
</tr>
151152
<tr>
152153
<td>Category</td>
153-
<td>{CATEGORY}</td>
154+
<td>{descriptor.Category}</td>
154155
</tr>
155156
<tr>
156157
<td>Code</td>
157-
<td><a href=""{URL}"">{TYPENAME}</a></td>
158+
<td><a href=""<URL>""><TYPENAME></a></td>
158159
</tr>
159160
</table>
160161
<!-- end generated table -->
161162
162163
## Description
163164
164-
ADD DESCRIPTION HERE
165+
{descriptor.Description.ToString(CultureInfo.InvariantCulture)}
165166
166167
## Motivation
167168
@@ -180,35 +181,28 @@ ADD HOW TO FIX VIOLATIONS HERE
180181
181182
### Via #pragma directive.
182183
```C#
183-
#pragma warning disable {ID} // {TITLE}
184+
#pragma warning disable {descriptor.Id} // {descriptor.Title.ToString(CultureInfo.InvariantCulture)}
184185
Code violating the rule here
185-
#pragma warning restore {ID} // {TITLE}
186+
#pragma warning restore {descriptor.Id} // {descriptor.Title.ToString(CultureInfo.InvariantCulture)}
186187
```
187188
188189
Or put this at the top of the file to disable all instances.
189190
```C#
190-
#pragma warning disable {ID} // {TITLE}
191+
#pragma warning disable {descriptor.Id} // {descriptor.Title.ToString(CultureInfo.InvariantCulture)}
191192
```
192193
193194
### Via attribute `[SuppressMessage]`.
194195
195196
```C#
196-
[System.Diagnostics.CodeAnalysis.SuppressMessage(""{CATEGORY}"",
197-
""{ID}:{TITLE}"",
197+
[System.Diagnostics.CodeAnalysis.SuppressMessage(""{descriptor.Category}"",
198+
""{descriptor.Id}:{descriptor.Title.ToString(CultureInfo.InvariantCulture)}"",
198199
Justification = ""Reason..."")]
199200
```
200-
<!-- end generated config severity -->"
201-
.AssertReplace("{ID}", descriptor.Id)
202-
.AssertReplace("## ADD TITLE HERE", $"## {descriptor.Title.ToString(CultureInfo.InvariantCulture)}")
203-
.AssertReplace("{SEVERITY}", descriptor.DefaultSeverity.ToString())
204-
.AssertReplace("{ENABLED}", descriptor.IsEnabledByDefault ? "true" : "false")
205-
.AssertReplace("{CATEGORY}", descriptor.Category)
206-
.AssertReplace("ADD DESCRIPTION HERE", descriptor.Description.ToString(CultureInfo.InvariantCulture))
207-
.AssertReplace("{TITLE}", descriptor.Title.ToString(CultureInfo.InvariantCulture));
201+
<!-- end generated config severity -->";
208202
if (Analyzers.Count(x => x.SupportedDiagnostics.Any(d => d.Id == descriptor.Id)) == 1)
209203
{
210-
return stub.AssertReplace("{TYPENAME}", descriptorInfo.Analyzer.GetType().Name)
211-
.AssertReplace("{URL}", descriptorInfo.CodeFileUri);
204+
return stub.AssertReplace("<TYPENAME>", descriptorInfo.Analyzer.GetType().Name)
205+
.AssertReplace("<URL>", descriptorInfo.CodeFileUri);
212206
}
213207

214208
var builder = StringBuilderPool.Borrow();

documentation/ASP001.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</tr>
1414
<tr>
1515
<td>Enabled</td>
16-
<td>true</td>
16+
<td>True</td>
1717
</tr>
1818
<tr>
1919
<td>Category</td>

documentation/ASP002.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</tr>
1414
<tr>
1515
<td>Enabled</td>
16-
<td>true</td>
16+
<td>True</td>
1717
</tr>
1818
<tr>
1919
<td>Category</td>

documentation/ASP003.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</tr>
1414
<tr>
1515
<td>Enabled</td>
16-
<td>true</td>
16+
<td>True</td>
1717
</tr>
1818
<tr>
1919
<td>Category</td>

documentation/ASP004.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</tr>
1414
<tr>
1515
<td>Enabled</td>
16-
<td>true</td>
16+
<td>True</td>
1717
</tr>
1818
<tr>
1919
<td>Category</td>

documentation/ASP005.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</tr>
1414
<tr>
1515
<td>Enabled</td>
16-
<td>true</td>
16+
<td>True</td>
1717
</tr>
1818
<tr>
1919
<td>Category</td>

0 commit comments

Comments
 (0)