Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add PolySharp libarary to use latest C# syntax #9960

Merged
merged 1 commit into from
May 28, 2024
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
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
<None Include="$(MSBuildThisFileDirectory)\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="PolySharp">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub">
<PrivateAssets>all</PrivateAssets>
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<PackageVersion Include="OneOf.SourceGenerator" Version="3.0.271" />
<PackageVersion Include="PdfPig" Version="0.1.9-alpha-20240510-d86c2" />
<PackageVersion Include="PlantUml.Net" Version="1.4.80" />
<PackageVersion Include="PolySharp" Version="1.14.1" />
<PackageVersion Include="Spectre.Console" Version="0.49.1" />
<PackageVersion Include="Spectre.Console.Cli" Version="0.49.1" />
<PackageVersion Include="Stubble.Core" Version="1.10.8" />
Expand Down
4 changes: 0 additions & 4 deletions src/Docfx.Build/ApiPage/ApiPage.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -160,5 +158,3 @@ static ApiPage()
public string? languageId { get; init; }
public Dictionary<string, OneOf<string, string[]>>? metadata { get; init; }
}

#endif
4 changes: 0 additions & 4 deletions src/Docfx.Build/ApiPage/ApiPageHtmlTemplate.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -158,5 +156,3 @@ LinkSpan link when string.IsNullOrEmpty(link.url) => Html($"{link.text}"),
};
}
}

#endif
4 changes: 0 additions & 4 deletions src/Docfx.Build/ApiPage/ApiPageMarkdownTemplate.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -124,5 +122,3 @@ internal static string Escape(string text)
return sb.ToString();
}
}

#endif
4 changes: 0 additions & 4 deletions src/Docfx.Build/ApiPage/ApiPageProcessor.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -74,5 +72,3 @@ public SaveResult Save(FileModel model)
};
}
}

#endif
2 changes: 0 additions & 2 deletions src/Docfx.Build/DocumentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ public void Build(IList<DocumentBuildParameters> 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)
Expand Down
4 changes: 0 additions & 4 deletions src/Docfx.Dotnet/DotnetApiCatalog.ApiPage.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -774,5 +772,3 @@ static string HtmlInnerText(string html)
return doc.DocumentNode.InnerText;
}
}

#endif
8 changes: 0 additions & 8 deletions src/Docfx.Dotnet/DotnetApiCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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:
Expand Down