Skip to content

Finish TryGetValue cleanup in FromEventJson implementations - #409

Draft
damyanpetev with Copilot wants to merge 74 commits into
masterfrom
copilot/mkirovanullable-cleanup-fromeventjson
Draft

Finish TryGetValue cleanup in FromEventJson implementations#409
damyanpetev with Copilot wants to merge 74 commits into
masterfrom
copilot/mkirovanullable-cleanup-fromeventjson

Conversation

Copilot AI commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #365, which converted the 21 ContainsKey + indexer lookups it had already touched (b304ed6). The remaining 63 sites across 23 hand-maintained event-args/component files under src/components/Blazor still did a double dictionary lookup; this converts them to a single TryGetValue.

Changes

  • Single-lookup conversion — every if (args != null && args.ContainsKey("x")) { … args["x"] … } in a FromEventJson body now uses TryGetValue, with the object? result passed straight to the existing ReturnTo* / ConvertReturnValue / StringToEnum helper.
  • Local naming<key>Obj, matching the convention established in b304ed6; no collisions with existing pattern variables such as detail.
  • Shape normalizationTileChangeStateEventArgs used the args?.ContainsKey("detail") == true && … args["detail"] variant; it now matches the same args != null && args.TryGetValue(...) form as its siblings.
  • Scope — hand-maintained files only. The other ContainsKey uses in src/componentsBase/BaseRendererControl.cs are internal state lookups, not event payload reads, and are untouched.
// before
if (args != null && args.ContainsKey("attachments"))
{ this.Attachments = ReturnToObjectArray<IgbChatMessageAttachment>(args["attachments"]); }

// after
if (args != null && args.TryGetValue("attachments", out var attachmentsObj))
{ this.Attachments = ReturnToObjectArray<IgbChatMessageAttachment>(attachmentsObj); }

Behavior is unchanged — TryGetValue returning false leaves out at null, which the guarded body never reads, so each site keeps the same "only assign when the key is present" semantics.

No new tests: the refactor is behavior-preserving and these decode paths are already exercised by the existing event tests (e.g. ComboTests drives ComboChangeEventArgsDetail.FromEventJson).

MayaKirova and others added 30 commits August 24, 2026 14:49
Co-authored-by: MayaKirova <10397980+MayaKirova@users.noreply.github.com>
…thread

Fix Copilot review findings: null-safety, dash encoding, delegate mismatch
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
MayaKirova and others added 20 commits September 1, 2026 16:28
Co-authored-by: MayaKirova <10397980+MayaKirova@users.noreply.github.com>
Fix null-component task completion race in dynamic content resolution
The full product made IgbDatePicker and IgbDateTimeInput Value, Min and Max nullable in 25.1.63, the shipped item templates bind a DateTime? field, and null is the only way to clear the element from Blazor. Generic value binding and EditForm integration for the date components are a separate change.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ReturnToString never returns null, so the getters built on it return string. IgcChatMessage id, text and sender, IgcChatMessageAttachment id and IgcTileChangeStateEventArgs tile are required on the client.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… operators

ConvertReturnValue returns object?, so the ReturnTo* guards and the component-side null checks are live again instead of being hidden behind null!. Dictionary getters return the raw value, the method-wide CS8604 pragmas are replaced by per-site checks, BuildSequenceInfo runs lazily rather than from the constructor, and collection notifications pass null items through as before. IgBlazor keeps the throwing getter: a nullable property would need about 150 guards at the module registration sites.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…htened

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: damyanpetev <3198469+damyanpetev@users.noreply.github.com>
Copilot AI changed the title [WIP] Cleanup remaining FromEventJson dictionary lookups Finish TryGetValue cleanup in FromEventJson implementations Sep 11, 2026
Copilot AI requested a review from damyanpetev September 11, 2026 07:52
Base automatically changed from mkirova/nullable to master September 11, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants