Skip to content

Commit

Permalink
chore: Apply dotnet source code formatters (#10449)
Browse files Browse the repository at this point in the history
* chore: apply `dotnet format whitespace` command

* chore: apply `dotnet format style` command
  • Loading branch information
filzrev authored Dec 10, 2024
1 parent bc89912 commit d628967
Show file tree
Hide file tree
Showing 44 changed files with 57 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override ListWithStringFallback Read(ref Utf8JsonReader reader, Type type
{
using var document = JsonDocument.ParseValue(ref reader);
JsonElement root = document.RootElement;
var values = root.EnumerateObject().Select(x=>x.ToString());
var values = root.EnumerateObject().Select(x => x.ToString());
return new ListWithStringFallback(values);
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
serializer.Serialize(writer, ((MergeJsonConfig)value).ToArray());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public object Handle(object obj, HandleModelAttributesContext context)

protected virtual bool ShouldHandle(object currentObj, object declaringObject, PropInfo currentPropInfo, HandleModelAttributesContext context)
{
return currentPropInfo is {Attr: not null};
return currentPropInfo is { Attr: not null };
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public void Expand(Dictionary<string, ApiReferenceBuildOutput> references, strin

public static List<ApiLanguageValuePair> GetSpecNames(string xref, string[] supportedLanguages, SortedList<string, List<SpecViewModel>> specs = null)
{
if (specs is {Count: > 0})
if (specs is { Count: > 0 })
{
return (from spec in specs
where supportedLanguages.Contains(spec.Key)
Expand Down
8 changes: 4 additions & 4 deletions src/Docfx.Build.ManagedReference/FillReferenceInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ private void TraceSourceInfo(PageViewModel model, string file)
private static IEnumerable<string> GetUidsToFill(PageViewModel pageViewModel)
{
return from i in pageViewModel.Items
from c in (i.Children ?? Enumerable.Empty<string>())
.Concat(i.ExtensionMethods ?? Enumerable.Empty<string>())
.Concat(i.InheritedMembers ?? Enumerable.Empty<string>())
select c;
from c in (i.Children ?? Enumerable.Empty<string>())
.Concat(i.ExtensionMethods ?? Enumerable.Empty<string>())
.Concat(i.InheritedMembers ?? Enumerable.Empty<string>())
select c;
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build.OverwriteDocuments/OverwriteUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void AddOrUpdateFragmentProperty(this MarkdownFragment fragment, s
{
if (!fragment.Properties.TryGetValue(oPath, out var property))
{
fragment.Properties[oPath] = property = new MarkdownProperty { OPath = oPath};
fragment.Properties[oPath] = property = new MarkdownProperty { OPath = oPath };
}

if (string.IsNullOrEmpty(property.Content))
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build.RestApi/BuildRestApiDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private static void MarkupRecursive(JToken jToken, IHostService host, FileModel
{
if (MarkupKeys.Contains(pair.Key) && pair.Value != null)
{
if (pair.Value is JValue {Type: JTokenType.String} jValue)
if (pair.Value is JValue { Type: JTokenType.String } jValue)
{
jObject[pair.Key] = Markup(host, (string)jValue, model, filter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build.SchemaDriven/Models/JsonPointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public JsonPointer GetParentPointer()
public static bool TryCreate(string raw, out JsonPointer pointer)
{
pointer = null;
if (raw is {Length: > 0} && raw[0] != '/')
if (raw is { Length: > 0 } && raw[0] != '/')
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build.SchemaDriven/Processors/FileInterpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public FileInterpreter(bool exportFileLink, bool updateValue)

public bool CanInterpret(BaseSchema schema)
{
return schema is {ContentType: ContentType.File};
return schema is { ContentType: ContentType.File };
}

public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build.SchemaDriven/Processors/HrefInterpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public HrefInterpreter(bool exportFileLink, bool updateValue, string siteHostNam

public bool CanInterpret(BaseSchema schema)
{
return schema is {ContentType: ContentType.Href};
return schema is { ContentType: ContentType.Href };
}

public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class MarkdownInterpreter : IInterpreter
{
public bool CanInterpret(BaseSchema schema)
{
return schema is {ContentType: ContentType.Markdown};
return schema is { ContentType: ContentType.Markdown };
}

public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build.SchemaDriven/Processors/XrefInterpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public XrefInterpreter(bool aggregateXrefs, bool resolveXref)

public bool CanInterpret(BaseSchema schema)
{
return schema is {ContentType: ContentType.Xref};
return schema is { ContentType: ContentType.Xref };
}

public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build/TableOfContents/TocDocumentProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void UpdateTocItemHref(TocItemViewModel toc, FileModel model, IDocumentB
toc.OriginalTopicHref = null;

includedFrom = toc.IncludedFrom ?? includedFrom;
if (toc.Items is {Count: > 0})
if (toc.Items is { Count: > 0 })
{
foreach (var item in toc.Items)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build/TableOfContents/TocResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private TocItemInfo ResolveItemCore(TocItemInfo wrapper, Stack<FileAndType> stac
{
case HrefType.AbsolutePath:
case HrefType.RelativeFile:
if (item.Items is {Count: > 0})
if (item.Items is { Count: > 0 })
{
item.Items = new List<TocItemViewModel>(from i in item.Items
select ResolveItem(new TocItemInfo(file, i), stack) into r
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build/TableOfContents/TocRestructureUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private static void RestructureCore(TocItemViewModel item, List<TocItemViewModel
}
}

if (item.Items is {Count: > 0})
if (item.Items is { Count: > 0 })
{
var parentItems = new List<TocItemViewModel>(item.Items);
foreach (var i in item.Items)
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build/TemplateProcessors/TemplateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private IEnumerable<string> GetTemplateDirectories(IEnumerable<string> names)

public void ProcessTheme(string outputDirectory, bool overwrite)
{
if (_themes is {Count: > 0})
if (_themes is { Count: > 0 })
{
TryExportResourceFiles(_themes, outputDirectory, overwrite);
Logger.LogInfo($"Theme(s) {_themes.ToDelimitedString()} applied.");
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build/XRefMaps/XRefArchiveBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private async Task<string> DownloadCoreAsync(Uri uri, XRefArchive xa, Cancellati
// Sort is not needed if `map.Sorted == true`.
// But there are some xrefmap files that is not propery sorted by using InvariantCulture.
// (e.g. Unity xrefmap that maintained by community)
if (map.References is {Count: > 0})
if (map.References is { Count: > 0 })
{
map.References.Sort(XRefSpecUidComparer.Instance);
map.Sorted = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Common/Path/RelativePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static RelativePath FromUrl(string path)
public static bool IsRelativePath(string path)
{
// TODO : to merge with the PathUtility one
return path is {Length: > 0} &&
return path is { Length: > 0 } &&
path[0] != '/' &&
path[0] != '\\' &&
path.IndexOfAny(PathUtility.InvalidPathChars) == -1;
Expand Down
4 changes: 2 additions & 2 deletions src/Docfx.Dotnet/DotnetApiCatalog.Toc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ IEnumerable<TocNode> CreateToc(ISymbol symbol, Compilation compilation)

switch (symbol)
{
case INamespaceSymbol {IsGlobalNamespace: true} ns:
case INamespaceSymbol { IsGlobalNamespace: true } ns:
foreach (var child in ns.GetNamespaceMembers())
foreach (var item in CreateToc(child, compilation))
yield return item;
Expand Down Expand Up @@ -248,7 +248,7 @@ void InsertCategory(TocNodeType type, string name)
case CategoryLayout.Nested:
{
// Skip when parent node is category node.
if (parentTocNode is {type: TocNodeType.None})
if (parentTocNode is { type: TocNodeType.None })
return;

// If items contains specified type node. Create new TocNode for category. and move related node to child node.
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Dotnet/ExtensionMethods/ISymbolExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.CodeAnalysis;
using System.Collections.Immutable;
using System.Globalization;
using System.Reflection;
using System.Reflection.Emit;
using Microsoft.CodeAnalysis;

#nullable enable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Run(MetadataModel yaml, ResolverContext context)
(member, parent) =>
{
// get all the possible places where link is possible
if (member.Syntax is {Content: not null})
if (member.Syntax is { Content: not null })
{
SyntaxLanguage[] keys = new SyntaxLanguage[member.Syntax.Content.Count];
member.Syntax.Content.Keys.CopyTo(keys, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void Run(MetadataModel yaml, ResolverContext context)
page = parent;
current.References = null;
}
if (documentReferences is {Count: > 0})
if (documentReferences is { Count: > 0 })
{
foreach (var key in documentReferences.Keys)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class SetDerivedClass : IResolverPipeline

public void Run(MetadataModel yaml, ResolverContext context)
{
if (yaml.Members is {Count: > 0})
if (yaml.Members is { Count: > 0 })
{
UpdateDerivedClassMapping(yaml.Members, context.References);
AppendDerivedClass(yaml.Members);
Expand All @@ -23,7 +23,7 @@ private void UpdateDerivedClassMapping(List<MetadataItem> items, Dictionary<stri
foreach (var item in items ?? Enumerable.Empty<MetadataItem>())
{
var inheritance = item.Inheritance;
if (inheritance is {Count: > 0})
if (inheritance is { Count: > 0 })
{
var superClass = inheritance[inheritance.Count - 1];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public override MetadataItem VisitMethod(IMethodSymbol symbol)
}
_generator.GenerateSyntax(symbol, result.Syntax, _filter);

if (symbol is {IsOverride: true, OverriddenMethod: not null})
if (symbol is { IsOverride: true, OverriddenMethod: not null })
{
result.Overridden = AddSpecReference(symbol.OverriddenMethod, typeGenericParameters, methodGenericParameters);
}
Expand Down Expand Up @@ -298,7 +298,7 @@ public override MetadataItem VisitEvent(IEventSymbol symbol)

var typeGenericParameters = symbol.ContainingType.IsGenericType ? symbol.ContainingType.Accept(TypeGenericParameterNameVisitor.Instance) : EmptyListOfString;

if (symbol is {IsOverride: true, OverriddenEvent: not null})
if (symbol is { IsOverride: true, OverriddenEvent: not null })
{
result.Overridden = AddSpecReference(symbol.OverriddenEvent, typeGenericParameters);
}
Expand Down Expand Up @@ -352,7 +352,7 @@ public override MetadataItem VisitProperty(IPropertySymbol symbol)
Debug.Assert(result.Syntax.Return.Type != null);
}

if (symbol is {IsOverride: true, OverriddenProperty: not null})
if (symbol is { IsOverride: true, OverriddenProperty: not null })
{
result.Overridden = AddSpecReference(symbol.OverriddenProperty, typeGenericParameters);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static string GetId(ISymbol symbol)
return null;
}

if (symbol is INamespaceSymbol {IsGlobalNamespace: true})
if (symbol is INamespaceSymbol { IsGlobalNamespace: true })
{
return GlobalNamespaceId;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Docfx.Dotnet/Parsers/XmlComment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private void ResolveCrefLink(XNode node, string nodeSelector, Action<string, str
if (!success)
{
var detailedInfo = new StringBuilder();
if (_context is {Source: not null})
if (_context is { Source: not null })
{
if (!string.IsNullOrEmpty(_context.Source.Name))
{
Expand Down Expand Up @@ -640,7 +640,7 @@ static void MarkdownXmlDecode(MarkdownObject node)
MarkdownXmlDecode(child);
break;

case LeafBlock {Inline: not null} leafBlock:
case LeafBlock { Inline: not null } leafBlock:
foreach (var child in leafBlock.Inline)
MarkdownXmlDecode(child);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Dotnet/SourceLink/SourceLinkMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Text.Json;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;

#nullable enable

Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Dotnet/SymbolFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ bool IncludeAttributeDefault(ISymbol symbol)
private bool IsSymbolAccessible(ISymbol symbol)
{
// TODO: should we include implicitly declared members like constructors? They are part of the API contract.
if (symbol is {IsImplicitlyDeclared: true, Kind: not SymbolKind.Namespace})
if (symbol is { IsImplicitlyDeclared: true, Kind: not SymbolKind.Namespace })
return false;

if (_config.IncludeExplicitInterfaceImplementations &&
Expand Down
6 changes: 3 additions & 3 deletions src/Docfx.Dotnet/SymbolFormatter.Syntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ private void AddTypedConstant(TypedConstant typedConstant)
AddPunctuation(")");
break;

case TypedConstantKind.Array when typedConstant is {IsNull: false, Type: not null}:
case TypedConstantKind.Array when typedConstant is { IsNull: false, Type: not null }:
AddKeyword("new", "New");
AddSpace();
AddTypeName(typedConstant.Type);
Expand Down Expand Up @@ -460,7 +460,7 @@ private void AddEnumConstant(TypedConstant typedConstant)

private bool ExpandEnumClassName(ISymbol symbol, SymbolDisplayPart part)
{
if (symbol.Kind != SymbolKind.Field && part is {Kind: SymbolDisplayPartKind.EnumMemberName, Symbol: not null})
if (symbol.Kind != SymbolKind.Field && part is { Kind: SymbolDisplayPartKind.EnumMemberName, Symbol: not null })
{
_parts.Add(new(SymbolDisplayPartKind.EnumName, part.Symbol.ContainingSymbol, part.Symbol.ContainingSymbol.Name));
_parts.Add(new(SymbolDisplayPartKind.Punctuation, null, "."));
Expand All @@ -472,7 +472,7 @@ private bool ExpandEnumClassName(ISymbol symbol, SymbolDisplayPart part)

private bool StaticClassToVBModule(ISymbol symbol, SymbolDisplayPart part)
{
if (Language is SyntaxLanguage.VB && symbol is {IsStatic: true, Kind: SymbolKind.NamedType} &&
if (Language is SyntaxLanguage.VB && symbol is { IsStatic: true, Kind: SymbolKind.NamedType } &&
part.Kind == SymbolDisplayPartKind.Keyword && part.ToString() == "Class")
{
_parts.Add(new(SymbolDisplayPartKind.Keyword, null, "Module"));
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Dotnet/SymbolFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ LinkItem ToLinkItem(SymbolDisplayPart part)
if (symbol is null || part.Kind is SymbolDisplayPartKind.TypeParameterName)
return new() { DisplayName = part.ToString() };

if (symbol is INamedTypeSymbol {IsGenericType: true} type)
if (symbol is INamedTypeSymbol { IsGenericType: true } type)
symbol = type.ConstructedFrom;

return new()
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Dotnet/SymbolHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static bool IsMember(this ISymbol symbol)

public static bool IsClass(this ISymbol symbol)
{
return symbol.Kind is SymbolKind.NamedType && symbol is INamedTypeSymbol {TypeKind: TypeKind.Class};
return symbol.Kind is SymbolKind.NamedType && symbol is INamedTypeSymbol { TypeKind: TypeKind.Class };
}

public static bool IsEnumMember(this ISymbol symbol)
Expand Down
8 changes: 4 additions & 4 deletions src/Docfx.Dotnet/YamlViewModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private static ReferenceViewModel ToReferenceViewModel(KeyValuePair<string, Refe
Parent = model.Value.Parent,
Definition = model.Value.Definition,
};
if (model.Value.NameParts is {Count: > 0})
if (model.Value.NameParts is { Count: > 0 })
{
result.Name = GetName(model.Value.NameParts, SyntaxLanguage.Default);
var nameForCSharp = GetName(model.Value.NameParts, SyntaxLanguage.CSharp);
Expand Down Expand Up @@ -270,7 +270,7 @@ public static ItemViewModel ToItemViewModel(this MetadataItem model, ExtractMeta
Attributes = model.Attributes,
};

if (model.Parent is {Name: not null} && !model.Name.StartsWith(model.Parent.Name))
if (model.Parent is { Name: not null } && !model.Name.StartsWith(model.Parent.Name))
{
result.Id = model.Name.Substring(model.Name.LastIndexOf('.') + 1);
}
Expand Down Expand Up @@ -330,7 +330,7 @@ public static SyntaxDetailViewModel ToSyntaxDetailViewModel(this SyntaxDetail mo
TypeParameters = model.TypeParameters,
Return = model.Return,
};
if (model.Content is {Count: > 0})
if (model.Content is { Count: > 0 })
{
result.Content = model.Content.GetLanguageProperty(SyntaxLanguage.Default);
var contentForCSharp = model.Content.GetLanguageProperty(SyntaxLanguage.CSharp);
Expand Down Expand Up @@ -379,7 +379,7 @@ public static TValue GetLanguageProperty<TValue>(this SortedList<SyntaxLanguage,

private static void AddChildren(MetadataItem model, PageViewModel result, ExtractMetadataConfig config)
{
if (model.Items is {Count: > 0})
if (model.Items is { Count: > 0 })
{
foreach (var item in model.Items)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private static TabItemBlock CreateTabItem(
private static Tuple<string, string, LinkInline> ParseHeading(HeadingBlock block)
{
var child = block.Inline.FirstChild;
if (child is {NextSibling: null} and LinkInline link)
if (child is { NextSibling: null } and LinkInline link)
{
var m = HrefRegex().Match(link.Url);
if (m.Success)
Expand Down
Loading

0 comments on commit d628967

Please sign in to comment.