Fix new SDK Warnings#3308
Conversation
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThis 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 ( 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
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>
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>
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>
This pull request modernizes and simplifies collection initializations throughout the codebase by adopting C# 12 collection expressions (using square brackets and the
withkeyword). 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:
DictionaryandHashSetwith collection expressions inSchemaHelpers.cs,ConfigurationFile.cs,FeatureFlags.cs,MarkdownFile.cs,ChangelogBlock.cs, andMockEnvironmentVariables.cs. This includes all static and instance fields that previously usednew Type(StringComparer.OrdinalIgnoreCase)or similar patterns. [1] [2] [3] [4] [5] [6] [7]Consistency in configuration and loader classes:
ChangelogConfigurationLoader.csto use collection expressions forbyProductdictionaries in multiple methods, ensuring a consistent and modern style. [1] [2] [3]Other syntax improvements:
ContentDateEnrichment.csby using a collection expression forJsonArray.