Skip to content

Add @SafeDIConfiguration macro to replace CSV config#199

Merged
dfed merged 11 commits intomainfrom
dfed--swift-configuration
Mar 29, 2026
Merged

Add @SafeDIConfiguration macro to replace CSV config#199
dfed merged 11 commits intomainfrom
dfed--swift-configuration

Conversation

@dfed
Copy link
Copy Markdown
Owner

@dfed dfed commented Mar 29, 2026

Summary

  • Adds a @SafeDIConfiguration peer macro that decorates an enum with two required static let properties: additionalImportedModules: [StaticString] and additionalDirectoriesToInclude: [StaticString], validated at compile time with fix-its for missing properties
  • Updates SafeDITool to extract configuration from source files, with a second pass for additionalDirectoriesToInclude directories
  • Errors if both CSV files and @SafeDIConfiguration are present; CSV support retained with TODO comments for removal in 2.0
  • Updates README and ExampleMultiProjectIntegration to use the new macro instead of CSV files

Test plan

  • 13 new macro tests (behavior, error, fix-it)
  • 6 new FileVisitor tests for config detection
  • 2 new SafeDITool code generation tests for source config
  • 1 new SafeDITool error test for CSV+source conflict
  • All 364 tests pass

🤖 Generated with Claude Code

Introduce a @SafeDIConfiguration macro that allows SafeDI build configuration
to be expressed in Swift source code instead of CSV files. The macro decorates
a struct requiring two properties: `additionalImportedModules` and
`additionalDirectoriesToInclude`, both of type [StaticString] initialized with
string literal arrays. CSV files are still supported (with TODO comments for
removal in 2.0) but an error is raised if both are present.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dfed dfed self-assigned this Mar 29, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.91%. Comparing base (b81984c) to head (e82d78f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main     #199    +/-   ##
========================================
  Coverage   99.90%   99.91%            
========================================
  Files          32       36     +4     
  Lines        3274     3470   +196     
========================================
+ Hits         3271     3467   +196     
  Misses          3        3            
Files with missing lines Coverage Δ
...ICore/Errors/FixableSafeDIConfigurationError.swift 100.00% <100.00%> (ø)
...ensions/AttributeListSyntaxElementExtensions.swift 100.00% <100.00%> (ø)
...ore/Extensions/AttributeListSyntaxExtensions.swift 100.00% <100.00%> (ø)
...ources/SafeDICore/Models/SafeDIConfiguration.swift 100.00% <100.00%> (ø)
Sources/SafeDICore/Visitors/FileVisitor.swift 100.00% <100.00%> (ø)
...feDICore/Visitors/SafeDIConfigurationVisitor.swift 100.00% <100.00%> (ø)
...SafeDIMacros/Macros/SafeDIConfigurationMacro.swift 100.00% <100.00%> (ø)
Sources/SafeDIMacros/SafeDIMacroPlugin.swift 100.00% <100.00%> (ø)
Sources/SafeDITool/SafeDITool.swift 99.63% <100.00%> (+0.07%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

dfed and others added 10 commits March 28, 2026 19:01
Don't skip children when visiting a @SafeDIConfiguration-decorated struct,
so it can also participate in the dependency tree if decorated with
@INSTANTIABLE.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use an uninhabited enum instead of a struct to prevent accidental
instantiation. Properties are now static let, matching the constant
nature of the configuration. No visibility is enforced — the type
can be private, internal, public, etc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rmat

Add SafeDIConfiguration.swift to the ExampleMultiProjectIntegration
xcodeproj so the Xcode build tool plugin can see it. Also applies
SwiftFormat to new files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix findSwiftFiles to not re-read swiftSourcesFilePath on the second
pass for additionalDirectoriesToInclude. Add tests for the two-pass
directory scanning path, invalid config values in FileVisitor, and
the CSV+source conflict with includeFolders.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The decoratingNonEnum, additionalImportedModulesNotStringLiteralArray,
and additionalDirectoriesToIncludeNotStringLiteralArray cases were
thrown as plain errors in the macro, never used as fixable diagnostics.
Their diagnostic/fixIt paths were dead code causing coverage gaps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…itor

Covers the `continue` branch when a variable binding doesn't have
an identifier pattern (e.g. tuple destructuring).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rename tests to follow existing conventions and make them verify
meaningful behavior rather than just exercising code paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dfed dfed marked this pull request as ready for review March 29, 2026 17:04
@dfed dfed merged commit f57c521 into main Mar 29, 2026
25 checks passed
@dfed dfed deleted the dfed--swift-configuration branch March 29, 2026 17:20
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.

1 participant