Skip to content

Reduce complexity in LoadEmbeddedLocalizations#590

Merged
ziagham merged 1 commit intoflowsynx:masterfrom
mohin-io:issue-588-reduce-localization-complexity
Oct 27, 2025
Merged

Reduce complexity in LoadEmbeddedLocalizations#590
ziagham merged 1 commit intoflowsynx:masterfrom
mohin-io:issue-588-reduce-localization-complexity

Conversation

@mohin-io
Copy link
Copy Markdown
Contributor

@mohin-io mohin-io commented Oct 26, 2025

Closes #588.

Summary

This contribution refactors the LoadEmbeddedLocalizations workflow to improve readability, modularity, and maintainability in accordance with the FlowSynx coding standards. The localization loading process is now decomposed into well-scoped helper methods that handle:

  1. Assembly enumeration
  2. Localization resource discovery
  3. Culture token extraction
  4. JSON payload loading and deserialization

By isolating these responsibilities, the localization pipeline is now easier to reason about, simpler to test, and more resilient to future extension (e.g., logging, diagnostics, or alternative resource formats). Existing merge semantics remain fully preserved.

Key-merge behaviour across assemblies

  • Extracted LoadEmbeddedLocalizations responsibilities into focused helpers that iterate assemblies, identify culture tokens, and read JSON payloads
  • Introduced guard clauses and XML doc comments to document each parsing stage and align with FlowSynx contribution standards
  • Preserved existing merge semantics while centralizing duplicate-key handling, ready for future logging enhancements

Implementation Details

  • LoadEmbeddedLocalizations now delegates to LoadAssemblyLocalizations, reducing branch depth and meeting the target cognitive complexity ≤ 15
  • Helper methods (GetLocalizationResourceNames, GetCultureFromResourceName, ReadLocalizationResource, MergeLocalizationEntries) encapsulate discrete operations and reuse shared logic
  • added System.Reflection import to support assembly-specific helpers and documented optional duplicate-key logging for maintainers

Testing

  • Not run (dotnet CLI unavailable locally: dotnet test)

@mohin-io mohin-io requested review from a team as code owners October 26, 2025 21:07
@sonarqubecloud
Copy link
Copy Markdown

@ziagham ziagham merged commit fae6e2b into flowsynx:master Oct 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Reduce Cognitive Complexity in LoadEmbeddedLocalizations()

2 participants