From 06cef3ff7999085e81464663657e9968156bb570 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Mon, 30 Sep 2024 11:04:37 -0300 Subject: [PATCH] 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 --- src/ThisAssembly.Constants/CSharp.sbntxt | 2 +- src/ThisAssembly.Constants/ConstantsGenerator.cs | 10 ++-------- src/ThisAssembly.Resources/CSharp.sbntxt | 2 +- src/ThisAssembly.Resources/ResourcesGenerator.cs | 8 ++------ src/ThisAssembly.Strings/CSharp.sbntxt | 2 +- src/ThisAssembly.Strings/StringsGenerator.cs | 8 ++------ 6 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/ThisAssembly.Constants/CSharp.sbntxt b/src/ThisAssembly.Constants/CSharp.sbntxt index 758ae63f..73bbc8cb 100644 --- a/src/ThisAssembly.Constants/CSharp.sbntxt +++ b/src/ThisAssembly.Constants/CSharp.sbntxt @@ -30,7 +30,7 @@ {{ func remarks }} {{~ if Remarks ~}} {{ Remarks }} -/// +/// {{~ end ~}} {{ end }} {{ func render }} diff --git a/src/ThisAssembly.Constants/ConstantsGenerator.cs b/src/ThisAssembly.Constants/ConstantsGenerator.cs index 252a8964..2a963739 100644 --- a/src/ThisAssembly.Constants/ConstantsGenerator.cs +++ b/src/ThisAssembly.Constants/ConstantsGenerator.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using System.Text; -using System.Text.RegularExpressions; using Devlooped.Sponsors; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -17,8 +16,6 @@ namespace ThisAssembly; [Generator(LanguageNames.CSharp)] public class ConstantsGenerator : IIncrementalGenerator { - static readonly Regex SeeExpr = new("", RegexOptions.Compiled); - public void Initialize(IncrementalGeneratorInitializationContext context) { var files = context.AdditionalTextsProvider @@ -124,16 +121,13 @@ void GenerateConstant(SourceProductionContext spc, // structures via functions. if (parse.Language == LanguageNames.CSharp) { - output = SeeExpr.Replace(SyntaxFactory + output = SyntaxFactory .ParseCompilationUnit(output, options: cs) .NormalizeWhitespace() .GetText() - .ToString(), - $""); + .ToString(); } spc.AddSource($"{root}.{name}.g.cs", SourceText.From(output, Encoding.UTF8)); } - - } diff --git a/src/ThisAssembly.Resources/CSharp.sbntxt b/src/ThisAssembly.Resources/CSharp.sbntxt index 961aae6a..f47b7484 100644 --- a/src/ThisAssembly.Resources/CSharp.sbntxt +++ b/src/ThisAssembly.Resources/CSharp.sbntxt @@ -18,7 +18,7 @@ /// {{~ if Remarks ~}} {{ Remarks }} - /// + /// {{~ end ~}} {{~ if Warn ~}} [Obsolete("{{ Warn }}", false diff --git a/src/ThisAssembly.Resources/ResourcesGenerator.cs b/src/ThisAssembly.Resources/ResourcesGenerator.cs index 7b5ce772..80326fd5 100644 --- a/src/ThisAssembly.Resources/ResourcesGenerator.cs +++ b/src/ThisAssembly.Resources/ResourcesGenerator.cs @@ -4,7 +4,6 @@ using System.IO; using System.Linq; using System.Text; -using System.Text.RegularExpressions; using Devlooped.Sponsors; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -17,8 +16,6 @@ namespace ThisAssembly; [Generator(LanguageNames.CSharp)] public class ResourcesGenerator : IIncrementalGenerator { - static readonly Regex SeeExpr = new("", RegexOptions.Compiled); - public void Initialize(IncrementalGeneratorInitializationContext context) { context.RegisterPostInitializationOutput( @@ -124,12 +121,11 @@ static void GenerateSource(SourceProductionContext spc, }; var output = template.Render(model, member => member.Name); - output = SeeExpr.Replace(SyntaxFactory + output = SyntaxFactory .ParseCompilationUnit(output, options: parse as CSharpParseOptions) .NormalizeWhitespace() .GetText() - .ToString(), - $""); + .ToString(); spc.AddSource( $"{basePath.Replace('\\', '.').Replace('/', '.')}.g.cs", diff --git a/src/ThisAssembly.Strings/CSharp.sbntxt b/src/ThisAssembly.Strings/CSharp.sbntxt index 10fb93f8..105ab253 100644 --- a/src/ThisAssembly.Strings/CSharp.sbntxt +++ b/src/ThisAssembly.Strings/CSharp.sbntxt @@ -18,7 +18,7 @@ /// {{~ if Remarks ~}} {{ Remarks }} - /// + /// {{~ end ~}} {{~ if Warn ~}} [Obsolete("{{ Warn }}", false diff --git a/src/ThisAssembly.Strings/StringsGenerator.cs b/src/ThisAssembly.Strings/StringsGenerator.cs index 7c4fdebb..4c1ce370 100644 --- a/src/ThisAssembly.Strings/StringsGenerator.cs +++ b/src/ThisAssembly.Strings/StringsGenerator.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using System.Text; -using System.Text.RegularExpressions; using Devlooped.Sponsors; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -16,8 +15,6 @@ namespace ThisAssembly; [Generator(LanguageNames.CSharp)] public class StringsGenerator : IIncrementalGenerator { - static readonly Regex SeeExpr = new("", RegexOptions.Compiled); - public void Initialize(IncrementalGeneratorInitializationContext context) { // Read the ThisAssemblyNamespace property or default to null @@ -85,12 +82,11 @@ static void GenerateSource(SourceProductionContext spc, var output = template.Render(model, member => member.Name); - output = SeeExpr.Replace(SyntaxFactory + output = SyntaxFactory .ParseCompilationUnit(output, options: parse as CSharpParseOptions) .NormalizeWhitespace() .GetText() - .ToString(), - $""); + .ToString(); spc.AddSource(resourceName, SourceText.From(output, Encoding.UTF8)); }