Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/Elastic.ApiExplorer/Schema/SchemaHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,38 @@ public static class SchemaHelpers
/// <summary>
/// Types that are known to be value types (resolve to primitives like string).
/// </summary>
public static readonly HashSet<string> KnownValueTypes = new(StringComparer.OrdinalIgnoreCase)
{
public static readonly HashSet<string> KnownValueTypes =
[
with(StringComparer.OrdinalIgnoreCase),
"Field", "Fields", "Id", "Ids", "IndexName", "Indices", "Name", "Names",
"Routing", "VersionNumber", "SequenceNumber", "PropertyName", "RelationName",
"TaskId", "ScrollId", "SuggestionName", "Duration", "DateMath", "Fuzziness",
"GeoHashPrecision", "Distance", "TimeOfDay", "MinimumShouldMatch", "Script",
"ByteSize", "Percentage", "Stringifiedboolean", "ExpandWildcards", "float", "Stringifiedinteger",
// Numeric value types
"uint", "ulong", "long", "int", "short", "ushort", "byte", "sbyte", "double", "decimal"
};
];

/// <summary>
/// Types that have dedicated pages we can link to.
/// Only container types get their own pages - individual queries/aggregations are rendered inline.
/// </summary>
public static readonly HashSet<string> LinkedTypes = new(StringComparer.OrdinalIgnoreCase)
{
public static readonly HashSet<string> LinkedTypes =
[
with(StringComparer.OrdinalIgnoreCase),
"QueryContainer", "AggregationContainer", "Aggregate"
};
];

/// <summary>
/// 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.
/// </summary>
public static readonly HashSet<string> PrimitiveTypeNames = new(StringComparer.OrdinalIgnoreCase)
{
public static readonly HashSet<string> PrimitiveTypeNames =
[
with(StringComparer.OrdinalIgnoreCase),
"boolean", "number", "string", "integer", "object", "null", "array"
};
];

/// <summary>
/// Gets the URL for a container type's dedicated page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public record ConfigurationFile

public HashSet<Product> Products { get; private set; } = [];

private readonly Dictionary<string, string> _substitutions = new(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, string> _substitutions = [with(StringComparer.OrdinalIgnoreCase)];
public IReadOnlyDictionary<string, string> Substitutions => _substitutions;

private readonly Dictionary<string, bool> _features = new(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, bool> _features = [with(StringComparer.OrdinalIgnoreCase)];

[field: AllowNull, MaybeNull]
public FeatureFlags Features => field ??= new FeatureFlags(_features);
Expand Down Expand Up @@ -259,7 +259,7 @@ public ConfigurationFile(DocumentationSetFile docSetFile, IDocumentationSetConte
Branding = ValidateBranding(docSetFile.Branding, context);

// Process features
_features = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
_features = [with(StringComparer.OrdinalIgnoreCase)];
if (docSetFile.Features.PrimaryNav.HasValue)
_features["primary-nav"] = docSetFile.Features.PrimaryNav.Value;
if (docSetFile.Features.DisableGithubEditLink.HasValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Elastic.Documentation.Configuration.Builder;

public class FeatureFlags(Dictionary<string, bool> initFeatureFlags)
{
private readonly Dictionary<string, bool> _featureFlags = new(initFeatureFlags);
private readonly Dictionary<string, bool> _featureFlags = [with(initFeatureFlags)];

public void Set(string key, bool value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
: [addAction];

var body = new JsonObject { ["actions"] = actions };

Expand Down
4 changes: 2 additions & 2 deletions src/Elastic.Markdown/IO/MarkdownFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public virtual string NavigationTitle


//indexed by slug
private readonly Dictionary<string, PageTocItem> _pageTableOfContent = new(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, PageTocItem> _pageTableOfContent = [with(StringComparer.OrdinalIgnoreCase)];
public IReadOnlyDictionary<string, PageTocItem> PageTableOfContent => _pageTableOfContent;

private readonly HashSet<string> _anchors = new(StringComparer.OrdinalIgnoreCase);
private readonly HashSet<string> _anchors = [with(StringComparer.OrdinalIgnoreCase)];
public IReadOnlySet<string> Anchors => _anchors;

public string FilePath { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
public HashSet<string> PrivateRepositories { get; private set; } = new(StringComparer.OrdinalIgnoreCase);
public HashSet<string> PrivateRepositories { get; private set; } = [with(StringComparer.OrdinalIgnoreCase)];

/// <summary>
/// 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.
/// </summary>
public HashSet<string> HideFeatures { get; private set; } = new(StringComparer.OrdinalIgnoreCase);
public HashSet<string> HideFeatures { get; private set; } = [with(StringComparer.OrdinalIgnoreCase)];

/// <summary>
/// How to handle PR/issue links relative to private bundle repos (see :link-visibility: option).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ private static PivotConfiguration ConvertPivot(PivotConfigurationYaml yamlPivot)
Dictionary<string, BundlePerProductRule>? byProduct = null;
if (yaml.Products is { Count: > 0 })
{
byProduct = new Dictionary<string, BundlePerProductRule>(StringComparer.OrdinalIgnoreCase);
byProduct = [with(StringComparer.OrdinalIgnoreCase)];
foreach (var (productKey, productYaml) in yaml.Products)
{
var productIds = productKey.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
Expand Down Expand Up @@ -947,7 +947,7 @@ private static PivotConfiguration ConvertPivot(PivotConfigurationYaml yamlPivot)
Dictionary<string, CreateRules>? byProduct = null;
if (yaml.Products is { Count: > 0 })
{
byProduct = new Dictionary<string, CreateRules>(StringComparer.OrdinalIgnoreCase);
byProduct = [with(StringComparer.OrdinalIgnoreCase)];
foreach (var (productKey, productYaml) in yaml.Products)
{
var productIds = productKey.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
Expand Down Expand Up @@ -1012,7 +1012,7 @@ private static PivotConfiguration ConvertPivot(PivotConfigurationYaml yamlPivot)
Dictionary<string, PublishBlocker>? byProduct = null;
if (yaml.Products is { Count: > 0 })
{
byProduct = new Dictionary<string, PublishBlocker>(StringComparer.OrdinalIgnoreCase);
byProduct = [with(StringComparer.OrdinalIgnoreCase)];
foreach (var (productKey, productYaml) in yaml.Products)
{
var productIds = productKey.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Elastic.Documentation.Build.Tests;
/// </summary>
public class MockEnvironmentVariables : IEnvironmentVariables
{
private readonly Dictionary<string, string> _variables = new(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, string> _variables = [with(StringComparer.OrdinalIgnoreCase)];

/// <summary>
/// Sets an environment variable value for testing.
Expand Down
Loading