Skip to content

Commit

Permalink
Rename base class for generators for better semantics
Browse files Browse the repository at this point in the history
The base generator provides built-in transformation from embedded templates, but the true "templated generators" will be the ones users can customize by providing their own templates.

This will make naming confusing down the road. So rename now before we embark on that.
  • Loading branch information
kzu committed Nov 29, 2024
1 parent 84be9a3 commit 17360d5
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public enum ReferenceCheck
ValueIsType,
}

public abstract class TemplateGenerator(string referenceType, string stringTemplate, string typeTemplate, ReferenceCheck referenceCheck = ReferenceCheck.ValueIsType) : IIncrementalGenerator
public abstract class BaseGenerator(string referenceType, string stringTemplate, string typeTemplate, ReferenceCheck referenceCheck = ReferenceCheck.ValueIsType) : IIncrementalGenerator
{
protected record struct TemplateArgs(string TargetNamespace, INamedTypeSymbol StructId, INamedTypeSymbol ValueType, INamedTypeSymbol ReferenceType, INamedTypeSymbol StringType);

Expand Down
2 changes: 1 addition & 1 deletion src/StructId.Analyzer/ComparableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace StructId;

[Generator(LanguageNames.CSharp)]
public class ComparableGenerator() : TemplateGenerator(
public class ComparableGenerator() : BaseGenerator(
"System.IComparable`1",
ThisAssembly.Resources.Templates.Comparable.Text,
ThisAssembly.Resources.Templates.Comparable.Text,
Expand Down
2 changes: 1 addition & 1 deletion src/StructId.Analyzer/ConstructorGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace StructId;

[Generator(LanguageNames.CSharp)]
public class ConstructorGenerator() : TemplateGenerator(
public class ConstructorGenerator() : BaseGenerator(
"System.Object",
ThisAssembly.Resources.Templates.Constructor.Text,
ThisAssembly.Resources.Templates.ConstructorT.Text,
Expand Down
2 changes: 1 addition & 1 deletion src/StructId.Analyzer/ConversionGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace StructId;

[Generator(LanguageNames.CSharp)]
public class ConversionGenerator() : TemplateGenerator(
public class ConversionGenerator() : BaseGenerator(
"System.Object",
ThisAssembly.Resources.Templates.Conversion.Text,
ThisAssembly.Resources.Templates.ConversionT.Text,
Expand Down
2 changes: 1 addition & 1 deletion src/StructId.Analyzer/DapperGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace StructId;

[Generator(LanguageNames.CSharp)]
public class DapperGenerator() : TemplateGenerator(
public class DapperGenerator() : BaseGenerator(
"Dapper.SqlMapper+TypeHandler`1", "", "", ReferenceCheck.TypeExists)
{
static readonly Template template = Template.Parse(ThisAssembly.Resources.DapperExtensions.Text);
Expand Down
2 changes: 1 addition & 1 deletion src/StructId.Analyzer/EntityFrameworkGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace StructId;

[Generator(LanguageNames.CSharp)]
public class EntityFrameworkGenerator() : TemplateGenerator(
public class EntityFrameworkGenerator() : BaseGenerator(
"Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter`2",
ThisAssembly.Resources.Templates.EntityFramework.Text,
ThisAssembly.Resources.Templates.EntityFramework.Text,
Expand Down
2 changes: 1 addition & 1 deletion src/StructId.Analyzer/NewableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace StructId;

[Generator(LanguageNames.CSharp)]
public class NewableGenerator() : TemplateGenerator(
public class NewableGenerator() : BaseGenerator(
"System.Object",
ThisAssembly.Resources.Templates.Newable.Text,
ThisAssembly.Resources.Templates.NewableT.Text,
Expand Down
2 changes: 1 addition & 1 deletion src/StructId.Analyzer/NewtonsoftJsonGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace StructId;

[Generator(LanguageNames.CSharp)]
public class NewtonsoftJsonGenerator() : TemplateGenerator(
public class NewtonsoftJsonGenerator() : BaseGenerator(
"Newtonsoft.Json.JsonConverter`1",
ThisAssembly.Resources.Templates.NewtonsoftJsonConverter.Text,
ThisAssembly.Resources.Templates.NewtonsoftJsonConverterT.Text,
Expand Down
2 changes: 1 addition & 1 deletion src/StructId.Analyzer/ParsableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace StructId;

[Generator(LanguageNames.CSharp)]
public class ParsableGenerator() : TemplateGenerator(
public class ParsableGenerator() : BaseGenerator(
"System.IParsable`1",
ThisAssembly.Resources.Templates.Parsable.Text,
ThisAssembly.Resources.Templates.ParsableT.Text);
2 changes: 1 addition & 1 deletion src/StructId.Analyzer/SystemTextJsonGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace StructId;

[Generator(LanguageNames.CSharp)]
public class SystemTextJsonGenerator() : TemplateGenerator(
public class SystemTextJsonGenerator() : BaseGenerator(
"System.IParsable`1",
ThisAssembly.Resources.Templates.JsonConverter.Text,
ThisAssembly.Resources.Templates.JsonConverterT.Text);
2 changes: 1 addition & 1 deletion src/StructId/Templates/TSelf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? prov
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, [MaybeNullWhen(false)] out TId result)
=> TryParse(s.ToString(), provider, out result);

public int CompareTo(TId other) => other.CompareTo(this);
public int CompareTo(TId other) => throw new NotImplementedException();
}

readonly partial record struct Self : IStructId
Expand Down

0 comments on commit 17360d5

Please sign in to comment.