diff --git a/src/Docfx.Build.SchemaDriven/Models/JsonPointer.cs b/src/Docfx.Build.SchemaDriven/Models/JsonPointer.cs
index 96718e0667b..5b1284e1ea1 100644
--- a/src/Docfx.Build.SchemaDriven/Models/JsonPointer.cs
+++ b/src/Docfx.Build.SchemaDriven/Models/JsonPointer.cs
@@ -205,12 +205,7 @@ public static BaseSchema GetChildSchema(BaseSchema parent, string part)
return parent.Items;
}
- if (parent.Properties.TryGetValue(part, out var bs))
- {
- return bs;
- }
-
- return null;
+ return parent.Properties.GetValueOrDefault(part);
}
private static string UnescapeReference(string reference)
diff --git a/src/Docfx.Build.SchemaDriven/Processors/MarkdownAstInterpreter.cs b/src/Docfx.Build.SchemaDriven/Processors/MarkdownAstInterpreter.cs
index a59cabc612a..497851514e7 100644
--- a/src/Docfx.Build.SchemaDriven/Processors/MarkdownAstInterpreter.cs
+++ b/src/Docfx.Build.SchemaDriven/Processors/MarkdownAstInterpreter.cs
@@ -29,13 +29,13 @@ public object Interpret(BaseSchema schema, object value, IProcessContext context
if (value is MarkdownDocument val)
{
- return MarkupCore(val, context, path);
+ return MarkupCore(val, context);
}
return _inner.Interpret(schema, value, context, path);
}
- private static string MarkupCore(MarkdownDocument document, IProcessContext context, string path)
+ private static string MarkupCore(MarkdownDocument document, IProcessContext context)
{
var host = context.Host;
diff --git a/src/Docfx.Build.SchemaDriven/Processors/MarkdownInterpreter.cs b/src/Docfx.Build.SchemaDriven/Processors/MarkdownInterpreter.cs
index ceba2456501..a4c928497d7 100644
--- a/src/Docfx.Build.SchemaDriven/Processors/MarkdownInterpreter.cs
+++ b/src/Docfx.Build.SchemaDriven/Processors/MarkdownInterpreter.cs
@@ -36,8 +36,8 @@ private static string MarkupCore(string content, IProcessContext context, string
(context.UidLinkSources).Merge(mr.UidLinkSources);
(context.Dependency).UnionWith(mr.Dependency);
- if (mr.Html.StartsWith(@""), " jsonPath=\"" + path + "\"");
+ if (mr.Html.StartsWith("
"), " jsonPath=\"" + path + "\"");
return mr.Html;
}
}
diff --git a/src/Docfx.Build.SchemaDriven/SchemaFragmentsIterator.cs b/src/Docfx.Build.SchemaDriven/SchemaFragmentsIterator.cs
index cd0dfd13eb9..805974f4b4b 100644
--- a/src/Docfx.Build.SchemaDriven/SchemaFragmentsIterator.cs
+++ b/src/Docfx.Build.SchemaDriven/SchemaFragmentsIterator.cs
@@ -59,9 +59,9 @@ private void TraverseCore(
var propSchema = schema.Properties[key];
if (propSchema.Type == SchemaValueType.Object || propSchema.Type == SchemaValueType.Array)
{
- if (map.Children.ContainsKey(key))
+ if (map.Children.TryGetValue(key, out YamlNode child))
{
- TraverseCore(map.Children[key], fragments, propSchema, oPathPrefix + key, uid);
+ TraverseCore(child, fragments, propSchema, oPathPrefix + key, uid);
}
}
else
@@ -88,9 +88,9 @@ private void TraverseCore(
{
if (item is YamlMappingNode mapNode)
{
- if (mapNode.Children.ContainsKey(mergeKey))
+ if (mapNode.Children.TryGetValue(mergeKey, out YamlNode child))
{
- var opath = $"{parentOPath}[{mergeKey}=\"{mapNode.Children[mergeKey]}\"]";
+ var opath = $"{parentOPath}[{mergeKey}=\"{child}\"]";
TraverseCore(item, fragments, schema.Items, opath, uid);
}
else
diff --git a/src/Docfx.Build.SchemaDriven/ValidateFragmentsHandler.cs b/src/Docfx.Build.SchemaDriven/ValidateFragmentsHandler.cs
index 75dca189e65..2a21076f632 100644
--- a/src/Docfx.Build.SchemaDriven/ValidateFragmentsHandler.cs
+++ b/src/Docfx.Build.SchemaDriven/ValidateFragmentsHandler.cs
@@ -14,9 +14,9 @@ public class ValidateFragmentsHandler : ISchemaFragmentsHandler
public void HandleUid(string uidKey, YamlMappingNode node, Dictionary fragments, BaseSchema schema, string oPathPrefix, string uid)
{
- if (!fragments.ContainsKey(uid) && !_isMissingUidsLogged.ContainsKey(uid))
+ if (!fragments.ContainsKey(uid))
{
- _isMissingUidsLogged[uid] = false;
+ _isMissingUidsLogged.TryAdd(uid, false);
}
}
diff --git a/src/Docfx.Build.SchemaDriven/Validators/SchemaValidator.cs b/src/Docfx.Build.SchemaDriven/Validators/SchemaValidator.cs
index 39af31df8ca..834edbc8631 100644
--- a/src/Docfx.Build.SchemaDriven/Validators/SchemaValidator.cs
+++ b/src/Docfx.Build.SchemaDriven/Validators/SchemaValidator.cs
@@ -11,7 +11,7 @@ public class SchemaValidator
{
private readonly JsonSchema _schema;
- private static readonly EvaluationOptions DefaultOptions = new EvaluationOptions
+ private static readonly EvaluationOptions DefaultOptions = new()
{
ValidateAgainstMetaSchema = false,
OutputFormat = OutputFormat.List,
diff --git a/src/Docfx.Build.TagLevelRestApi/SplitRestApiToTagLevel.cs b/src/Docfx.Build.TagLevelRestApi/SplitRestApiToTagLevel.cs
index a064783fd5f..de7e7fc5852 100644
--- a/src/Docfx.Build.TagLevelRestApi/SplitRestApiToTagLevel.cs
+++ b/src/Docfx.Build.TagLevelRestApi/SplitRestApiToTagLevel.cs
@@ -77,7 +77,7 @@ private static Tuple, TreeItemRestructure> SplitModelToOperation
tagModel.Metadata["_isSplittedToTag"] = true;
var newModel = GenerateNewFileModel(model, tagModel);
splittedModels.Add(newModel);
- treeItems.Add(ConvertToTreeItem(tagModel, newModel.Key));
+ treeItems.Add(ConvertToTreeItem(tagModel));
}
// Only keep not tagged children in root model
@@ -173,7 +173,7 @@ private static IEnumerable CalculateUids(RestApiRootItemViewModel root)
}
}
- private static TreeItem ConvertToTreeItem(RestApiRootItemViewModel root, string fileKey)
+ private static TreeItem ConvertToTreeItem(RestApiRootItemViewModel root)
{
return new TreeItem
{
diff --git a/src/Docfx.Build.UniversalReference/BuildOutputs/ApiBuildOutput.cs b/src/Docfx.Build.UniversalReference/BuildOutputs/ApiBuildOutput.cs
index d1129555bf9..f5284e1a38d 100644
--- a/src/Docfx.Build.UniversalReference/BuildOutputs/ApiBuildOutput.cs
+++ b/src/Docfx.Build.UniversalReference/BuildOutputs/ApiBuildOutput.cs
@@ -175,5 +175,5 @@ public class ApiBuildOutput
[ExtensibleMember]
[Newtonsoft.Json.JsonExtensionData]
[System.Text.Json.Serialization.JsonExtensionData]
- public Dictionary Metadata { get; set; } = new Dictionary();
+ public Dictionary Metadata { get; set; } = new();
}
diff --git a/src/Docfx.Build.UniversalReference/BuildOutputs/ApiExceptionInfoBuildOutput.cs b/src/Docfx.Build.UniversalReference/BuildOutputs/ApiExceptionInfoBuildOutput.cs
index 1672ce2f5cb..d9963944c0f 100644
--- a/src/Docfx.Build.UniversalReference/BuildOutputs/ApiExceptionInfoBuildOutput.cs
+++ b/src/Docfx.Build.UniversalReference/BuildOutputs/ApiExceptionInfoBuildOutput.cs
@@ -24,5 +24,5 @@ public class ApiExceptionInfoBuildOutput
[ExtensibleMember]
[Newtonsoft.Json.JsonExtensionData]
[System.Text.Json.Serialization.JsonExtensionData]
- public Dictionary Metadata { get; set; } = new Dictionary();
+ public Dictionary Metadata { get; set; } = new();
}
diff --git a/src/Docfx.Build.UniversalReference/BuildOutputs/ApiInheritanceTreeBuildOutput.cs b/src/Docfx.Build.UniversalReference/BuildOutputs/ApiInheritanceTreeBuildOutput.cs
index 5041fe36a70..17666ce6e3f 100644
--- a/src/Docfx.Build.UniversalReference/BuildOutputs/ApiInheritanceTreeBuildOutput.cs
+++ b/src/Docfx.Build.UniversalReference/BuildOutputs/ApiInheritanceTreeBuildOutput.cs
@@ -30,5 +30,5 @@ public class ApiInheritanceTreeBuildOutput
[ExtensibleMember]
[Newtonsoft.Json.JsonExtensionData]
[System.Text.Json.Serialization.JsonExtensionData]
- public Dictionary Metadata { get; set; } = new Dictionary();
+ public Dictionary Metadata { get; set; } = new();
}
diff --git a/src/Docfx.Build.UniversalReference/BuildOutputs/ApiNames.cs b/src/Docfx.Build.UniversalReference/BuildOutputs/ApiNames.cs
index 043cfbf7304..687702098cc 100644
--- a/src/Docfx.Build.UniversalReference/BuildOutputs/ApiNames.cs
+++ b/src/Docfx.Build.UniversalReference/BuildOutputs/ApiNames.cs
@@ -45,5 +45,5 @@ public class ApiNames
[ExtensibleMember]
[Newtonsoft.Json.JsonExtensionData]
[System.Text.Json.Serialization.JsonExtensionData]
- public Dictionary Metadata { get; set; } = new Dictionary();
+ public Dictionary Metadata { get; set; } = new();
}
diff --git a/src/Docfx.Build.UniversalReference/BuildOutputs/ApiParameterBuildOutput.cs b/src/Docfx.Build.UniversalReference/BuildOutputs/ApiParameterBuildOutput.cs
index a5e6ba7ffed..f9e9419457b 100644
--- a/src/Docfx.Build.UniversalReference/BuildOutputs/ApiParameterBuildOutput.cs
+++ b/src/Docfx.Build.UniversalReference/BuildOutputs/ApiParameterBuildOutput.cs
@@ -39,5 +39,5 @@ public class ApiParameterBuildOutput
[ExtensibleMember]
[Newtonsoft.Json.JsonExtensionData]
[System.Text.Json.Serialization.JsonExtensionData]
- public Dictionary Metadata { get; set; } = new Dictionary();
+ public Dictionary Metadata { get; set; } = new();
}
diff --git a/src/Docfx.Build.UniversalReference/BuildOutputs/ApiSyntaxBuildOutput.cs b/src/Docfx.Build.UniversalReference/BuildOutputs/ApiSyntaxBuildOutput.cs
index e3e3d4ac55b..70490d78d8c 100644
--- a/src/Docfx.Build.UniversalReference/BuildOutputs/ApiSyntaxBuildOutput.cs
+++ b/src/Docfx.Build.UniversalReference/BuildOutputs/ApiSyntaxBuildOutput.cs
@@ -35,5 +35,5 @@ public class ApiSyntaxBuildOutput
[ExtensibleMember]
[Newtonsoft.Json.JsonExtensionData]
[System.Text.Json.Serialization.JsonExtensionData]
- public Dictionary Metadata { get; set; } = new Dictionary();
+ public Dictionary Metadata { get; set; } = new();
}
diff --git a/src/Docfx.Build.UniversalReference/FillReferenceInformation.cs b/src/Docfx.Build.UniversalReference/FillReferenceInformation.cs
index 6bc02b37982..3f0a238d371 100644
--- a/src/Docfx.Build.UniversalReference/FillReferenceInformation.cs
+++ b/src/Docfx.Build.UniversalReference/FillReferenceInformation.cs
@@ -28,14 +28,14 @@ public override void Postbuild(ImmutableList models, IHostService hos
{
continue;
}
- FillCore((PageViewModel)model.Content, host, model.OriginalFileAndType.File);
+ FillCore((PageViewModel)model.Content, host);
}
}
}
#region Private methods
- private static void FillCore(PageViewModel model, IHostService host, string file)
+ private static void FillCore(PageViewModel model, IHostService host)
{
if (model.References == null || model.References.Count == 0)
{
diff --git a/src/Docfx.Build.UniversalReference/ModelConverter.cs b/src/Docfx.Build.UniversalReference/ModelConverter.cs
index 44e18876d53..e0bbd94a4e8 100644
--- a/src/Docfx.Build.UniversalReference/ModelConverter.cs
+++ b/src/Docfx.Build.UniversalReference/ModelConverter.cs
@@ -100,12 +100,12 @@ List> ToSpec()
var specs = src.Specs;
foreach (var language in supportedLanguages)
{
- if (specs?.ContainsKey(language) == true)
+ if (specs?.TryGetValue(language, out List spec) is true)
{
result.Add(new ApiLanguageValuePair
{
Language = language,
- Value = GetSpecName(specs[language])
+ Value = GetSpecName(spec)
});
}
else
@@ -394,7 +394,7 @@ public static List> ToApiListInDevLangs(T defaultValu
result.Add(new ApiLanguageValuePair
{
Language = language,
- Value = values.ContainsKey(language) ? values[language] : defaultValue,
+ Value = values.GetValueOrDefault(language, defaultValue),
});
}
diff --git a/src/Docfx.Build/ApiPage/ApiPageHtmlTemplate.cs b/src/Docfx.Build/ApiPage/ApiPageHtmlTemplate.cs
index 6a46867a5de..ea1ab38d6d7 100644
--- a/src/Docfx.Build/ApiPage/ApiPageHtmlTemplate.cs
+++ b/src/Docfx.Build/ApiPage/ApiPageHtmlTemplate.cs
@@ -44,7 +44,7 @@ HtmlTemplate Api(Api api)
var value = (ApiBase)api.Value;
var attributes = value.metadata is null
? default
- : UnsafeHtml(string.Join(" ", value.metadata.Select(m => $"data-{WebUtility.HtmlEncode(m.Key)}='{WebUtility.HtmlEncode(m.Value)}'")));
+ : UnsafeHtml(string.Join(' ', value.metadata.Select(m => $"data-{WebUtility.HtmlEncode(m.Key)}='{WebUtility.HtmlEncode(m.Value)}'")));
var (level, title) = api.Value switch
{
diff --git a/src/Docfx.Build/CompilePhaseHandler.cs b/src/Docfx.Build/CompilePhaseHandler.cs
index 1dc41221526..e6ad1537014 100644
--- a/src/Docfx.Build/CompilePhaseHandler.cs
+++ b/src/Docfx.Build/CompilePhaseHandler.cs
@@ -26,7 +26,7 @@ public void Handle(List hostServices, int maxParallelism)
Prepare(hostServices, maxParallelism);
hostServices.RunAll(hostService =>
{
- var steps = string.Join("=>", hostService.Processor.BuildSteps.OrderBy(step => step.BuildOrder).Select(s => s.Name));
+ var steps = string.Join("=>", hostService.Processor.BuildSteps.OrderBy(static step => step.BuildOrder).Select(static s => s.Name));
Logger.LogInfo($"Building {hostService.Models.Count} file(s) in {hostService.Processor.Name}({steps})...");
Logger.LogVerbose($"Processor {hostService.Processor.Name}: Prebuilding...");
Prebuild(hostService);
@@ -144,7 +144,7 @@ private static void RunBuildSteps(IEnumerable buildSteps, Ac
{
if (buildSteps != null)
{
- foreach (var buildStep in buildSteps.OrderBy(step => step.BuildOrder))
+ foreach (var buildStep in buildSteps.OrderBy(static step => step.BuildOrder))
{
action(buildStep);
}
diff --git a/src/Docfx.Build/Conceptual/WordCounter.cs b/src/Docfx.Build/Conceptual/WordCounter.cs
index 1a183713769..4efb8208626 100644
--- a/src/Docfx.Build/Conceptual/WordCounter.cs
+++ b/src/Docfx.Build/Conceptual/WordCounter.cs
@@ -9,6 +9,14 @@ internal static class WordCounter
{
private static readonly string[] ExcludeNodeXPaths = ["//title"];
+#if NET8_0_OR_GREATER
+ private static readonly System.Buffers.SearchValues SpecialChars = System.Buffers.SearchValues.Create(".?!;:,()[]");
+#else
+ private static readonly string SpecialChars = ".?!;:,()[]";
+#endif
+
+ private static readonly char[] DelimiterChars = [' ', '\t', '\n'];
+
public static long CountWord(string html)
{
ArgumentNullException.ThrowIfNull(html);
@@ -50,10 +58,7 @@ private static int CountWordInText(string text)
return 0;
}
- string specialChars = ".?!;:,()[]";
- char[] delimiterChars = [' ', '\t', '\n'];
-
- string[] wordList = text.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
- return wordList.Count(s => !s.Trim().All(specialChars.Contains));
+ string[] wordList = text.Split(DelimiterChars, StringSplitOptions.RemoveEmptyEntries);
+ return wordList.Count(static s => !s.Trim().All(static c => SpecialChars.Contains(c)));
}
}
diff --git a/src/Docfx.Build/DocumentBuildContext.cs b/src/Docfx.Build/DocumentBuildContext.cs
index 7bbb5501752..b3da3dfb121 100644
--- a/src/Docfx.Build/DocumentBuildContext.cs
+++ b/src/Docfx.Build/DocumentBuildContext.cs
@@ -115,13 +115,13 @@ from u in xrefMaps
public int MaxParallelism { get; }
- public ConcurrentDictionary FileMap { get; } = new ConcurrentDictionary(FilePathComparer.OSPlatformSensitiveStringComparer);
+ public ConcurrentDictionary FileMap { get; } = new(FilePathComparer.OSPlatformSensitiveStringComparer);
- public ConcurrentDictionary XRefSpecMap { get; } = new ConcurrentDictionary();
+ public ConcurrentDictionary XRefSpecMap { get; } = new();
- public ConcurrentDictionary> TocMap { get; } = new ConcurrentDictionary>(FilePathComparer.OSPlatformSensitiveStringComparer);
+ public ConcurrentDictionary> TocMap { get; } = new(FilePathComparer.OSPlatformSensitiveStringComparer);
- public HashSet XRef { get; } = new HashSet();
+ public HashSet XRef { get; } = new();
public string RootTocPath { get; }
@@ -129,11 +129,11 @@ from u in xrefMaps
public ICustomHrefGenerator HrefGenerator { get; }
- internal ConcurrentBag ManifestItems { get; } = new ConcurrentBag();
+ internal ConcurrentBag ManifestItems { get; } = new();
- private ConcurrentDictionary ExternalXRefSpec { get; } = new ConcurrentDictionary();
+ private ConcurrentDictionary ExternalXRefSpec { get; } = new();
- private ConcurrentDictionary UnknownUids { get; } = new ConcurrentDictionary();
+ private ConcurrentDictionary UnknownUids { get; } = new();
public void ReportExternalXRefSpec(XRefSpec spec)
{
@@ -148,24 +148,6 @@ public void ReportExternalXRefSpec(XRefSpec spec)
(uid, old) => old + spec);
}
- internal void SaveExternalXRefSpec(TextWriter writer)
- {
- JsonUtility.Serialize(writer, ExternalXRefSpec);
- }
-
- internal void LoadExternalXRefSpec(TextReader reader)
- {
- if (!ExternalXRefSpec.IsEmpty)
- {
- throw new InvalidOperationException("Cannot load after reporting external xref spec.");
- }
- var dict = JsonUtility.Deserialize>(reader);
- foreach (var pair in dict)
- {
- ExternalXRefSpec[pair.Key] = pair.Value;
- }
- }
-
public void ResolveExternalXRefSpec()
{
Task.WaitAll(
@@ -275,12 +257,7 @@ public string GetFilePath(string key)
{
throw new ArgumentException("Key cannot be empty.", nameof(key));
}
- if (FileMap.TryGetValue(key, out string filePath))
- {
- return filePath;
- }
-
- return null;
+ return FileMap.GetValueOrDefault(key);
}
// TODO: use this method instead of directly accessing FileMap
diff --git a/src/Docfx.Build/DocumentBuilder.cs b/src/Docfx.Build/DocumentBuilder.cs
index 85af3e459e1..ede13a86dd3 100644
--- a/src/Docfx.Build/DocumentBuilder.cs
+++ b/src/Docfx.Build/DocumentBuilder.cs
@@ -92,11 +92,11 @@ public void Build(IList parameters, string outputDirect
if (parameter.Files.Count == 0)
{
- manifests.Add(new Manifest() { SourceBasePath = StringExtension.ToNormalizedPath(EnvironmentContext.BaseDirectory) });
+ manifests.Add(new Manifest { SourceBasePath = StringExtension.ToNormalizedPath(EnvironmentContext.BaseDirectory) });
}
else
{
- if (!parameter.Files.EnumerateFiles().Any(s => s.Type == DocumentType.Article))
+ if (!parameter.Files.EnumerateFiles().Any(static s => s.Type == DocumentType.Article))
{
if (!string.IsNullOrEmpty(parameter.GroupInfo?.Name))
{
@@ -131,7 +131,7 @@ public void Build(IList parameters, string outputDirect
else if (emptyContentGroups.Count > 0)
{
Logger.LogSuggestion(
- $"No content file found in group: {string.Join(",", emptyContentGroups)}. Please make sure the content section of docfx.json is correctly configured.",
+ $"No content file found in group: {string.Join(',', emptyContentGroups)}. Please make sure the content section of docfx.json is correctly configured.",
code: SuggestionCodes.Build.EmptyInputContents);
}
diff --git a/src/Docfx.Build/MarkupResultUtility.cs b/src/Docfx.Build/MarkupResultUtility.cs
index c56041dd205..53a642c18cb 100644
--- a/src/Docfx.Build/MarkupResultUtility.cs
+++ b/src/Docfx.Build/MarkupResultUtility.cs
@@ -104,7 +104,7 @@ where string.Equals(attr.Name, "src", StringComparison.OrdinalIgnoreCase) ||
anchorInHref = null;
}
- link.Value = file.UrlEncode().ToString() + anchorInHref;
+ link.Value = file.UrlEncode() + anchorInHref;
}
if (!fileLinkSources.TryGetValue(file, out List sources))
diff --git a/src/Docfx.Build/PostProcessors/HtmlPostProcessor.cs b/src/Docfx.Build/PostProcessors/HtmlPostProcessor.cs
index 0532739afde..a51bd936707 100644
--- a/src/Docfx.Build/PostProcessors/HtmlPostProcessor.cs
+++ b/src/Docfx.Build/PostProcessors/HtmlPostProcessor.cs
@@ -13,7 +13,7 @@ namespace Docfx.Build.Engine;
sealed class HtmlPostProcessor : IPostProcessor
{
- public List Handlers { get; } = new List();
+ public List Handlers { get; } = new();
private bool _handlerInitialized;
diff --git a/src/Docfx.Build/Settings/ApplyTemplateSettings.cs b/src/Docfx.Build/Settings/ApplyTemplateSettings.cs
index e0f40197f33..10928b715d6 100644
--- a/src/Docfx.Build/Settings/ApplyTemplateSettings.cs
+++ b/src/Docfx.Build/Settings/ApplyTemplateSettings.cs
@@ -18,10 +18,10 @@ public class ApplyTemplateSettings
public string OutputFolder { get; }
public bool DebugMode { get; }
public bool TransformDocument { get; set; } = true;
- public ExportSettings RawModelExportSettingsForDebug { get; set; } = new ExportSettings(DefaultRawModelExportSettings);
- public ExportSettings ViewModelExportSettingsForDebug { get; set; } = new ExportSettings(DefaultRawModelExportSettings);
- public ExportSettings RawModelExportSettings { get; set; } = new ExportSettings(DefaultRawModelExportSettings);
- public ExportSettings ViewModelExportSettings { get; set; } = new ExportSettings(DefaultViewModelExportSettings);
+ public ExportSettings RawModelExportSettingsForDebug { get; set; } = new(DefaultRawModelExportSettings);
+ public ExportSettings ViewModelExportSettingsForDebug { get; set; } = new(DefaultRawModelExportSettings);
+ public ExportSettings RawModelExportSettings { get; set; } = new(DefaultRawModelExportSettings);
+ public ExportSettings ViewModelExportSettings { get; set; } = new(DefaultViewModelExportSettings);
public ICustomHrefGenerator HrefGenerator { get; set; }
public ApplyTemplateSettings(string inputFolder, string outputFolder) : this(inputFolder, outputFolder, null, false)
diff --git a/src/Docfx.Build/TableOfContents/BuildTocDocument.cs b/src/Docfx.Build/TableOfContents/BuildTocDocument.cs
index 66efb8bb5aa..d2c7b63318f 100644
--- a/src/Docfx.Build/TableOfContents/BuildTocDocument.cs
+++ b/src/Docfx.Build/TableOfContents/BuildTocDocument.cs
@@ -31,11 +31,11 @@ public override void Build(FileModel model, IHostService host)
{
var toc = (TocItemViewModel)model.Content;
TocRestructureUtility.Restructure(toc, host.TableOfContentRestructions);
- BuildCore(toc, model, host);
+ BuildCore(toc, model);
// todo : metadata.
}
- private static void BuildCore(TocItemViewModel item, FileModel model, IHostService hostService, string includedFrom = null)
+ private static void BuildCore(TocItemViewModel item, FileModel model, string includedFrom = null)
{
if (item == null)
{
@@ -70,7 +70,7 @@ private static void BuildCore(TocItemViewModel item, FileModel model, IHostServi
{
foreach (var i in item.Items)
{
- BuildCore(i, model, hostService, includedFrom);
+ BuildCore(i, model, includedFrom);
}
}
@@ -83,12 +83,6 @@ void UpdateDependencies(HashSet linkTos, Dictionary> dict, string path, LinkSourceInfo source)
=> dict[path] = dict.TryGetValue(path, out var sources) ? sources.Add(source) : ImmutableList.Create(source);
diff --git a/src/Docfx.Build/TableOfContents/MarkdownTocReader.cs b/src/Docfx.Build/TableOfContents/MarkdownTocReader.cs
index 20f57c0da71..b44e42053dc 100644
--- a/src/Docfx.Build/TableOfContents/MarkdownTocReader.cs
+++ b/src/Docfx.Build/TableOfContents/MarkdownTocReader.cs
@@ -9,10 +9,10 @@ public static class MarkdownTocReader
{
private const string ContinuableCharacters = ".,;:!?~";
private const string StopCharacters = @"\s\""\'<>";
- private const string XrefAutoLinkRegexString = @"(]+)>)";
+ private const string XrefAutoLinkRegexString = "(]+)>)";
private const string XrefAutoLinkRegexWithQuoteString = @"";
private const string XrefShortcutRegexWithQuoteString = @"@(?:(['""])(?\s*?\S+?[\s\S]*?)\1)";
- private const string XrefShortcutRegexString = $@"@(?[a-zA-Z](?:[{ContinuableCharacters}]?[^{StopCharacters}{ContinuableCharacters}])*)";
+ private const string XrefShortcutRegexString = $"@(?[a-zA-Z](?:[{ContinuableCharacters}]?[^{StopCharacters}{ContinuableCharacters}])*)";
public static List LoadToc(string tocContent, string filePath)
{
diff --git a/src/Docfx.Build/TableOfContents/TocResolver.cs b/src/Docfx.Build/TableOfContents/TocResolver.cs
index d8b11f962e7..74461c237db 100644
--- a/src/Docfx.Build/TableOfContents/TocResolver.cs
+++ b/src/Docfx.Build/TableOfContents/TocResolver.cs
@@ -23,15 +23,15 @@ public TocItemInfo Resolve(string file)
return ResolveItem(_collection[file], new Stack());
}
- private TocItemInfo ResolveItem(TocItemInfo wrapper, Stack stack, bool isRoot = true)
+ private TocItemInfo ResolveItem(TocItemInfo wrapper, Stack stack)
{
using (new LoggerFileScope(wrapper.File.File))
{
- return ResolveItemCore(wrapper, stack, isRoot);
+ return ResolveItemCore(wrapper, stack);
}
}
- private TocItemInfo ResolveItemCore(TocItemInfo wrapper, Stack stack, bool isRoot)
+ private TocItemInfo ResolveItemCore(TocItemInfo wrapper, Stack stack)
{
if (wrapper.IsResolved)
{
@@ -125,7 +125,7 @@ private TocItemInfo ResolveItemCore(TocItemInfo wrapper, Stack stac
if (item.Items != null && item.Items.Count > 0)
{
item.Items = new List(from i in item.Items
- select ResolveItem(new TocItemInfo(file, i), stack, false) into r
+ select ResolveItem(new TocItemInfo(file, i), stack) into r
where r != null
select r.Content);
if (string.IsNullOrEmpty(item.TopicHref) && string.IsNullOrEmpty(item.TopicUid))
@@ -207,7 +207,7 @@ select ResolveItem(new TocItemInfo(file, i), stack, false) into r
{
for (int i = 0; i < item.Items.Count; i++)
{
- item.Items[i] = ResolveItem(new TocItemInfo(file, item.Items[i]), stack, false).Content;
+ item.Items[i] = ResolveItem(new TocItemInfo(file, item.Items[i]), stack).Content;
}
}
}
diff --git a/src/Docfx.Build/TemplateProcessors/Preprocessors/PreprocessorLoader.cs b/src/Docfx.Build/TemplateProcessors/Preprocessors/PreprocessorLoader.cs
index e281cf817bc..9e57166cdfd 100644
--- a/src/Docfx.Build/TemplateProcessors/Preprocessors/PreprocessorLoader.cs
+++ b/src/Docfx.Build/TemplateProcessors/Preprocessors/PreprocessorLoader.cs
@@ -23,7 +23,7 @@ public PreprocessorLoader(ResourceFileReader reader, DocumentBuildContext contex
public IEnumerable LoadStandalones()
{
// Only files under root folder are allowed
- foreach (var res in _reader.GetResources($@"^[^/]*{Regex.Escape(TemplateJintPreprocessor.StandaloneExtension)}$"))
+ foreach (var res in _reader.GetResources($"^[^/]*{Regex.Escape(TemplateJintPreprocessor.StandaloneExtension)}$"))
{
var name = Path.GetFileNameWithoutExtension(res.Path.Remove(res.Path.LastIndexOf('.')));
var preprocessor = Load(res, name);
diff --git a/src/Docfx.Build/TemplateProcessors/Preprocessors/TemplateUtility.cs b/src/Docfx.Build/TemplateProcessors/Preprocessors/TemplateUtility.cs
index 74b05684ca2..c38d6b25eb9 100644
--- a/src/Docfx.Build/TemplateProcessors/Preprocessors/TemplateUtility.cs
+++ b/src/Docfx.Build/TemplateProcessors/Preprocessors/TemplateUtility.cs
@@ -54,7 +54,7 @@ public string GetHrefFromRoot(string originalHref, string sourceFileKey)
Logger.LogWarning($"Invalid file link: ({originalHref})", file: sourceFileKey, code: WarningCodes.Build.InvalidFileLink);
return originalHref;
}
- return file.UrlEncode().ToString() + UriUtility.GetQueryStringAndFragment(originalHref);
+ return file.UrlEncode() + UriUtility.GetQueryStringAndFragment(originalHref);
}
public string Markup(string markdown, string sourceFileKey)
diff --git a/src/Docfx.Build/TemplateProcessors/Template.cs b/src/Docfx.Build/TemplateProcessors/Template.cs
index cdd60b76cd4..eeb48b51fd3 100644
--- a/src/Docfx.Build/TemplateProcessors/Template.cs
+++ b/src/Docfx.Build/TemplateProcessors/Template.cs
@@ -11,8 +11,6 @@ public class Template
private const string Primary = ".primary";
private const string Auxiliary = ".aux";
- private readonly object _locker = new();
-
public string Name { get; }
public string ScriptName { get; }
public string Extension { get; }
@@ -62,7 +60,7 @@ public Template(ITemplateRenderer renderer, ITemplatePreprocessor preprocessor)
/// },
/// isShared: true
/// }
- ///
+ ///
/// }
///
///