Skip to content

Commit

Permalink
chore: Fix code formatting (dotnet#10176)
Browse files Browse the repository at this point in the history
* chore: remove BOM from project files and extra whitespaces

* chore: apply `dotnet format whitespace` command

* chore: Apply `dotnet format style` command

* chore: enable file header template rule & apply `dotnet format style` command

* chore: fix build error

---------

Co-authored-by: Yufei Huang <[email protected]>
  • Loading branch information
filzrev and yufeih committed Sep 19, 2024
1 parent d84a0ef commit cfe7138
Show file tree
Hide file tree
Showing 85 changed files with 650 additions and 572 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ csharp_prefer_simple_using_statement = false:none # IDE006
csharp_using_directive_placement = outside_namespace:suggestion # IDE0065: using directive placement

# File header preferences
file_header_template = unset # IDE0073: Require file header
dotnet_diagnostic.IDE0073.severity = warning # IDE0073: Require file header
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.

# Namespace naming preferences
dotnet_style_namespace_match_folder = true:suggestion # IDE0130: Namespace does not match folder structure
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.App/Docfx.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<InternalsVisibleTo Include="docfx.Tests" />
<InternalsVisibleTo Include="docfx.Snapshot.Tests" />
</ItemGroup>

<ItemGroup>
<InternalsAssemblyName Include="UglyToad.PdfPig" />
</ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/Docfx.App/Helpers/MetadataMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public void Merge(MetadataMergeParameters parameters)
}
parameters.Metadata ??= ImmutableDictionary<string, object>.Empty;

Directory.CreateDirectory(parameters.OutputBaseDir);
Logger.LogInfo("Start merge metadata...");
MergePageViewModel(parameters);
MergeToc(parameters);
Logger.LogInfo("Merge metadata completed.");
Directory.CreateDirectory(parameters.OutputBaseDir);
Logger.LogInfo("Start merge metadata...");
MergePageViewModel(parameters);
MergeToc(parameters);
Logger.LogInfo("Merge metadata completed.");
}

private void MergePageViewModel(MetadataMergeParameters parameters)
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build.Common/Docfx.Build.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\Docfx.Common\Docfx.Common.csproj" />
<ProjectReference Include="..\Docfx.DataContracts.Common\Docfx.DataContracts.Common.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\Docfx.Common\Docfx.Common.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Markdig" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build.RestApi/Docfx.Build.RestApi.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\Docfx.Common\Docfx.Common.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Common\Docfx.Common.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\Docfx.Common\Docfx.Common.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build/ApiPage/ApiPageProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public FileModel Load(FileAndType file, ImmutableDictionary<string, object> meta
foreach (var (key, value) in data.metadata.OrderBy(item => item.Key))
content[key] = value.Value;
}

content["title"] = data.title;
content["content"] = ApiPageHtmlTemplate.Render(data, Markup).ToString();
content["yamlmime"] = "ApiPage";
Expand Down
4 changes: 2 additions & 2 deletions src/Docfx.Build/ManifestUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public static Manifest MergeManifest(List<Manifest> manifests)
ArgumentNullException.ThrowIfNull(manifests);

var xrefMaps = (from manifest in manifests
where manifest.Xrefmap != null
select manifest.Xrefmap).ToList();
where manifest.Xrefmap != null
select manifest.Xrefmap).ToList();
var manifestGroupInfos = (from manifest in manifests
from g in manifest.Groups ?? Enumerable.Empty<ManifestGroupInfo>()
select g).ToList();
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build/OneOfJsonConverterFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

using System.Diagnostics;
using System.Reflection;
using System.Text.Json.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;
using OneOf;

#nullable enable
Expand Down
5 changes: 4 additions & 1 deletion src/Docfx.Build/ResourceFiles/IResourceFileConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Docfx.Build.ResourceFiles;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Docfx.Build.ResourceFiles;

public interface IResourceFileConfig
{
Expand Down
5 changes: 4 additions & 1 deletion src/Docfx.Build/TableOfContents/MarkdownTocReader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Text.RegularExpressions;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text.RegularExpressions;
using Docfx.Common;
using Docfx.DataContracts.Common;
using Docfx.Plugins;
Expand Down
6 changes: 3 additions & 3 deletions src/Docfx.Build/TableOfContents/TocResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ private TocItemInfo ResolveItemCore(TocItemInfo wrapper, Stack<FileAndType> stac
if (item.Items != null && item.Items.Count > 0)
{
item.Items = new List<TocItemViewModel>(from i in item.Items
select ResolveItem(new TocItemInfo(file, i), stack) into r
where r != null
select r.Content);
select ResolveItem(new TocItemInfo(file, i), stack) into r
where r != null
select r.Content);
if (string.IsNullOrEmpty(item.TopicHref) && string.IsNullOrEmpty(item.TopicUid))
{
var defaultItem = GetDefaultHomepageItem(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static JsValue ConvertObjectToJsValue(Jint.Engine engine, object raw)
{
// allow Jint to take ownership of the array
var elements = new JsValue[list.Count];
for (int i = 0; i < (uint) elements.Length; i++)
for (int i = 0; i < (uint)elements.Length; i++)
{
elements[i] = ConvertObjectToJsValue(engine, list[i]);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Docfx.Common/ConvertToObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

using System.Diagnostics.CodeAnalysis;
using System.Dynamic;

using Newtonsoft.Json.Linq;
using System.Runtime.CompilerServices;
using Newtonsoft.Json.Linq;

namespace Docfx.Common;

Expand Down
5 changes: 4 additions & 1 deletion src/Docfx.Common/EntityMergers/IMergeContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Docfx.Common.EntityMergers;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Docfx.Common.EntityMergers;

public interface IMergeContext
{
Expand Down
5 changes: 4 additions & 1 deletion src/Docfx.Common/EntityMergers/IMergeHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Docfx.Common.EntityMergers;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Docfx.Common.EntityMergers;

public interface IMergeHandler
{
Expand Down
5 changes: 4 additions & 1 deletion src/Docfx.Common/EntityMergers/MergeContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Docfx.Common.EntityMergers;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Docfx.Common.EntityMergers;

internal sealed class MergeContext : IMergeContext
{
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Common/EntityMergers/MergePlacement.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.\r
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.


Expand Down
10 changes: 5 additions & 5 deletions src/Docfx.Common/EntityMergers/ReflectionEntityMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public void Merge(ref object source, object overrides, IMergeContext context)
placement =
placementValue switch
{
"after" => MergePlacement.After,
"before" => MergePlacement.Before,
"after" => MergePlacement.After,
"before" => MergePlacement.Before,
"replace" => MergePlacement.Replace,
_ => MergePlacement.None
_ => MergePlacement.None
};
}
}
Expand All @@ -117,8 +117,8 @@ public void Merge(ref object source, object overrides, IMergeContext context)

s = placement switch
{
MergePlacement.After => $"{s}{o}",
MergePlacement.Before => $"{o}{s}",
MergePlacement.After => $"{s}{o}",
MergePlacement.Before => $"{o}{s}",
MergePlacement.Replace => o.ToString()
};

Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Common/IItemWithMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.\r
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.


Expand Down
5 changes: 4 additions & 1 deletion src/Docfx.Common/LruList.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Docfx.Common;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Docfx.Common;

public class LruList<T>
{
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Common/Path/PathUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static string MakeRelativePath(string basePath, string absolutePath)

if (toUri.IsFile && !toUri.OriginalString.StartsWith("file://", StringComparison.InvariantCultureIgnoreCase))
{
return Path.GetRelativePath(basePath, absolutePath).BackSlashToForwardSlash();
return Path.GetRelativePath(basePath, absolutePath).BackSlashToForwardSlash();
}

Uri relativeUri = fromUri.MakeRelativeUri(toUri);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\Docfx.Common\Docfx.Common.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Immutable;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Immutable;

using Docfx.Common;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\Docfx.DataContracts.Common\Docfx.DataContracts.Common.csproj" />
<ProjectReference Include="..\Docfx.Common\Docfx.Common.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\Docfx.Common\Docfx.Common.csproj" />
<ProjectReference Include="..\Docfx.YamlSerialization\Docfx.YamlSerialization.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions src/Docfx.Dotnet/CompilationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public static (Compilation, IAssemblySymbol) CreateCompilationFromAssembly(strin
var compilation = CS.CSharpCompilation.Create(
assemblyName: null,
options: new CS.CSharpCompilationOptions(
outputKind : OutputKind.DynamicallyLinkedLibrary,
metadataImportOptions : includePrivateMembers
outputKind: OutputKind.DynamicallyLinkedLibrary,
metadataImportOptions: includePrivateMembers
? MetadataImportOptions.All
: MetadataImportOptions.Public
),
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Dotnet/DotnetApiCatalog.Toc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void InsertCategory(TocNodeType type, string name)

// Insert category as text label.
case CategoryLayout.Flattened:
default:
default:
{
if (items.FirstOrDefault(i => i.type == type) is { } node)
items.Insert(items.IndexOf(node), new() { name = name });
Expand Down
4 changes: 2 additions & 2 deletions src/Docfx.Dotnet/ManagedReference/Models/AdditionalNotes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
namespace Docfx.DataContracts.ManagedReference;

public class AdditionalNotes
{
{
[YamlMember(Alias = "caller")]
[JsonProperty("caller")]
[JsonPropertyName("caller")]
[MarkdownContent]
public string Caller { get; set; }

[YamlMember(Alias = "implementer")]
[JsonProperty("implementer")]
[JsonPropertyName("implementer")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public override MetadataItem VisitAssembly(IAssemblySymbol symbol)
{
{ SyntaxLanguage.Default, symbol.MetadataName },
},
DisplayQualifiedNames = new SortedList<SyntaxLanguage, string>
DisplayQualifiedNames = new SortedList<SyntaxLanguage, string>
{
{ SyntaxLanguage.Default, symbol.MetadataName },
},
Expand Down Expand Up @@ -185,7 +185,7 @@ public override MetadataItem VisitNamedType(INamedTypeSymbol symbol)
var member in symbol.GetMembers()
.Where(static s =>
s is not INamedTypeSymbol
&& ! s.Name.StartsWith('<')
&& !s.Name.StartsWith('<')
&& (s is not IMethodSymbol ms || ms.MethodKind != MethodKind.StaticConstructor)
))
{
Expand Down
5 changes: 4 additions & 1 deletion src/Docfx.Dotnet/Parsers/XHtmlWriter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Xml;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Xml;

/// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
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 @@ -374,9 +374,9 @@ private void ResolveCrefLink(XNode node, string nodeSelector, Action<string, str

if (detailedInfo.Length == 0 && node is XDocument doc)
{
var memberName = (string) doc.Element("member")?.Attribute("name");
var memberName = (string)doc.Element("member")?.Attribute("name");

if (! string.IsNullOrEmpty(memberName))
if (!string.IsNullOrEmpty(memberName))
{
detailedInfo.Append(", member name is ");
detailedInfo.Append(memberName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace Microsoft.CodeAnalysis.Debugging;

Expand Down
1 change: 0 additions & 1 deletion src/Docfx.Dotnet/SourceLink/SourceLinkMap.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.ObjectModel;
using System.Diagnostics;
Expand Down
1 change: 0 additions & 1 deletion src/Docfx.Dotnet/SourceLink/SymbolSourceDocumentFinder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
Expand Down
5 changes: 4 additions & 1 deletion src/Docfx.Dotnet/SymbolFormatter.Symbols.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Immutable;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
Expand Down
5 changes: 4 additions & 1 deletion src/Docfx.Dotnet/SymbolFormatter.Syntax.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Immutable;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Immutable;
using Docfx.DataContracts.ManagedReference;
using Microsoft.CodeAnalysis;
using CS = Microsoft.CodeAnalysis.CSharp;
Expand Down
5 changes: 4 additions & 1 deletion src/Docfx.Dotnet/SymbolFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Immutable;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Immutable;
using Docfx.DataContracts.ManagedReference;
using Microsoft.CodeAnalysis;
using CS = Microsoft.CodeAnalysis.CSharp;
Expand Down
5 changes: 4 additions & 1 deletion src/Docfx.Dotnet/SymbolHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Diagnostics.CodeAnalysis;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis;

#nullable enable
Expand Down
Loading

0 comments on commit cfe7138

Please sign in to comment.