Skip to content

chore: enforce *Create classes as package-internal - #47

Merged
michaelbushe merged 1 commit into
mainfrom
chore/internal-create-classes
Jul 18, 2026
Merged

chore: enforce *Create classes as package-internal#47
michaelbushe merged 1 commit into
mainfrom
chore/internal-create-classes

Conversation

@michaelbushe

Copy link
Copy Markdown
Member

Companion to MindfulSoftwareLLC/dartastic_opentelemetry#62 (which applied the same lockdown to the SDK's Create classes).

Why

The *Create classes were internal by doc-comment convention only. They're public classes in part files of barrel-exported libraries, so AttributesCreate.create() etc. were callable by any consumer — an open factory-bypass door, contradicting the beta.8/9 removal of factory cheat paths. (The SDK itself used AttributesCreate that way until #62 removed it.) The part of + private-constructor pattern protects the constructors; the public Create wrappers were exactly a public door to them.

What

  • @internal (package:meta) on all 28 *Create classes — analyzer rejects outside-package use (invalid_use_of_internal_member), dartdoc hides them
  • Barrel hides them, enforced by invalid_export_of_internal_element
  • meta imports added to host libraries
  • Factories, same-package code, and tests are unaffected

Validation

  • dart analyze lib test: no issues
  • Full suite: 753 passed, 0 failures
  • The SDK no longer references any API Create class (verified in #62), so releasing this as beta.10 breaks nothing downstream

🤖 Generated with Claude Code

@michaelbushe

Copy link
Copy Markdown
Member Author

@kevmoo If you have time please take a look at my use of Dart Language features to enforce creation of API (and SDK) objects via OTelFactory.

The Create classes were internal by doc-comment convention only —
public classes in part files of barrel-exported libraries, so
AttributesCreate.create() etc. were callable by any consumer: an open
factory-bypass door (the SDK itself used AttributesCreate that way
until dartastic_opentelemetry#62). The part-of/private-constructor
pattern protects the constructors, not the Create wrappers.

- @internal on all 28 Create classes
- barrel hides them (invalid_export_of_internal_element enforced)
- meta imports added to host libraries

Full suite: 753 passed, 0 failures.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@michaelbushe
michaelbushe force-pushed the chore/internal-create-classes branch from 2e8750a to 5d25709 Compare July 18, 2026 05:41
@michaelbushe
michaelbushe merged commit 3acebbf into main Jul 18, 2026
6 checks passed
@michaelbushe
michaelbushe deleted the chore/internal-create-classes branch July 18, 2026 05:49
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