From 7c24613499c40c76b4dadecdd2032c0cab163535 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Tue, 12 May 2026 17:34:45 -0300 Subject: [PATCH 1/3] Fix new SDK warnings --- .../Builder/ConfigurationFile.cs | 6 +++--- .../Builder/FeatureFlags.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Elastic.Documentation.Configuration/Builder/ConfigurationFile.cs b/src/Elastic.Documentation.Configuration/Builder/ConfigurationFile.cs index dcb83203a9..d3a0b8eec8 100644 --- a/src/Elastic.Documentation.Configuration/Builder/ConfigurationFile.cs +++ b/src/Elastic.Documentation.Configuration/Builder/ConfigurationFile.cs @@ -47,10 +47,10 @@ public record ConfigurationFile public HashSet Products { get; private set; } = []; - private readonly Dictionary _substitutions = new(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary _substitutions = [with(StringComparer.OrdinalIgnoreCase)]; public IReadOnlyDictionary Substitutions => _substitutions; - private readonly Dictionary _features = new(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary _features = [with(StringComparer.OrdinalIgnoreCase)]; [field: AllowNull, MaybeNull] public FeatureFlags Features => field ??= new FeatureFlags(_features); @@ -259,7 +259,7 @@ public ConfigurationFile(DocumentationSetFile docSetFile, IDocumentationSetConte Branding = ValidateBranding(docSetFile.Branding, context); // Process features - _features = new Dictionary(StringComparer.OrdinalIgnoreCase); + _features = [with(StringComparer.OrdinalIgnoreCase)]; if (docSetFile.Features.PrimaryNav.HasValue) _features["primary-nav"] = docSetFile.Features.PrimaryNav.Value; if (docSetFile.Features.DisableGithubEditLink.HasValue) diff --git a/src/Elastic.Documentation.Configuration/Builder/FeatureFlags.cs b/src/Elastic.Documentation.Configuration/Builder/FeatureFlags.cs index 73ca47910f..3edfad1fc8 100644 --- a/src/Elastic.Documentation.Configuration/Builder/FeatureFlags.cs +++ b/src/Elastic.Documentation.Configuration/Builder/FeatureFlags.cs @@ -6,7 +6,7 @@ namespace Elastic.Documentation.Configuration.Builder; public class FeatureFlags(Dictionary initFeatureFlags) { - private readonly Dictionary _featureFlags = new(initFeatureFlags); + private readonly Dictionary _featureFlags = [with(initFeatureFlags)]; public void Set(string key, bool value) { From a97af3c7e54cb2d43531e8f633a58cdbfa62689f Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Tue, 12 May 2026 17:36:23 -0300 Subject: [PATCH 2/3] Fix new SDK warnings --- .../Schema/SchemaHelpers.cs | 21 +++++++++++-------- .../Elasticsearch/ContentDateEnrichment.cs | 2 +- src/Elastic.Markdown/IO/MarkdownFile.cs | 4 ++-- .../Directives/Changelog/ChangelogBlock.cs | 4 ++-- .../ChangelogConfigurationLoader.cs | 6 +++--- .../MockEnvironmentVariables.cs | 2 +- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/Elastic.ApiExplorer/Schema/SchemaHelpers.cs b/src/Elastic.ApiExplorer/Schema/SchemaHelpers.cs index b4c0652fd1..3b403c11dd 100644 --- a/src/Elastic.ApiExplorer/Schema/SchemaHelpers.cs +++ b/src/Elastic.ApiExplorer/Schema/SchemaHelpers.cs @@ -19,8 +19,9 @@ public static class SchemaHelpers /// /// Types that are known to be value types (resolve to primitives like string). /// - public static readonly HashSet KnownValueTypes = new(StringComparer.OrdinalIgnoreCase) - { + public static readonly HashSet KnownValueTypes = + [ + with(StringComparer.OrdinalIgnoreCase), "Field", "Fields", "Id", "Ids", "IndexName", "Indices", "Name", "Names", "Routing", "VersionNumber", "SequenceNumber", "PropertyName", "RelationName", "TaskId", "ScrollId", "SuggestionName", "Duration", "DateMath", "Fuzziness", @@ -28,26 +29,28 @@ public static class SchemaHelpers "ByteSize", "Percentage", "Stringifiedboolean", "ExpandWildcards", "float", "Stringifiedinteger", // Numeric value types "uint", "ulong", "long", "int", "short", "ushort", "byte", "sbyte", "double", "decimal" - }; + ]; /// /// Types that have dedicated pages we can link to. /// Only container types get their own pages - individual queries/aggregations are rendered inline. /// - public static readonly HashSet LinkedTypes = new(StringComparer.OrdinalIgnoreCase) - { + public static readonly HashSet LinkedTypes = + [ + with(StringComparer.OrdinalIgnoreCase), "QueryContainer", "AggregationContainer", "Aggregate" - }; + ]; /// /// Primitive/generic type names that are not named schema types. /// These should not be considered for recursive type detection since they /// represent generic types rather than specific schema references. /// - public static readonly HashSet PrimitiveTypeNames = new(StringComparer.OrdinalIgnoreCase) - { + public static readonly HashSet PrimitiveTypeNames = + [ + with(StringComparer.OrdinalIgnoreCase), "boolean", "number", "string", "integer", "object", "null", "array" - }; + ]; /// /// Gets the URL for a container type's dedicated page. diff --git a/src/Elastic.Markdown/Exporters/Elasticsearch/ContentDateEnrichment.cs b/src/Elastic.Markdown/Exporters/Elasticsearch/ContentDateEnrichment.cs index fcc0b605f8..04a1caea9c 100644 --- a/src/Elastic.Markdown/Exporters/Elasticsearch/ContentDateEnrichment.cs +++ b/src/Elastic.Markdown/Exporters/Elasticsearch/ContentDateEnrichment.cs @@ -192,7 +192,7 @@ private async Task SwapAliasAsync(string? oldIndex, string newIndex, Cancel ct) new JsonObject { ["remove"] = new JsonObject { ["index"] = oldIndex, ["alias"] = _lookupAlias } }, addAction ) - : new JsonArray(addAction); + : [with(addAction)]; var body = new JsonObject { ["actions"] = actions }; diff --git a/src/Elastic.Markdown/IO/MarkdownFile.cs b/src/Elastic.Markdown/IO/MarkdownFile.cs index 857ee32da8..3d2b6bad20 100644 --- a/src/Elastic.Markdown/IO/MarkdownFile.cs +++ b/src/Elastic.Markdown/IO/MarkdownFile.cs @@ -84,10 +84,10 @@ public virtual string NavigationTitle //indexed by slug - private readonly Dictionary _pageTableOfContent = new(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary _pageTableOfContent = [with(StringComparer.OrdinalIgnoreCase)]; public IReadOnlyDictionary PageTableOfContent => _pageTableOfContent; - private readonly HashSet _anchors = new(StringComparer.OrdinalIgnoreCase); + private readonly HashSet _anchors = [with(StringComparer.OrdinalIgnoreCase)]; public IReadOnlySet Anchors => _anchors; public string FilePath { get; } diff --git a/src/Elastic.Markdown/Myst/Directives/Changelog/ChangelogBlock.cs b/src/Elastic.Markdown/Myst/Directives/Changelog/ChangelogBlock.cs index c89052377d..954c932d5a 100644 --- a/src/Elastic.Markdown/Myst/Directives/Changelog/ChangelogBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/Changelog/ChangelogBlock.cs @@ -146,14 +146,14 @@ public class ChangelogBlock(DirectiveBlockParser parser, ParserContext context) /// Links to these repositories will be hidden (commented out) in the rendered output. /// Auto-detected from assembler configuration when available. /// - public HashSet PrivateRepositories { get; private set; } = new(StringComparer.OrdinalIgnoreCase); + public HashSet PrivateRepositories { get; private set; } = [with(StringComparer.OrdinalIgnoreCase)]; /// /// Feature IDs that should be hidden when rendering changelog entries. /// Combined from all loaded bundles' hide-features fields. /// Entries with matching feature-id values will be excluded from the output. /// - public HashSet HideFeatures { get; private set; } = new(StringComparer.OrdinalIgnoreCase); + public HashSet HideFeatures { get; private set; } = [with(StringComparer.OrdinalIgnoreCase)]; /// /// How to handle PR/issue links relative to private bundle repos (see :link-visibility: option). diff --git a/src/services/Elastic.Changelog/Configuration/ChangelogConfigurationLoader.cs b/src/services/Elastic.Changelog/Configuration/ChangelogConfigurationLoader.cs index a8c17ced35..4c866be716 100644 --- a/src/services/Elastic.Changelog/Configuration/ChangelogConfigurationLoader.cs +++ b/src/services/Elastic.Changelog/Configuration/ChangelogConfigurationLoader.cs @@ -749,7 +749,7 @@ private static PivotConfiguration ConvertPivot(PivotConfigurationYaml yamlPivot) Dictionary? byProduct = null; if (yaml.Products is { Count: > 0 }) { - byProduct = new Dictionary(StringComparer.OrdinalIgnoreCase); + byProduct = [with(StringComparer.OrdinalIgnoreCase)]; foreach (var (productKey, productYaml) in yaml.Products) { var productIds = productKey.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); @@ -947,7 +947,7 @@ private static PivotConfiguration ConvertPivot(PivotConfigurationYaml yamlPivot) Dictionary? byProduct = null; if (yaml.Products is { Count: > 0 }) { - byProduct = new Dictionary(StringComparer.OrdinalIgnoreCase); + byProduct = [with(StringComparer.OrdinalIgnoreCase)]; foreach (var (productKey, productYaml) in yaml.Products) { var productIds = productKey.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); @@ -1012,7 +1012,7 @@ private static PivotConfiguration ConvertPivot(PivotConfigurationYaml yamlPivot) Dictionary? byProduct = null; if (yaml.Products is { Count: > 0 }) { - byProduct = new Dictionary(StringComparer.OrdinalIgnoreCase); + byProduct = [with(StringComparer.OrdinalIgnoreCase)]; foreach (var (productKey, productYaml) in yaml.Products) { var productIds = productKey.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); diff --git a/tests/Elastic.Documentation.Build.Tests/MockEnvironmentVariables.cs b/tests/Elastic.Documentation.Build.Tests/MockEnvironmentVariables.cs index 04bebb7703..45cb7deaee 100644 --- a/tests/Elastic.Documentation.Build.Tests/MockEnvironmentVariables.cs +++ b/tests/Elastic.Documentation.Build.Tests/MockEnvironmentVariables.cs @@ -13,7 +13,7 @@ namespace Elastic.Documentation.Build.Tests; /// public class MockEnvironmentVariables : IEnvironmentVariables { - private readonly Dictionary _variables = new(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary _variables = [with(StringComparer.OrdinalIgnoreCase)]; /// /// Sets an environment variable value for testing. From cc0301de04a2f22ec023dfe9c2473bf4d648d56b Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Tue, 12 May 2026 17:37:30 -0300 Subject: [PATCH 3/3] Fix new SDK warnings --- .../Exporters/Elasticsearch/ContentDateEnrichment.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Elastic.Markdown/Exporters/Elasticsearch/ContentDateEnrichment.cs b/src/Elastic.Markdown/Exporters/Elasticsearch/ContentDateEnrichment.cs index 04a1caea9c..d4846ba9d8 100644 --- a/src/Elastic.Markdown/Exporters/Elasticsearch/ContentDateEnrichment.cs +++ b/src/Elastic.Markdown/Exporters/Elasticsearch/ContentDateEnrichment.cs @@ -192,7 +192,7 @@ private async Task SwapAliasAsync(string? oldIndex, string newIndex, Cancel ct) new JsonObject { ["remove"] = new JsonObject { ["index"] = oldIndex, ["alias"] = _lookupAlias } }, addAction ) - : [with(addAction)]; + : [addAction]; var body = new JsonObject { ["actions"] = actions };