Skip to content

Cleanup: instance-style extension calls, redundant generic args, and redundant casts#12583

Merged
niksedk merged 5 commits into
SubtitleEdit:mainfrom
ivandrofly:refactor/extension-method-call-style
Jul 18, 2026
Merged

Cleanup: instance-style extension calls, redundant generic args, and redundant casts#12583
niksedk merged 5 commits into
SubtitleEdit:mainfrom
ivandrofly:refactor/extension-method-call-style

Conversation

@ivandrofly

@ivandrofly ivandrofly commented Jul 17, 2026

Copy link
Copy Markdown
Member

Three small, behavior-preserving cleanup commits:

  1. Drop redundant <string> type argument from MakeComboBox calls — the generic type is inferred from the source collection, so the explicit <string> was just noise. Touches the DCinema SMPTE, iTunes Timed Text, Timed Text 1.0, IMSC 1.1 property windows, and the Cut Video window.

  2. Use instance-style extension method calls — convert static extension-method invocations to instance call syntax: LINQ (Enumerable.FirstOrDefault/Count/ToList), ObservableCollectionExtensions.AddRange, ClipboardExtensions.TryGetTextAsync, UiUtil.RemoveControlFromParent, and SplitToLines.

  3. Remove redundant and unnecessary casts — drop casts the compiler already supplies or that are no-ops: redundant numeric casts around Math.Round/division/TimeSpan.FromSeconds (integer-division semantics preserved), pointless (uint)/(int)/(byte) casts on already-correct types, leftover (IEnumerable<T>) upcasts before LINQ instance calls, and superfluous nullable/reference casts on ternary branches.

No behavior change. Full solution builds clean.

🤖 Generated with Claude Code

ivandrofly and others added 3 commits July 17, 2026 19:28
The generic type is inferred from the source collection, so the explicit
<string> is unnecessary noise.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Convert static extension-method invocations to instance call syntax:
LINQ (Enumerable.FirstOrDefault/Count/ToList), ObservableCollectionExtensions.AddRange,
ClipboardExtensions.TryGetTextAsync, UiUtil.RemoveControlFromParent, and SplitToLines.
More readable and idiomatic; no behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop casts that the compiler already provides implicitly or that are no-ops:
- redundant numeric casts around Math.Round / division / TimeSpan.FromSeconds
  where the operand or result type already matches (integer division semantics
  in AdvancedEffectAudioTextPulse are preserved);
- pointless (uint)/(int)/(byte) casts on already-correct types;
- (IEnumerable<T>) upcasts left over before LINQ instance calls;
- superfluous nullable/reference casts on ternary branches (e.g. : (T?)null).

No behavior change; full solution builds clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ivandrofly ivandrofly changed the title Cleanup: use instance-style extension method calls and drop redundant generic args Cleanup: instance-style extension calls, redundant generic args, and redundant casts Jul 17, 2026
@niksedk

niksedk commented Jul 18, 2026

Copy link
Copy Markdown
Member

AI-generated bug fix pull requests

For future AI-generated bug fix PRs, please limit each pull request to 1–3 related fixes (depending on their size and complexity). Smaller, focused PRs are much easier to review, test, and merge.

Please also include a brief manual comment describing how you personally verified each fix. AI-generated code can contain mistakes or unintended side effects, so every submitted change should be tested and validated by the contributor before opening the PR.

niksedk and others added 2 commits July 18, 2026 11:45
@niksedk

niksedk commented Jul 18, 2026

Copy link
Copy Markdown
Member

Reviewed hunk by hunk with focus on the cast removals, since "redundant" casts around arithmetic are where cleanups silently change semantics. All verified behavior-preserving:

  • The numeric-division hunks keep their original semantics: every removed (double) sat where a * 100.0 / - 10.0 / / 2.0 literal already forced double arithmetic, or (in AdvancedEffectAudioTextPulse) the cast applied to the result of the truncating long division, which is unchanged.
  • The overload-resolution traps check out: TimeCode(double) and Paragraph(string, double, double) are the only matching constructors, so the implicit ulongdouble conversions pick the same overloads the casts did.
  • SeWindowPosition.Width/Height are int, so the window-centering (int) casts were true no-ops (not double→int truncations).
  • nuintulong in the mpv stride write is an implicit, value-preserving conversion.
  • ClipboardExtensions is Avalonia's own extension class and IClipboard has no instance TryGetTextAsync, so instance syntax binds to the same method.
  • The target-typed null ternaries and ?? 0 coalescing hunks are compile-proven (a type mismatch would not build).

One leftover fixed on top: FontNames.FirstOrDefault<string>() kept the redundant generic argument the same commit was removing elsewhere.

Full solution builds clean; all 1,496 tests pass (libse, libuilogic, seconv, UI).

🤖 Generated with Claude Code

@niksedk
niksedk merged commit 54c47db into SubtitleEdit:main Jul 18, 2026
1 of 2 checks passed
@ivandrofly
ivandrofly deleted the refactor/extension-method-call-style branch July 18, 2026 09:55
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.

2 participants