From 6cbf4622b6ec5094fa24afd029720f11028814b8 Mon Sep 17 00:00:00 2001 From: Daniel Pindur Date: Mon, 19 Jan 2026 18:42:00 +0100 Subject: [PATCH 1/3] update to dotnet10 --- .github/workflows/dotnet-ci.yml | 2 +- examples/Example.Core/Example.Core.Api/Example.Core.Api.csproj | 2 +- examples/Example.Core/Example.Core/Example.Core.csproj | 2 +- test/Dango.Tests/Dango.Tests.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dotnet-ci.yml b/.github/workflows/dotnet-ci.yml index ceff6e5..2ed7e82 100644 --- a/.github/workflows/dotnet-ci.yml +++ b/.github/workflows/dotnet-ci.yml @@ -21,7 +21,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v5 with: - dotnet-version: 9.0 + dotnet-version: 10.0 # Install dependencies - name: Restore dependencies diff --git a/examples/Example.Core/Example.Core.Api/Example.Core.Api.csproj b/examples/Example.Core/Example.Core.Api/Example.Core.Api.csproj index 17b910f..237d661 100644 --- a/examples/Example.Core/Example.Core.Api/Example.Core.Api.csproj +++ b/examples/Example.Core/Example.Core.Api/Example.Core.Api.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable diff --git a/examples/Example.Core/Example.Core/Example.Core.csproj b/examples/Example.Core/Example.Core/Example.Core.csproj index 30f8d63..f11c66b 100644 --- a/examples/Example.Core/Example.Core/Example.Core.csproj +++ b/examples/Example.Core/Example.Core/Example.Core.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable diff --git a/test/Dango.Tests/Dango.Tests.csproj b/test/Dango.Tests/Dango.Tests.csproj index 948419e..56a6dd1 100644 --- a/test/Dango.Tests/Dango.Tests.csproj +++ b/test/Dango.Tests/Dango.Tests.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 latest enable enable From 8fa938a85b62eca6fc8a4be7a607f1fbf32a77d6 Mon Sep 17 00:00:00 2001 From: Daniel Pindur Date: Mon, 19 Jan 2026 19:24:11 +0100 Subject: [PATCH 2/3] small change to allow local refs --- .../Example.Core/Example.Core/Example.Core.csproj | 5 ++++- .../IDangoEnumMappingConfiguration.cs | 6 +++--- src/Dango/Analysis/MappingAnalyzer.cs | 4 ++-- src/Dango/Analysis/MappingResolver.cs | 10 +++++----- src/Dango/CodeGeneration/CodeGenerator.cs | 10 +++++----- src/Dango/Dango.csproj | 2 +- src/Dango/DangoGenerator.cs | 7 +++---- src/Dango/WellKnownTypes.cs | 13 +++++++++++++ test/Dango.Tests/Dango.Tests.csproj | 6 +++--- 9 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 src/Dango/WellKnownTypes.cs diff --git a/examples/Example.Core/Example.Core/Example.Core.csproj b/examples/Example.Core/Example.Core/Example.Core.csproj index f11c66b..406c1d2 100644 --- a/examples/Example.Core/Example.Core/Example.Core.csproj +++ b/examples/Example.Core/Example.Core/Example.Core.csproj @@ -12,7 +12,10 @@ - + + diff --git a/src/Dango.Abstractions/IDangoEnumMappingConfiguration.cs b/src/Dango.Abstractions/IDangoEnumMappingConfiguration.cs index f034919..c5ab034 100644 --- a/src/Dango.Abstractions/IDangoEnumMappingConfiguration.cs +++ b/src/Dango.Abstractions/IDangoEnumMappingConfiguration.cs @@ -15,14 +15,14 @@ public interface IDangoEnumMappingConfiguration /// /// The configuration instance for method chaining. IDangoEnumMappingConfiguration MapByValue(); - + /// /// Configures the mapping to match enum values by their names (default behavior). /// For example, SourceEnum.Active will map to DestinationEnum.Active if both exist. /// /// The configuration instance for method chaining. IDangoEnumMappingConfiguration MapByName(); - + /// /// Specifies a default destination value to use when a source enum value has no matching destination value. /// This prevents compilation errors when the destination enum has fewer values than the source. @@ -30,7 +30,7 @@ public interface IDangoEnumMappingConfiguration /// The default destination enum value to use for unmapped source values. /// The configuration instance for method chaining. IDangoEnumMappingConfiguration WithDefault(TDestination defaultValue); - + /// /// Provides custom mappings for specific source enum values, overriding the default mapping strategy. /// This is useful when certain values need special handling that doesn't follow the name or value pattern. diff --git a/src/Dango/Analysis/MappingAnalyzer.cs b/src/Dango/Analysis/MappingAnalyzer.cs index 96321e6..fac44dd 100644 --- a/src/Dango/Analysis/MappingAnalyzer.cs +++ b/src/Dango/Analysis/MappingAnalyzer.cs @@ -8,7 +8,7 @@ namespace Dango.Analysis; internal static class MappingAnalyzer { public static Dictionary> AnalyzeMappings( - SourceProductionContext context, + SourceProductionContext context, IMethodSymbol registerMethod, SemanticModel model) { @@ -210,7 +210,7 @@ private static void ProcessChainedInvocation( } private static void AddMapping( - Dictionary> enumMappingsBySourceEnum, + Dictionary> enumMappingsBySourceEnum, EnumPair enumPair, EnumMapping mapping) { diff --git a/src/Dango/Analysis/MappingResolver.cs b/src/Dango/Analysis/MappingResolver.cs index 674803a..a1c9461 100644 --- a/src/Dango/Analysis/MappingResolver.cs +++ b/src/Dango/Analysis/MappingResolver.cs @@ -8,7 +8,7 @@ namespace Dango.Analysis; internal static class MappingResolver { public static IEnumerable<(string SourceValue, string DestinationValue)> ResolveValueMappings( - SourceProductionContext context, + SourceProductionContext context, EnumPair enumPair, EnumMapping mapping) { @@ -21,7 +21,7 @@ internal static class MappingResolver } private static IEnumerable<(string SourceValue, string DestinationValue)> ResolveValueMappingsByName( - SourceProductionContext context, + SourceProductionContext context, EnumPair enumPair, EnumMapping mapping) { @@ -30,13 +30,13 @@ internal static class MappingResolver .Where(f => f.IsConst && f.IsStatic) .Select(f => f.Name) .ToList(); - + var destinationEnumValues = enumPair.DestinationEnum.GetMembers() .OfType() .Where(f => f.IsConst && f.IsStatic) .Select(f => f.Name) .ToImmutableHashSet(); - + foreach (var enumValue in sourceEnumValues) { if (mapping.Overrides is not null && mapping.Overrides.TryGetValue(enumValue, out var destNameOverride)) @@ -60,7 +60,7 @@ internal static class MappingResolver } private static IEnumerable<(string SourceValue, string DestinationValue)> ResolveValueMappingsByValue( - SourceProductionContext context, + SourceProductionContext context, EnumPair enumPair, EnumMapping mapping) { diff --git a/src/Dango/CodeGeneration/CodeGenerator.cs b/src/Dango/CodeGeneration/CodeGenerator.cs index 0b7e793..ab14a86 100644 --- a/src/Dango/CodeGeneration/CodeGenerator.cs +++ b/src/Dango/CodeGeneration/CodeGenerator.cs @@ -31,9 +31,9 @@ public static void GenerateSources( } private static CompilationUnitSyntax GenerateCompilationUnit( - string className, + string className, string assemblyName, - IEnumerable> mappingsForEnumPairs, + IEnumerable> mappingsForEnumPairs, SourceProductionContext context) { var methods = new List(); @@ -60,7 +60,7 @@ private static CompilationUnitSyntax GenerateCompilationUnit( .AddMembers(namespaceDeclaration) .WithLeadingTrivia( Comment("// "), EndOfLine("\n"), - Comment("// This code was generated by Dango tool. Do not change manually as changes will be overwritten."), EndOfLine("\n"), + Comment("// This code was generated by Dango tool. Do not change manually as changes will be overwritten."), EndOfLine("\n"), Comment("// "), EndOfLine("\n")); } @@ -86,9 +86,9 @@ private static MethodDeclarationSyntax GenerateNonNullableExtensionMethod( .AddArgumentListArguments(Argument(IdentifierName("value")))), Argument(IdentifierName("value")), Argument(LiteralExpression(SyntaxKind.NullLiteralExpression))))); - + var switchArms = mappings.Select(m => GenerateSwitchArm(enumPair, m)).Append(defaultArm).ToArray(); - + var switchExpression = SwitchExpression(IdentifierName("value")).AddArms(switchArms); return MethodDeclaration(destinationTypeName, mappingMethodName) diff --git a/src/Dango/Dango.csproj b/src/Dango/Dango.csproj index 65fb73a..a24a185 100644 --- a/src/Dango/Dango.csproj +++ b/src/Dango/Dango.csproj @@ -49,7 +49,7 @@ - + diff --git a/src/Dango/DangoGenerator.cs b/src/Dango/DangoGenerator.cs index 41b8a00..faf3907 100644 --- a/src/Dango/DangoGenerator.cs +++ b/src/Dango/DangoGenerator.cs @@ -1,7 +1,6 @@ using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Dango.Abstractions; using Dango.Analysis; using Dango.CodeGeneration; using Dango.ErrorHandling; @@ -27,7 +26,7 @@ private static void Execute(SourceProductionContext context, (Compilation compilation, ImmutableArray candidates) input) { var (compilation, candidates) = input; - var registrarInterface = compilation.GetTypeByMetadataName(typeof(IDangoMapperRegistrar).FullName!)!; + var registrarInterface = compilation.GetTypeByMetadataName(WellKnownTypes.IDangoMapperRegistrarFullName)!; var enumMappingsBySourceEnum = new Dictionary>(SymbolEqualityComparer.Default); var registrarInterfaceImplementationFound = false; @@ -47,7 +46,7 @@ private static void Execute(SourceProductionContext context, registrarInterfaceImplementationFound = true; - var registerMethod = symbol.GetMembers(nameof(IDangoMapperRegistrar.Register)) + var registerMethod = symbol.GetMembers(WellKnownTypes.RegisterMethodName) .OfType() .FirstOrDefault(m => m.Parameters.Length == 1); @@ -90,7 +89,7 @@ private static void AppendMappings( private static void AddToResolvedMappings( SourceProductionContext context, Location location, - Dictionary> enumMappingsBySourceEnum, + Dictionary> enumMappingsBySourceEnum, EnumPair enumPair, EnumMapping mapping) { diff --git a/src/Dango/WellKnownTypes.cs b/src/Dango/WellKnownTypes.cs new file mode 100644 index 0000000..a8aed99 --- /dev/null +++ b/src/Dango/WellKnownTypes.cs @@ -0,0 +1,13 @@ +namespace Dango; + +/// +/// Constants for well-known type metadata names. +/// These use nameof() to get compile-time type safety in the generator project, +/// but are used as strings at runtime (no runtime type loading required). +/// +internal static class WellKnownTypes +{ + // Compile-time constants that give us type safety + public const string IDangoMapperRegistrarFullName = nameof(Dango) + "." + nameof(Abstractions) + "." + nameof(Abstractions.IDangoMapperRegistrar); + public const string RegisterMethodName = nameof(Abstractions.IDangoMapperRegistrar.Register); +} diff --git a/test/Dango.Tests/Dango.Tests.csproj b/test/Dango.Tests/Dango.Tests.csproj index 56a6dd1..80ef6b3 100644 --- a/test/Dango.Tests/Dango.Tests.csproj +++ b/test/Dango.Tests/Dango.Tests.csproj @@ -11,11 +11,11 @@ - - + + - + From 47d2749e85ad4047ecd6e9d251940807b03725ac Mon Sep 17 00:00:00 2001 From: Daniel Pindur Date: Mon, 19 Jan 2026 19:31:27 +0100 Subject: [PATCH 3/3] fix release please dotnet version --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 078ea32..465a7a7 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -26,7 +26,7 @@ jobs: if: ${{ steps.release.outputs.release_created }} uses: actions/setup-dotnet@v5 with: - dotnet-version: '8.0.x' + dotnet-version: '10.0.x' - name: Restore dependencies if: ${{ steps.release.outputs.release_created }}