diff --git a/src/StructId.Analyzer/TemplateGenerator.cs b/src/StructId.Analyzer/BaseGenerator.cs similarity index 96% rename from src/StructId.Analyzer/TemplateGenerator.cs rename to src/StructId.Analyzer/BaseGenerator.cs index 340e184..eee16ef 100644 --- a/src/StructId.Analyzer/TemplateGenerator.cs +++ b/src/StructId.Analyzer/BaseGenerator.cs @@ -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); diff --git a/src/StructId.Analyzer/ComparableGenerator.cs b/src/StructId.Analyzer/ComparableGenerator.cs index d4a760a..c257210 100644 --- a/src/StructId.Analyzer/ComparableGenerator.cs +++ b/src/StructId.Analyzer/ComparableGenerator.cs @@ -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, diff --git a/src/StructId.Analyzer/ConstructorGenerator.cs b/src/StructId.Analyzer/ConstructorGenerator.cs index 800ceb3..3473eb9 100644 --- a/src/StructId.Analyzer/ConstructorGenerator.cs +++ b/src/StructId.Analyzer/ConstructorGenerator.cs @@ -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, diff --git a/src/StructId.Analyzer/ConversionGenerator.cs b/src/StructId.Analyzer/ConversionGenerator.cs index bfbdb8e..64c71f7 100644 --- a/src/StructId.Analyzer/ConversionGenerator.cs +++ b/src/StructId.Analyzer/ConversionGenerator.cs @@ -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, diff --git a/src/StructId.Analyzer/DapperGenerator.cs b/src/StructId.Analyzer/DapperGenerator.cs index 8f1eef0..c7e45d8 100644 --- a/src/StructId.Analyzer/DapperGenerator.cs +++ b/src/StructId.Analyzer/DapperGenerator.cs @@ -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); diff --git a/src/StructId.Analyzer/EntityFrameworkGenerator.cs b/src/StructId.Analyzer/EntityFrameworkGenerator.cs index bd4f232..583fb50 100644 --- a/src/StructId.Analyzer/EntityFrameworkGenerator.cs +++ b/src/StructId.Analyzer/EntityFrameworkGenerator.cs @@ -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, diff --git a/src/StructId.Analyzer/NewableGenerator.cs b/src/StructId.Analyzer/NewableGenerator.cs index 21d58fc..18a0d5d 100644 --- a/src/StructId.Analyzer/NewableGenerator.cs +++ b/src/StructId.Analyzer/NewableGenerator.cs @@ -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, diff --git a/src/StructId.Analyzer/NewtonsoftJsonGenerator.cs b/src/StructId.Analyzer/NewtonsoftJsonGenerator.cs index 071dcea..993ec97 100644 --- a/src/StructId.Analyzer/NewtonsoftJsonGenerator.cs +++ b/src/StructId.Analyzer/NewtonsoftJsonGenerator.cs @@ -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, diff --git a/src/StructId.Analyzer/ParsableGenerator.cs b/src/StructId.Analyzer/ParsableGenerator.cs index 9ed739e..d9609c3 100644 --- a/src/StructId.Analyzer/ParsableGenerator.cs +++ b/src/StructId.Analyzer/ParsableGenerator.cs @@ -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); \ No newline at end of file diff --git a/src/StructId.Analyzer/SystemTextJsonGenerator.cs b/src/StructId.Analyzer/SystemTextJsonGenerator.cs index 9e8ddd0..39328bd 100644 --- a/src/StructId.Analyzer/SystemTextJsonGenerator.cs +++ b/src/StructId.Analyzer/SystemTextJsonGenerator.cs @@ -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); \ No newline at end of file diff --git a/src/StructId/Templates/TSelf.cs b/src/StructId/Templates/TSelf.cs index c6c7227..085618d 100644 --- a/src/StructId/Templates/TSelf.cs +++ b/src/StructId/Templates/TSelf.cs @@ -23,7 +23,7 @@ public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? prov public static bool TryParse(ReadOnlySpan 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