From 24eb22bc8c22262670ea2493d3f8e8c3bf6d466e Mon Sep 17 00:00:00 2001 From: Christian Helle Date: Tue, 3 Mar 2026 08:54:41 +0100 Subject: [PATCH 1/2] Fix #580: Auto-enable GenerateOptionalPropertiesAsNullable for nullable strings --- src/Refitter.Core/CSharpClientGeneratorFactory.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Refitter.Core/CSharpClientGeneratorFactory.cs b/src/Refitter.Core/CSharpClientGeneratorFactory.cs index 279b69585..6b1030e3b 100644 --- a/src/Refitter.Core/CSharpClientGeneratorFactory.cs +++ b/src/Refitter.Core/CSharpClientGeneratorFactory.cs @@ -62,6 +62,12 @@ public CustomCSharpClientGenerator Create() settings.CodeGeneratorSettings, generator.Settings.CSharpGeneratorSettings); + // Auto-enable optional properties as nullable when nullable reference types enabled + if (generator.Settings.CSharpGeneratorSettings.GenerateNullableReferenceTypes) + { + generator.Settings.CSharpGeneratorSettings.GenerateOptionalPropertiesAsNullable = true; + } + return generator; } From 3cc5f2b35d4a1c3fe58300c49b815c77e90b7797 Mon Sep 17 00:00:00 2001 From: Christian Helle Date: Tue, 3 Mar 2026 08:55:06 +0100 Subject: [PATCH 2/2] Fix #672: Scope method naming per-interface instead of globally --- .../RefitMultipleInterfaceByTagGenerator.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Refitter.Core/RefitMultipleInterfaceByTagGenerator.cs b/src/Refitter.Core/RefitMultipleInterfaceByTagGenerator.cs index b3b2afae9..1f43e6800 100644 --- a/src/Refitter.Core/RefitMultipleInterfaceByTagGenerator.cs +++ b/src/Refitter.Core/RefitMultipleInterfaceByTagGenerator.cs @@ -6,6 +6,7 @@ namespace Refitter.Core; internal class RefitMultipleInterfaceByTagGenerator : RefitInterfaceGenerator { private readonly HashSet knownIdentifiers = new(); + private Dictionary>? _methodIdentifiersByInterface; internal RefitMultipleInterfaceByTagGenerator( RefitGeneratorSettings settings, @@ -29,6 +30,8 @@ public override IEnumerable GenerateCode() Dictionary interfacesByGroup = new(); Dictionary interfacesNamesByGroup = new(); + + _methodIdentifiersByInterface = new(); foreach (var kv in byGroup) { @@ -59,6 +62,10 @@ public override IEnumerable GenerateCode() interfacesNamesByGroup[kv.Key] = interfaceName; } + else + { + interfaceName = interfacesNamesByGroup[kv.Key]; + } var operationName = GetOperationName(interfaceName, op.PathItem.Key, operations.Key, operation); var dynamicQuerystringParameterType = operationName + "QueryParams"; @@ -155,8 +162,19 @@ private string GetOperationName( string verb, OpenApiOperation operation) { - var generatedName = IdentifierUtils.Counted(knownIdentifiers, GenerateOperationName(name, verb, operation, capitalizeFirstCharacter: true), parent: interfaceName); - knownIdentifiers.Add($"{interfaceName}.{generatedName}"); + // Initialize per-interface tracking if needed + if (!_methodIdentifiersByInterface!.ContainsKey(interfaceName)) + { + _methodIdentifiersByInterface[interfaceName] = new HashSet(); + } + + var interfaceIdentifiers = _methodIdentifiersByInterface[interfaceName]; + var generatedName = IdentifierUtils.Counted( + interfaceIdentifiers, + GenerateOperationName(name, verb, operation, capitalizeFirstCharacter: true), + parent: interfaceName); + + interfaceIdentifiers.Add(generatedName); return generatedName; }