Skip to content

refactor: six duplication consolidations from the hygiene backlog#1268

Merged
nickna merged 6 commits into
mainfrom
worktree-backlog-dedups
Jul 11, 2026
Merged

refactor: six duplication consolidations from the hygiene backlog#1268
nickna merged 6 commits into
mainfrom
worktree-backlog-dedups

Conversation

@nickna

@nickna nickna commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Continues the audit backlog after #1266/#1267. Six independent consolidations, one commit each, all behavior-preserving:

Runtime

CLI

  • Program.cs: CompileModuleFile/CompileSingleFile duplicated the ~70-line EXE/DLL emission tail verbatim (temp-DLL, Save, --verify, AppHost bundling + explicit-bundler error handler, runtimeconfig, SharpTS.dll co-location). Both now route through EmitCompiledAssembly with the one differing compile step as a delegate. Smoke-verified end-to-end: --compile to DLL runs under dotnet; --compile --target exe bundles (built-in bundler) and the EXE runs.

Verification

  • Full unit suite: 15,452/15,452 pass
  • Test262 interpreter baseline diff clean (subset includes built-ins/JSON and built-ins/Object, directly covering the two riskiest items)
  • Per-item targeted slices ran green before each commit: crypto 447, clone/typed-array/worker 268, Object/lodash 191, JSON 193, descriptor/decorator 171

nickna added 6 commits July 10, 2026 19:14
…ons parse

The SHA-family digest switch was inlined 4x (pbkdf2Sync/hkdfSync + the
async pbkdf2/hkdf) and the scrypt N/r/p options parse (incl. the
power-of-2 check) 2x. Now ParseKdfDigest (deliberately narrower than
CryptoAlgorithms.ParseHashName — the .NET KDF primitives take only the
SHA family) and ParseScryptOptions, with the per-API error-message
prefixes preserved. 447 crypto tests pass.
…ubclass factories

CloneTypedArray dispatched through two 11-arm typeName switches
hard-coding every SharpTS*Array constructor, even though the source is
already a concrete SharpTSTypedArray whose virtual CreateView factories
encode the same mapping. Internal CreateViewFrom bridges expose those
factories; both switches (and their DataCloneError default arms, which
were unreachable for a real instance) are gone. A future element type
can no longer silently miss the clone path. 268 clone/typed-array/worker
tests pass.
…drivers

CompileModuleFile and CompileSingleFile duplicated the ~70-line
emission tail verbatim (temp-DLL + Guid path, ILCompiler construction,
Save, --verify, AppHost single-file bundling with the explicit-bundler
error handler, runtimeconfig generation, SharpTS.dll/external-reference
co-location) — a bundling or co-location fix could land in one copy
only. Both now route through EmitCompiledAssembly, which takes the one
differing step (CompileModules vs Compile) as a delegate.

Smoke-verified both branches end-to-end: --compile to DLL runs via
dotnet; --compile --target exe bundles (built-in bundler) and the EXE
runs.
…ver ladder

The three built-ins each hand-rolled the same ordered 8-branch receiver
dispatch (object, hole-skipping array, class instance, plain dictionary,
Math singleton #288, function/arrow expandos #314, other callables,
throw), differing only in the projection. One EnumerateOwnEnumerable
iterator now encodes the ladder; keys/values/entries project key, value,
or [key, value] pair. ~150 lines to ~85, and the array hole-skip loop
exists once. 191 Object/lodash tests pass.
…serializers

StringifyDictionary/StringifyObject/StringifyInstance were ~65-line
copies (a comment admitted it) of the same body: circular seen-guard,
empty-{} shortcut, pretty stepIndent, per-entry mark/serialize/
rewind-on-undefined, finally-remove. One StringifyJsonObject core now
takes (keys, read); keys are snapshot up front and values read lazily —
the spec's OwnPropertyKeys-then-Get order — which also drops
StringifyObject's filtered-Dictionary allocation on the allowedKeys
path. ~195 lines to ~95. 193 JSON tests pass; Test262 built-ins/JSON is
in the baseline run below.
…d extraction

FromObject / FromAnyObject(reflection) / FromDictionary / FromIDictionary
each hand-repeated the value/get/set/writable/enumerable/configurable
extraction (~35 lines apiece, with visible probe drift). One Populate
(has, read) core now runs it; each variant supplies only its probe/read
pair. FromObject keeps its HasProperty-OR-HasSetter probe on the
value/get/set arms — the #801 omitted-vs-explicitly-undefined
distinction that feeds defineProperty/decorators. 171 descriptor/
decorator tests pass.
@nickna
nickna merged commit c2b6c29 into main Jul 11, 2026
1 of 2 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.

1 participant