From a30ee2de23ccd50146bfaf446371d9acd7c6823a Mon Sep 17 00:00:00 2001
From: filzrev <103790468+filzrev@users.noreply.github.com>
Date: Tue, 28 May 2024 12:58:07 +0900
Subject: [PATCH] chore: Add PolySharp libarary to use latest C# syntax
---
Directory.Build.props | 7 +++++++
Directory.Packages.props | 1 +
src/Docfx.Build/ApiPage/ApiPage.cs | 4 ----
src/Docfx.Build/ApiPage/ApiPageHtmlTemplate.cs | 4 ----
src/Docfx.Build/ApiPage/ApiPageMarkdownTemplate.cs | 4 ----
src/Docfx.Build/ApiPage/ApiPageProcessor.cs | 4 ----
src/Docfx.Build/DocumentBuilder.cs | 2 --
src/Docfx.Dotnet/DotnetApiCatalog.ApiPage.cs | 4 ----
src/Docfx.Dotnet/DotnetApiCatalog.cs | 8 --------
9 files changed, 8 insertions(+), 30 deletions(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 15697596fe2..e0900528b67 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -45,6 +45,13 @@
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+
all
diff --git a/Directory.Packages.props b/Directory.Packages.props
index eb45e5d77c1..50b4b31d6e0 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -17,6 +17,7 @@
+
diff --git a/src/Docfx.Build/ApiPage/ApiPage.cs b/src/Docfx.Build/ApiPage/ApiPage.cs
index 36b93f946f8..f6dcf16a216 100644
--- a/src/Docfx.Build/ApiPage/ApiPage.cs
+++ b/src/Docfx.Build/ApiPage/ApiPage.cs
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#if NET7_0_OR_GREATER
-
using System.Text.Json;
using System.Text.Json.Serialization;
using OneOf;
@@ -160,5 +158,3 @@ static ApiPage()
public string? languageId { get; init; }
public Dictionary>? metadata { get; init; }
}
-
-#endif
diff --git a/src/Docfx.Build/ApiPage/ApiPageHtmlTemplate.cs b/src/Docfx.Build/ApiPage/ApiPageHtmlTemplate.cs
index 72fedf6b98d..6a46867a5de 100644
--- a/src/Docfx.Build/ApiPage/ApiPageHtmlTemplate.cs
+++ b/src/Docfx.Build/ApiPage/ApiPageHtmlTemplate.cs
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#if NET7_0_OR_GREATER
-
using System.Net;
using OneOf;
using static Docfx.Build.HtmlTemplate;
@@ -158,5 +156,3 @@ LinkSpan link when string.IsNullOrEmpty(link.url) => Html($"{link.text}"),
};
}
}
-
-#endif
diff --git a/src/Docfx.Build/ApiPage/ApiPageMarkdownTemplate.cs b/src/Docfx.Build/ApiPage/ApiPageMarkdownTemplate.cs
index 3420dd246c2..ba38cd3e36c 100644
--- a/src/Docfx.Build/ApiPage/ApiPageMarkdownTemplate.cs
+++ b/src/Docfx.Build/ApiPage/ApiPageMarkdownTemplate.cs
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#if NET7_0_OR_GREATER
-
using System.Text;
#nullable enable
@@ -124,5 +122,3 @@ internal static string Escape(string text)
return sb.ToString();
}
}
-
-#endif
diff --git a/src/Docfx.Build/ApiPage/ApiPageProcessor.cs b/src/Docfx.Build/ApiPage/ApiPageProcessor.cs
index 55251944d1c..f74ec18b902 100644
--- a/src/Docfx.Build/ApiPage/ApiPageProcessor.cs
+++ b/src/Docfx.Build/ApiPage/ApiPageProcessor.cs
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#if NET7_0_OR_GREATER
-
using System.Collections.Immutable;
using System.Text.Json;
using Docfx.Common;
@@ -74,5 +72,3 @@ public SaveResult Save(FileModel model)
};
}
}
-
-#endif
diff --git a/src/Docfx.Build/DocumentBuilder.cs b/src/Docfx.Build/DocumentBuilder.cs
index 9ca9f1debcb..85af3e459e1 100644
--- a/src/Docfx.Build/DocumentBuilder.cs
+++ b/src/Docfx.Build/DocumentBuilder.cs
@@ -50,9 +50,7 @@ public void Build(IList parameters, string outputDirect
var markdownService = CreateMarkdigMarkdownService(parameters[0]);
-#if NET7_0_OR_GREATER
Processors = Processors.Append(new ApiPage.ApiPageDocumentProcessor(markdownService));
-#endif
Logger.LogInfo($"{Processors.Count()} plug-in(s) loaded.");
foreach (var processor in Processors)
diff --git a/src/Docfx.Dotnet/DotnetApiCatalog.ApiPage.cs b/src/Docfx.Dotnet/DotnetApiCatalog.ApiPage.cs
index 16b147668ff..8dd02350c9a 100644
--- a/src/Docfx.Dotnet/DotnetApiCatalog.ApiPage.cs
+++ b/src/Docfx.Dotnet/DotnetApiCatalog.ApiPage.cs
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#if NET7_0_OR_GREATER
-
using System.Collections.Concurrent;
using System.Text.RegularExpressions;
using Docfx.Build.ApiPage;
@@ -774,5 +772,3 @@ static string HtmlInnerText(string html)
return doc.DocumentNode.InnerText;
}
}
-
-#endif
diff --git a/src/Docfx.Dotnet/DotnetApiCatalog.cs b/src/Docfx.Dotnet/DotnetApiCatalog.cs
index 5b5eaa0e393..65390a022b4 100644
--- a/src/Docfx.Dotnet/DotnetApiCatalog.cs
+++ b/src/Docfx.Dotnet/DotnetApiCatalog.cs
@@ -89,20 +89,15 @@ async Task Build(ExtractMetadataConfig config, DotnetApiOptions options)
switch (config.OutputFormat)
{
case MetadataOutputFormat.Markdown:
-#if NET7_0_OR_GREATER
CreatePages(WriteMarkdown, assemblies, config, options);
void WriteMarkdown(string outputFolder, string id, Build.ApiPage.ApiPage apiPage)
{
File.WriteAllText(Path.Combine(outputFolder, $"{id}.md"), Docfx.Build.ApiPage.ApiPageMarkdownTemplate.Render(apiPage));
}
-#else
- Logger.LogError($"Markdown output format is only supported for docfx built against .NET 7 or greater.");
-#endif
break;
case MetadataOutputFormat.ApiPage:
-#if NET7_0_OR_GREATER
var serializer = new DeserializerBuilder().WithAttemptingUnquotedStringTypeDeserialization().Build();
CreatePages(WriteYaml, assemblies, config, options);
@@ -112,9 +107,6 @@ void WriteYaml(string outputFolder, string id, Build.ApiPage.ApiPage apiPage)
var obj = serializer.Deserialize(json);
YamlUtility.Serialize(Path.Combine(outputFolder, $"{id}.yml"), obj, "YamlMime:ApiPage");
}
-#else
- Logger.LogError($"ApiPage output format is only supported for docfx built against .NET 7 or greater.");
-#endif
break;
case MetadataOutputFormat.Mref: