Skip to content

Commit e55548b

Browse files
committed
Properly fix formatting error by switching to href
We were using cref, which is for API members, which is what was causing the formatting error in the first place. Fixes #408
1 parent fae4e05 commit e55548b

File tree

6 files changed

+9
-23
lines changed

6 files changed

+9
-23
lines changed

src/ThisAssembly.Constants/CSharp.sbntxt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
{{ func remarks }}
3131
{{~ if Remarks ~}}
3232
{{ Remarks }}
33-
/// <see cref="{{ Url }}"/>
33+
/// <see href="{{ Url }}"/>
3434
{{~ end ~}}
3535
{{ end }}
3636
{{ func render }}

src/ThisAssembly.Constants/ConstantsGenerator.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.IO;
44
using System.Linq;
55
using System.Text;
6-
using System.Text.RegularExpressions;
76
using Devlooped.Sponsors;
87
using Microsoft.CodeAnalysis;
98
using Microsoft.CodeAnalysis.CSharp;
@@ -17,8 +16,6 @@ namespace ThisAssembly;
1716
[Generator(LanguageNames.CSharp)]
1817
public class ConstantsGenerator : IIncrementalGenerator
1918
{
20-
static readonly Regex SeeExpr = new("<see.+sponsorlink\"/>", RegexOptions.Compiled);
21-
2219
public void Initialize(IncrementalGeneratorInitializationContext context)
2320
{
2421
var files = context.AdditionalTextsProvider
@@ -124,16 +121,13 @@ void GenerateConstant(SourceProductionContext spc,
124121
// structures via functions.
125122
if (parse.Language == LanguageNames.CSharp)
126123
{
127-
output = SeeExpr.Replace(SyntaxFactory
124+
output = SyntaxFactory
128125
.ParseCompilationUnit(output, options: cs)
129126
.NormalizeWhitespace()
130127
.GetText()
131-
.ToString(),
132-
$"<see cref=\"{Funding.HelpUrl}\"/>");
128+
.ToString();
133129
}
134130

135131
spc.AddSource($"{root}.{name}.g.cs", SourceText.From(output, Encoding.UTF8));
136132
}
137-
138-
139133
}

src/ThisAssembly.Resources/CSharp.sbntxt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/// </summary>
1919
{{~ if Remarks ~}}
2020
{{ Remarks }}
21-
/// <see cref="{{ Url }}"/>
21+
/// <see href="{{ Url }}"/>
2222
{{~ end ~}}
2323
{{~ if Warn ~}}
2424
[Obsolete("{{ Warn }}", false

src/ThisAssembly.Resources/ResourcesGenerator.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.IO;
55
using System.Linq;
66
using System.Text;
7-
using System.Text.RegularExpressions;
87
using Devlooped.Sponsors;
98
using Microsoft.CodeAnalysis;
109
using Microsoft.CodeAnalysis.CSharp;
@@ -17,8 +16,6 @@ namespace ThisAssembly;
1716
[Generator(LanguageNames.CSharp)]
1817
public class ResourcesGenerator : IIncrementalGenerator
1918
{
20-
static readonly Regex SeeExpr = new("<see.+sponsorlink\"/>", RegexOptions.Compiled);
21-
2219
public void Initialize(IncrementalGeneratorInitializationContext context)
2320
{
2421
context.RegisterPostInitializationOutput(
@@ -124,12 +121,11 @@ static void GenerateSource(SourceProductionContext spc,
124121
};
125122
var output = template.Render(model, member => member.Name);
126123

127-
output = SeeExpr.Replace(SyntaxFactory
124+
output = SyntaxFactory
128125
.ParseCompilationUnit(output, options: parse as CSharpParseOptions)
129126
.NormalizeWhitespace()
130127
.GetText()
131-
.ToString(),
132-
$"<see cref=\"{Funding.HelpUrl}\"/>");
128+
.ToString();
133129

134130
spc.AddSource(
135131
$"{basePath.Replace('\\', '.').Replace('/', '.')}.g.cs",

src/ThisAssembly.Strings/CSharp.sbntxt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/// </summary>
1919
{{~ if Remarks ~}}
2020
{{ Remarks }}
21-
/// <see cref="{{ Url }}"/>
21+
/// <see href="{{ Url }}"/>
2222
{{~ end ~}}
2323
{{~ if Warn ~}}
2424
[Obsolete("{{ Warn }}", false

src/ThisAssembly.Strings/StringsGenerator.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.IO;
44
using System.Linq;
55
using System.Text;
6-
using System.Text.RegularExpressions;
76
using Devlooped.Sponsors;
87
using Microsoft.CodeAnalysis;
98
using Microsoft.CodeAnalysis.CSharp;
@@ -16,8 +15,6 @@ namespace ThisAssembly;
1615
[Generator(LanguageNames.CSharp)]
1716
public class StringsGenerator : IIncrementalGenerator
1817
{
19-
static readonly Regex SeeExpr = new("<see.+sponsorlink\"/>", RegexOptions.Compiled);
20-
2118
public void Initialize(IncrementalGeneratorInitializationContext context)
2219
{
2320
// Read the ThisAssemblyNamespace property or default to null
@@ -85,12 +82,11 @@ static void GenerateSource(SourceProductionContext spc,
8582

8683
var output = template.Render(model, member => member.Name);
8784

88-
output = SeeExpr.Replace(SyntaxFactory
85+
output = SyntaxFactory
8986
.ParseCompilationUnit(output, options: parse as CSharpParseOptions)
9087
.NormalizeWhitespace()
9188
.GetText()
92-
.ToString(),
93-
$"<see cref=\"{Funding.HelpUrl}\"/>");
89+
.ToString();
9490

9591
spc.AddSource(resourceName, SourceText.From(output, Encoding.UTF8));
9692
}

0 commit comments

Comments
 (0)