@@ -22,27 +22,29 @@ public async Task Execute()
22
22
var compilation = await FluentAssertionAnalyzerDocsUtils . GetFluentAssertionAnalyzerDocsCompilation ( ) ;
23
23
var compilationWithAnalyzers = compilation . WithAnalyzers ( ImmutableArray . Create ( analyzer ) ) ;
24
24
25
- var docs = new StringBuilder ( ) ;
26
- var toc = new StringBuilder ( ) ;
27
- var scenarios = new StringBuilder ( ) ;
28
-
29
- docs . AppendLine ( "<!--" ) ;
30
- docs . AppendLine ( "This is a generated file, please edit src\\ FluentAssertions.Analyzers.FluentAssertionAnalyzerDocsGenerator\\ DocsGenerator.cs to change the contents" ) ;
31
- docs . AppendLine ( "-->" ) ;
32
- docs . AppendLine ( ) ;
33
-
34
- docs . AppendLine ( "# FluentAssertions Analyzer Docs" ) ;
35
- docs . AppendLine ( ) ;
36
-
37
- scenarios . AppendLine ( "## Scenarios" ) ;
38
- scenarios . AppendLine ( ) ;
39
-
40
- var testAssembly = typeof ( FluentAssertions . Analyzers . FluentAssertionAnalyzerDocs . FluentAssertionsAnalyzerTests ) . Assembly ;
25
+ var testAssembly = typeof ( FluentAssertionAnalyzerDocs . FluentAssertionsAnalyzerTests ) . Assembly ;
41
26
42
27
foreach ( var tree in compilationWithAnalyzers . Compilation . SyntaxTrees . Where ( t => t . FilePath . EndsWith ( "Tests.cs" ) ) )
43
28
{
44
29
Console . WriteLine ( $ "File: { Path . GetFileName ( tree . FilePath ) } ") ;
45
30
31
+ var docsName = Path . GetFileNameWithoutExtension ( tree . FilePath ) . Replace ( "Tests" , ".md" ) ;
32
+
33
+ var docs = new StringBuilder ( ) ;
34
+ var toc = new StringBuilder ( ) ;
35
+ var scenarios = new StringBuilder ( ) ;
36
+
37
+ docs . AppendLine ( "<!--" ) ;
38
+ docs . AppendLine ( "This is a generated file, please edit src\\ FluentAssertions.Analyzers.FluentAssertionAnalyzerDocsGenerator\\ DocsGenerator.cs to change the contents" ) ;
39
+ docs . AppendLine ( "-->" ) ;
40
+ docs . AppendLine ( ) ;
41
+
42
+ var subject = Path . GetFileNameWithoutExtension ( tree . FilePath ) . Replace ( "AnalyzerTests" , string . Empty ) ;
43
+ docs . AppendLine ( $ "# { subject } Analyzer Docs") ;
44
+ docs . AppendLine ( ) ;
45
+
46
+ scenarios . AppendLine ( "## Scenarios" ) ;
47
+ scenarios . AppendLine ( ) ;
46
48
47
49
var root = await tree . GetRootAsync ( ) ;
48
50
var classDef = root . DescendantNodes ( ) . OfType < ClassDeclarationSyntax > ( ) . First ( ) ;
@@ -114,22 +116,22 @@ public async Task Execute()
114
116
Console . WriteLine ( $ "source: { root . FindNode ( diagnostic . Location . SourceSpan ) } ") ;
115
117
Console . WriteLine ( $ " diagnostic: { diagnostic } ") ;
116
118
}
117
- }
118
119
119
- docs . AppendLine ( toc . ToString ( ) ) ;
120
- docs . AppendLine ( ) ;
121
- docs . AppendLine ( scenarios . ToString ( ) ) ;
120
+ docs . AppendLine ( toc . ToString ( ) ) ;
121
+ docs . AppendLine ( ) ;
122
+ docs . AppendLine ( scenarios . ToString ( ) ) ;
122
123
123
- var docsPath = Path . Combine ( Environment . CurrentDirectory , ".." , ".." , "docs" , "FluentAssertionsAnalyzer.md" ) ;
124
- Directory . CreateDirectory ( Path . GetDirectoryName ( docsPath ) ) ;
125
- await File . WriteAllTextAsync ( docsPath , docs . ToString ( ) ) ;
124
+ var docsPath = Path . Combine ( Environment . CurrentDirectory , ".." , ".." , "docs" , docsName ) ;
125
+ Directory . CreateDirectory ( Path . GetDirectoryName ( docsPath ) ) ;
126
+ await File . WriteAllTextAsync ( docsPath , docs . ToString ( ) ) ;
127
+ }
126
128
}
127
129
128
- private string [ ] GetMethodExceptionMessageLines ( object instnace , MethodInfo method )
130
+ private string [ ] GetMethodExceptionMessageLines ( object instance , MethodInfo method )
129
131
{
130
132
try
131
133
{
132
- method . Invoke ( instnace , null ) ;
134
+ method . Invoke ( instance , null ) ;
133
135
}
134
136
catch ( Exception ex ) when ( ex . InnerException is AssertFailedException exception )
135
137
{
0 commit comments