Skip to content

Fix new SDK Warnings#3308

Merged
cotti merged 3 commits into
mainfrom
fix/sdk-warn
May 12, 2026
Merged

Fix new SDK Warnings#3308
cotti merged 3 commits into
mainfrom
fix/sdk-warn

Conversation

@cotti
Copy link
Copy Markdown
Contributor

@cotti cotti commented May 12, 2026

This pull request modernizes and simplifies collection initializations throughout the codebase by adopting C# 12 collection expressions (using square brackets and the with keyword). This improves code readability and consistency, replacing older constructor-based initializations for dictionaries and hash sets. No functional changes are introduced—these are purely syntax and style improvements.

Adoption of C# 12 collection expressions:

  • Replaced constructor-based initializations of Dictionary and HashSet with collection expressions in SchemaHelpers.cs, ConfigurationFile.cs, FeatureFlags.cs, MarkdownFile.cs, ChangelogBlock.cs, and MockEnvironmentVariables.cs. This includes all static and instance fields that previously used new Type(StringComparer.OrdinalIgnoreCase) or similar patterns. [1] [2] [3] [4] [5] [6] [7]

Consistency in configuration and loader classes:

  • Updated dictionary initializations in ChangelogConfigurationLoader.cs to use collection expressions for byProduct dictionaries in multiple methods, ensuring a consistent and modern style. [1] [2] [3]

Other syntax improvements:

  • Simplified array initialization in ContentDateEnrichment.cs by using a collection expression for JsonArray.

@cotti cotti self-assigned this May 12, 2026
@cotti cotti requested a review from a team as a code owner May 12, 2026 20:39
@cotti cotti added the chore label May 12, 2026
@cotti cotti requested a review from reakaleek May 12, 2026 20:39
@cotti cotti changed the title Fix/sdk warn Fix new SDK Warnings May 12, 2026
@cotti cotti enabled auto-merge (squash) May 12, 2026 20:41
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: db62011b-f48d-4c29-9927-9453d340bc21

📥 Commits

Reviewing files that changed from the base of the PR and between 06c891b and cc0301d.

📒 Files selected for processing (8)
  • src/Elastic.ApiExplorer/Schema/SchemaHelpers.cs
  • src/Elastic.Documentation.Configuration/Builder/ConfigurationFile.cs
  • src/Elastic.Documentation.Configuration/Builder/FeatureFlags.cs
  • src/Elastic.Markdown/Exporters/Elasticsearch/ContentDateEnrichment.cs
  • src/Elastic.Markdown/IO/MarkdownFile.cs
  • src/Elastic.Markdown/Myst/Directives/Changelog/ChangelogBlock.cs
  • src/services/Elastic.Changelog/Configuration/ChangelogConfigurationLoader.cs
  • tests/Elastic.Documentation.Build.Tests/MockEnvironmentVariables.cs

📝 Walkthrough

Walkthrough

This PR modernizes collection initializations across eight files by replacing constructor-based syntax with C# collection expressions. All dictionaries and sets retain their original case-insensitive comparers (StringComparer.OrdinalIgnoreCase or equivalent). The changes span schema helpers, configuration builders, markdown processing, changelog configuration, and test utilities. No public APIs, behavior, or membership semantics are altered.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fix new SDK Warnings' is vague and does not clearly convey the actual change (modernizing to C# 12 collection expressions). Use a more specific title like 'Modernize collection initializations with C# 12 expressions' to better reflect the substantive change.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description is comprehensive and clearly explains the adoption of C# 12 collection expressions across multiple files with concrete examples.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/sdk-warn

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cotti cotti merged commit a75ed72 into main May 12, 2026
25 checks passed
@cotti cotti deleted the fix/sdk-warn branch May 12, 2026 20:49
cotti added a commit that referenced this pull request May 13, 2026
The collection expression `[addAction]` resolves to the generic
`JsonArray.Add<T>(T?)` overload, which is marked
`RequiresUnreferencedCode`/`RequiresDynamicCode` and fails AOT trim
analysis (IL2026/IL3050). Casting to `JsonNode` forces the AOT-safe
`Add(JsonNode?)` overload while keeping the collection-expression
syntax introduced in #3308.

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
theletterf added a commit that referenced this pull request May 13, 2026
Main #3308 ("Fix new SDK Warnings") uses C# 13 collection expression
`[with(comparer)]` to rewrite Dictionary<T> initializations that take
a custom IEqualityComparer, which satisfies IDE0028 in SDK 10.0.300+.
That fix lands here via the main merge, so the editorconfig override
from 7c4507e is no longer needed.

Also apply prettier formatting to NavigationSearchComponent.tsx (the
useQuery isError change from 307847b wasn't run through prettier).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
theletterf added a commit that referenced this pull request May 13, 2026
Two more dictionary fields with custom comparers were tripping IDE0028
under SDK 10.0.300 in the same way the dictionaries fixed in main #3308
did. Apply the same `[with(comparer)]` collection-expression rewrite.

CI was failing on these two lines across build, integration, and the
build (elastic/*) matrix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants