Skip to content

Commit 2f18f40

Browse files
committed
refactor(core): change GetGeneratedNamespace to NoInlining for error paths
**Issue:** GetGeneratedNamespace() was marked with AggressiveInlining but is only called in exception/error paths (when serializers are not registered). **Problem:** - Method allocates a StringBuilder and performs string manipulation - Inlining this into every error-throwing call site bloats code size - Error paths should be optimized for smaller code, not speed - Misleading to mark error-path helpers as AggressiveInlining **Solution:** Changed `MethodImpl(MethodImplOptions.AggressiveInlining)` to `MethodImpl(MethodImplOptions.NoInlining)` with clarifying comment. **Benefits:** - Smaller code size at call sites (10 call sites across NinoSerializer/NinoDeserializer) - Clearer intent - this is an error path helper - Consistent with other error path methods (e.g., ThrowInvalidCast in NinoDeserializer.cs:302) - No performance impact (only called when exceptions are thrown) **Locations using this method (all error paths):** - NinoSerializer.cs: 154, 234, 268, 298 - NinoDeserializer.cs: 102, 148, 361, 384, 432, 455 This is a code quality improvement with no runtime performance impact in the success case.
1 parent eb4a801 commit 2f18f40

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/Nino.Core/NinoHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ internal static class NinoHelper
1212
/// <summary>
1313
/// Gets the generated namespace for a type's assembly.
1414
/// This must match the logic in NinoTypeHelper.GetNamespace()
15+
/// Called only in error paths - intentionally not inlined to keep call sites small.
1516
/// </summary>
16-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
17+
[MethodImpl(MethodImplOptions.NoInlining)]
1718
internal static string GetGeneratedNamespace(Type type)
1819
{
1920
var assemblyName = type.Assembly.GetName().Name ?? string.Empty;

0 commit comments

Comments
 (0)