diff --git a/Directory.Packages.props b/Directory.Packages.props index 1ce02d348a8..948865a23df 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -33,7 +33,6 @@ - diff --git a/src/Docfx.Build/CompositionContainer.cs b/src/Docfx.Build/CompositionContainer.cs index e3b8618c62a..977f3956a85 100644 --- a/src/Docfx.Build/CompositionContainer.cs +++ b/src/Docfx.Build/CompositionContainer.cs @@ -10,7 +10,7 @@ namespace Docfx.Common; [Export(typeof(ICompositionContainer))] -public class CompositionContainer : ICompositionContainer +class CompositionContainer : ICompositionContainer { public static CompositionHost DefaultContainer { get; private set; } diff --git a/src/Docfx.Build/Conceptual/BuildConceptualDocument.cs b/src/Docfx.Build/Conceptual/BuildConceptualDocument.cs index 1cc73e0dcf9..072c5ae6ece 100644 --- a/src/Docfx.Build/Conceptual/BuildConceptualDocument.cs +++ b/src/Docfx.Build/Conceptual/BuildConceptualDocument.cs @@ -12,7 +12,7 @@ namespace Docfx.Build.ConceptualDocuments; [Export(nameof(ConceptualDocumentProcessor), typeof(IDocumentBuildStep))] -public class BuildConceptualDocument : BaseDocumentBuildStep +class BuildConceptualDocument : BaseDocumentBuildStep { private const string ConceptualKey = Constants.PropertyName.Conceptual; private const string DocumentTypeKey = "documentType"; diff --git a/src/Docfx.Build/Conceptual/ConceptualDocumentProcessor.cs b/src/Docfx.Build/Conceptual/ConceptualDocumentProcessor.cs index 1a724247957..05a5725b661 100644 --- a/src/Docfx.Build/Conceptual/ConceptualDocumentProcessor.cs +++ b/src/Docfx.Build/Conceptual/ConceptualDocumentProcessor.cs @@ -12,7 +12,7 @@ namespace Docfx.Build.ConceptualDocuments; [Export(typeof(IDocumentProcessor))] -public class ConceptualDocumentProcessor : DisposableDocumentProcessor +class ConceptualDocumentProcessor : DisposableDocumentProcessor { #region Fields diff --git a/src/Docfx.Build/Conceptual/CountWord.cs b/src/Docfx.Build/Conceptual/CountWord.cs index 9eb1d7ad359..2bc5acb2aa6 100644 --- a/src/Docfx.Build/Conceptual/CountWord.cs +++ b/src/Docfx.Build/Conceptual/CountWord.cs @@ -11,7 +11,7 @@ namespace Docfx.Build.ConceptualDocuments; [Export(nameof(ConceptualDocumentProcessor), typeof(IDocumentBuildStep))] -public class CountWord : BaseDocumentBuildStep +class CountWord : BaseDocumentBuildStep { public override string Name => nameof(CountWord); diff --git a/src/Docfx.Build/Conceptual/HtmlDocumentUtility.cs b/src/Docfx.Build/Conceptual/HtmlDocumentUtility.cs index a0fef91591e..4428c836ad6 100644 --- a/src/Docfx.Build/Conceptual/HtmlDocumentUtility.cs +++ b/src/Docfx.Build/Conceptual/HtmlDocumentUtility.cs @@ -6,7 +6,7 @@ namespace Docfx.Build.ConceptualDocuments; -public static class HtmlDocumentUtility +static class HtmlDocumentUtility { public static SeparatedHtmlInfo SeparateHtml(string contentHtml) { diff --git a/src/Docfx.Build/Conceptual/SeparatedHtmlInfo.cs b/src/Docfx.Build/Conceptual/SeparatedHtmlInfo.cs index 539eec10920..fc90dbf3ae9 100644 --- a/src/Docfx.Build/Conceptual/SeparatedHtmlInfo.cs +++ b/src/Docfx.Build/Conceptual/SeparatedHtmlInfo.cs @@ -3,7 +3,7 @@ namespace Docfx.Build.ConceptualDocuments; -public class SeparatedHtmlInfo +class SeparatedHtmlInfo { public string Title { get; set; } diff --git a/src/Docfx.Build/Conceptual/ValidateConceptualDocumentMetadata.cs b/src/Docfx.Build/Conceptual/ValidateConceptualDocumentMetadata.cs index 4da7c30e96c..dc8b8accc42 100644 --- a/src/Docfx.Build/Conceptual/ValidateConceptualDocumentMetadata.cs +++ b/src/Docfx.Build/Conceptual/ValidateConceptualDocumentMetadata.cs @@ -11,7 +11,7 @@ namespace Docfx.Build.ConceptualDocuments; [Export(nameof(ConceptualDocumentProcessor), typeof(IDocumentBuildStep))] -public class ValidateConceptualDocumentMetadata : BaseDocumentBuildStep +class ValidateConceptualDocumentMetadata : BaseDocumentBuildStep { private const string ConceptualKey = Constants.PropertyName.Conceptual; diff --git a/src/Docfx.Build/FileMetadataConverter.cs b/src/Docfx.Build/FileMetadataConverter.cs deleted file mode 100644 index cf73656b6f7..00000000000 --- a/src/Docfx.Build/FileMetadataConverter.cs +++ /dev/null @@ -1,114 +0,0 @@ -// 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.Build.Engine; -using Docfx.Common; -using Docfx.Glob; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Docfx; - -public class FileMetadataConverter : JsonConverter -{ - private const string BaseDir = "baseDir"; - private const string Dict = "dict"; - private const string Glob = "glob"; - private const string Key = "key"; - private const string Value = "value"; - - private readonly bool _ignoreBaseDir; - - public FileMetadataConverter() : base() { } - - public FileMetadataConverter(bool ignoreBaseDir) - { - _ignoreBaseDir = ignoreBaseDir; - } - - public override bool CanConvert(Type objectType) - { - return objectType == typeof(FileMetadata); - } - - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - JToken token; - if (reader.TokenType == JsonToken.StartObject) - { - token = JToken.Load(reader); - } - else - { - throw new JsonReaderException($"{reader.TokenType} is not a valid {objectType.Name}."); - } - var baseDir = (string)((JObject)token).GetValue(BaseDir); - if (token[Dict] is not JObject dict) - { - throw new JsonReaderException($"Expect {token[Dict]} to be JObject."); - } - var metaDict = new Dictionary>(); - foreach (var pair in dict) - { - metaDict.Add(pair.Key, GetFileMetadataItemArray(pair.Value)); - } - - return new FileMetadata(baseDir, metaDict); - } - - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - var fileMetadata = (FileMetadata)value; - writer.WriteStartObject(); - - if (!_ignoreBaseDir && fileMetadata.BaseDir != null) - { - writer.WritePropertyName(BaseDir); - writer.WriteRawValue(JsonUtility.Serialize(fileMetadata.BaseDir)); - } - - writer.WritePropertyName(Dict); - writer.WriteStartObject(); - foreach (var pair in fileMetadata) - { - writer.WritePropertyName(pair.Key); - writer.WriteStartArray(); - foreach (var item in pair.Value) - { - writer.WriteStartObject(); - writer.WritePropertyName(Glob); - writer.WriteRawValue(JsonUtility.Serialize(item.Glob.Raw)); - writer.WritePropertyName(Key); - writer.WriteRawValue(JsonUtility.Serialize(item.Key)); - writer.WritePropertyName(Value); - writer.WriteRawValue(JsonUtility.Serialize(item.Value)); - writer.WriteEndObject(); - } - writer.WriteEndArray(); - } - writer.WriteEndObject(); - - writer.WriteEndObject(); - } - - private static ImmutableArray GetFileMetadataItemArray(JToken value) - { - if (value is not JArray arr) - { - throw new JsonReaderException($"Expect {value} to be JArray."); - } - return arr.Select(e => - { - if (e is not JObject obj) - { - throw new JsonReaderException($"Expect {e} to be JObject."); - } - return new FileMetadataItem( - new GlobMatcher((string)obj[Glob]), - (string)obj[Key], - ConvertToObjectHelper.ConvertJObjectToObject(obj[Value])); - }).ToImmutableArray(); - } -} diff --git a/src/Docfx.Build/ManifestUtility.cs b/src/Docfx.Build/ManifestUtility.cs index 4cd564669e7..7fd8e7801b2 100644 --- a/src/Docfx.Build/ManifestUtility.cs +++ b/src/Docfx.Build/ManifestUtility.cs @@ -10,7 +10,7 @@ namespace Docfx.Common; #pragma warning disable CS0612 // Type or member is obsolete -public static class ManifestUtility +static class ManifestUtility { public static void RemoveDuplicateOutputFiles(ManifestItemCollection manifestItems) { diff --git a/src/Docfx.Build/PostProcessors/ExtractSearchIndex.cs b/src/Docfx.Build/PostProcessors/ExtractSearchIndex.cs index 4074bd64e31..eb96e045435 100644 --- a/src/Docfx.Build/PostProcessors/ExtractSearchIndex.cs +++ b/src/Docfx.Build/PostProcessors/ExtractSearchIndex.cs @@ -14,7 +14,7 @@ namespace Docfx.Build.Engine; [Export(nameof(ExtractSearchIndex), typeof(IPostProcessor))] -public class ExtractSearchIndex : IPostProcessor +class ExtractSearchIndex : IPostProcessor { private static readonly Regex s_regexWhiteSpace = new(@"\s+", RegexOptions.Compiled); private static readonly HashSet s_htmlInlineTags = new(StringComparer.OrdinalIgnoreCase) diff --git a/src/Docfx.Build/PostProcessors/HtmlPostProcessor.cs b/src/Docfx.Build/PostProcessors/HtmlPostProcessor.cs index 0cc295a9124..0532739afde 100644 --- a/src/Docfx.Build/PostProcessors/HtmlPostProcessor.cs +++ b/src/Docfx.Build/PostProcessors/HtmlPostProcessor.cs @@ -11,7 +11,7 @@ namespace Docfx.Build.Engine; -internal sealed class HtmlPostProcessor : IPostProcessor +sealed class HtmlPostProcessor : IPostProcessor { public List Handlers { get; } = new List(); diff --git a/src/Docfx.Build/PostProcessors/PostProcessor.cs b/src/Docfx.Build/PostProcessors/PostProcessor.cs index eb71b7602c0..d862b85502a 100644 --- a/src/Docfx.Build/PostProcessors/PostProcessor.cs +++ b/src/Docfx.Build/PostProcessors/PostProcessor.cs @@ -5,7 +5,7 @@ namespace Docfx.Build.Engine; -internal sealed class PostProcessor +sealed class PostProcessor { public string ContractName { get; set; } diff --git a/src/Docfx.Build/PostProcessors/PostProcessorsManager.cs b/src/Docfx.Build/PostProcessors/PostProcessorsManager.cs index 14e8e85d284..273fae6c93f 100644 --- a/src/Docfx.Build/PostProcessors/PostProcessorsManager.cs +++ b/src/Docfx.Build/PostProcessors/PostProcessorsManager.cs @@ -10,7 +10,7 @@ namespace Docfx.Build.Engine; -internal class PostProcessorsManager : IDisposable +class PostProcessorsManager : IDisposable { private readonly List _postProcessors; diff --git a/src/Docfx.Build/PostProcessors/RemoveDebugInfo.cs b/src/Docfx.Build/PostProcessors/RemoveDebugInfo.cs index aacdd9ef0bf..d189c59dd94 100644 --- a/src/Docfx.Build/PostProcessors/RemoveDebugInfo.cs +++ b/src/Docfx.Build/PostProcessors/RemoveDebugInfo.cs @@ -6,7 +6,7 @@ namespace Docfx.Build.Engine; -public sealed class RemoveDebugInfo : HtmlDocumentHandler +class RemoveDebugInfo : HtmlDocumentHandler { private readonly string[] DebugInfoAttributes = { diff --git a/src/Docfx.Build/PostProcessors/SearchIndexItem.cs b/src/Docfx.Build/PostProcessors/SearchIndexItem.cs index cc0587ecb0b..f3f8ff7574d 100644 --- a/src/Docfx.Build/PostProcessors/SearchIndexItem.cs +++ b/src/Docfx.Build/PostProcessors/SearchIndexItem.cs @@ -6,7 +6,7 @@ namespace Docfx.Build.Engine; -public class SearchIndexItem +class SearchIndexItem { [JsonProperty("href")] [JsonPropertyName("href")] diff --git a/src/Docfx.Build/PostProcessors/SitemapGenerator.cs b/src/Docfx.Build/PostProcessors/SitemapGenerator.cs index 1e6cb439f62..b4b2d0d0f22 100644 --- a/src/Docfx.Build/PostProcessors/SitemapGenerator.cs +++ b/src/Docfx.Build/PostProcessors/SitemapGenerator.cs @@ -13,7 +13,7 @@ namespace Docfx.Build.Engine; [Export(nameof(SitemapGenerator), typeof(IPostProcessor))] -public class SitemapGenerator : IPostProcessor +class SitemapGenerator : IPostProcessor { private static readonly XNamespace Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9"; // lgtm [cs/non-https-url] private const string HtmlExtension = ".html"; diff --git a/src/Docfx.Build/PostProcessors/ValidateBookmark.cs b/src/Docfx.Build/PostProcessors/ValidateBookmark.cs index 81b64fb9bfb..4415bdf37dc 100644 --- a/src/Docfx.Build/PostProcessors/ValidateBookmark.cs +++ b/src/Docfx.Build/PostProcessors/ValidateBookmark.cs @@ -9,7 +9,7 @@ namespace Docfx.Build.Engine; -public sealed class ValidateBookmark : HtmlDocumentHandler +sealed class ValidateBookmark : HtmlDocumentHandler { private static readonly string XPathTemplate = "//*/@{0}"; private static readonly HashSet WhiteList = new() { "top" }; diff --git a/src/Docfx.Build/ResourceFiles/ResourceDocumentProcessor.cs b/src/Docfx.Build/ResourceFiles/ResourceDocumentProcessor.cs index a2a40910a78..683d7044e3c 100644 --- a/src/Docfx.Build/ResourceFiles/ResourceDocumentProcessor.cs +++ b/src/Docfx.Build/ResourceFiles/ResourceDocumentProcessor.cs @@ -10,7 +10,7 @@ namespace Docfx.Build.ResourceFiles; [Export(typeof(IDocumentProcessor))] -public class ResourceDocumentProcessor : DisposableDocumentProcessor +class ResourceDocumentProcessor : DisposableDocumentProcessor { [ImportMany] public IEnumerable Configs { get; set; } diff --git a/src/Docfx.Build/ResourceFiles/ValidateResourceMetadata.cs b/src/Docfx.Build/ResourceFiles/ValidateResourceMetadata.cs index a2954d00f0f..d5bf329c14c 100644 --- a/src/Docfx.Build/ResourceFiles/ValidateResourceMetadata.cs +++ b/src/Docfx.Build/ResourceFiles/ValidateResourceMetadata.cs @@ -9,7 +9,7 @@ namespace Docfx.Build.ResourceFiles; [Export(nameof(ResourceDocumentProcessor), typeof(IDocumentBuildStep))] -public class ValidateResourceMetadata : BaseDocumentBuildStep +class ValidateResourceMetadata : BaseDocumentBuildStep { public override string Name => nameof(ValidateResourceMetadata); diff --git a/src/Docfx.Build/TableOfContents/BuildTocDocument.cs b/src/Docfx.Build/TableOfContents/BuildTocDocument.cs index 2377d5af4fd..905b2e12a4b 100644 --- a/src/Docfx.Build/TableOfContents/BuildTocDocument.cs +++ b/src/Docfx.Build/TableOfContents/BuildTocDocument.cs @@ -13,7 +13,7 @@ namespace Docfx.Build.TableOfContents; [Export(nameof(TocDocumentProcessor), typeof(IDocumentBuildStep))] -public class BuildTocDocument : BaseDocumentBuildStep +class BuildTocDocument : BaseDocumentBuildStep { public override string Name => nameof(BuildTocDocument); diff --git a/src/Docfx.Build/TableOfContents/HrefType.cs b/src/Docfx.Build/TableOfContents/HrefType.cs index 5d04cf0d90b..b7681947864 100644 --- a/src/Docfx.Build/TableOfContents/HrefType.cs +++ b/src/Docfx.Build/TableOfContents/HrefType.cs @@ -3,7 +3,7 @@ namespace Docfx.Build.TableOfContents; -internal enum HrefType +enum HrefType { AbsolutePath, RelativeFile, diff --git a/src/Docfx.Build/TableOfContents/TocDocumentProcessor.cs b/src/Docfx.Build/TableOfContents/TocDocumentProcessor.cs index efac86b130f..30594d37b38 100644 --- a/src/Docfx.Build/TableOfContents/TocDocumentProcessor.cs +++ b/src/Docfx.Build/TableOfContents/TocDocumentProcessor.cs @@ -12,7 +12,7 @@ namespace Docfx.Build.TableOfContents; [Export(typeof(IDocumentProcessor))] -public class TocDocumentProcessor : DisposableDocumentProcessor +class TocDocumentProcessor : DisposableDocumentProcessor { private static readonly char[] QueryStringOrAnchor = new[] { '#', '?' }; diff --git a/src/Docfx.Build/TableOfContents/TocFileType.cs b/src/Docfx.Build/TableOfContents/TocFileType.cs index 770833a4901..5ab637572d7 100644 --- a/src/Docfx.Build/TableOfContents/TocFileType.cs +++ b/src/Docfx.Build/TableOfContents/TocFileType.cs @@ -3,7 +3,7 @@ namespace Docfx.Build.TableOfContents; -internal enum TocFileType +enum TocFileType { None, Markdown, diff --git a/src/Docfx.Build/TableOfContents/TocHelper.cs b/src/Docfx.Build/TableOfContents/TocHelper.cs index 95cd389c62f..78ef199dbad 100644 --- a/src/Docfx.Build/TableOfContents/TocHelper.cs +++ b/src/Docfx.Build/TableOfContents/TocHelper.cs @@ -9,7 +9,7 @@ namespace Docfx.Build.TableOfContents; -public static class TocHelper +static class TocHelper { private static readonly YamlDeserializerWithFallback _deserializer = YamlDeserializerWithFallback.Create() diff --git a/src/Docfx.Build/TableOfContents/TocItemInfo.cs b/src/Docfx.Build/TableOfContents/TocItemInfo.cs index c34b55f56a1..75532f5eec5 100644 --- a/src/Docfx.Build/TableOfContents/TocItemInfo.cs +++ b/src/Docfx.Build/TableOfContents/TocItemInfo.cs @@ -6,7 +6,7 @@ namespace Docfx.Build.TableOfContents; -internal sealed class TocItemInfo +class TocItemInfo { public TocItemViewModel Content { get; set; } public FileAndType File { get; } diff --git a/src/Docfx.Build/TableOfContents/TocResolver.cs b/src/Docfx.Build/TableOfContents/TocResolver.cs index 45ad523ef83..ba3f52bd6ba 100644 --- a/src/Docfx.Build/TableOfContents/TocResolver.cs +++ b/src/Docfx.Build/TableOfContents/TocResolver.cs @@ -7,7 +7,7 @@ namespace Docfx.Build.TableOfContents; -internal sealed class TocResolver +class TocResolver { private readonly Dictionary _collection; private readonly Dictionary _notInProjectTocCache = new(); diff --git a/src/Docfx.Build/TableOfContents/TocRestructureUtility.cs b/src/Docfx.Build/TableOfContents/TocRestructureUtility.cs index f032b58faeb..e2bbe5c4bd1 100644 --- a/src/Docfx.Build/TableOfContents/TocRestructureUtility.cs +++ b/src/Docfx.Build/TableOfContents/TocRestructureUtility.cs @@ -7,7 +7,7 @@ namespace Docfx.Build.TableOfContents; -internal static class TocRestructureUtility +static class TocRestructureUtility { public static void Restructure(TocItemViewModel toc, IList restructures) { diff --git a/src/Docfx.Build/TableOfContents/Utility.cs b/src/Docfx.Build/TableOfContents/Utility.cs index 445cbbe7a02..016f59f8169 100644 --- a/src/Docfx.Build/TableOfContents/Utility.cs +++ b/src/Docfx.Build/TableOfContents/Utility.cs @@ -6,7 +6,7 @@ namespace Docfx.Build.TableOfContents; -internal static class Utility +static class Utility { public static bool IsSupportedFile(string file) { diff --git a/src/Docfx.Dotnet/Docfx.Dotnet.csproj b/src/Docfx.Dotnet/Docfx.Dotnet.csproj index 0068b081047..fa9c04bdf77 100644 --- a/src/Docfx.Dotnet/Docfx.Dotnet.csproj +++ b/src/Docfx.Dotnet/Docfx.Dotnet.csproj @@ -33,7 +33,6 @@ - diff --git a/test/Docfx.Build.SchemaDriven.Tests/LimitationReachedTest.cs b/test/Docfx.Build.SchemaDriven.Tests/LimitationReachedTest.cs deleted file mode 100644 index 653cfe0253b..00000000000 --- a/test/Docfx.Build.SchemaDriven.Tests/LimitationReachedTest.cs +++ /dev/null @@ -1,73 +0,0 @@ -// 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.Text.RegularExpressions; - -using Docfx.Build.Engine; -using Docfx.Build.TableOfContents; -using Docfx.Tests.Common; -using Xunit; - -namespace Docfx.Build.SchemaDriven.Tests; - -[Collection("docfx STA")] -public class LimitationReachedTest : TestBase -{ - private static readonly Regex InputMatcher = new(@"```(yml|yaml)\s*(### YamlMime:[\s\S]*?)\s*```", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex SchemaMatcher = new(@"```json\s*(\{\s*""\$schema""[\s\S]*?)\s*```", RegexOptions.Compiled | RegexOptions.IgnoreCase); - - private readonly string _outputFolder; - private readonly string _inputFolder; - private readonly string _templateFolder; - private readonly FileCollection _defaultFiles; - private readonly ApplyTemplateSettings _applyTemplateSettings; - private readonly TemplateManager _templateManager; - - private const string RawModelFileExtension = ".raw.json"; - - public LimitationReachedTest() - { - _outputFolder = GetRandomFolder(); - _inputFolder = GetRandomFolder(); - _templateFolder = GetRandomFolder(); - _defaultFiles = new FileCollection(Directory.GetCurrentDirectory()); - _applyTemplateSettings = new ApplyTemplateSettings(_inputFolder, _outputFolder) - { - RawModelExportSettings = { Export = true }, - TransformDocument = true, - }; - - _templateManager = new TemplateManager(new List { "template" }, null, _templateFolder); - } - - private void BuildDocument(FileCollection files) - { - var parameters = new DocumentBuildParameters - { - Files = files, - OutputBaseDir = _outputFolder, - ApplyTemplateSettings = _applyTemplateSettings, - Metadata = new Dictionary - { - ["meta"] = "Hello world!", - }.ToImmutableDictionary(), - TemplateManager = _templateManager, - }; - - using var builder = new DocumentBuilder(LoadAssemblies(), ImmutableArray.Empty); - builder.Build(parameters); - } - - private static IEnumerable LoadAssemblies() - { - yield return typeof(SchemaDrivenDocumentProcessor).Assembly; - yield return typeof(TocDocumentProcessor).Assembly; - yield return typeof(SchemaDrivenProcessorTest).Assembly; - } - - private static bool LimitationReached(TestListenerScope listener) - { - return listener.Items.SingleOrDefault(s => s.Message.StartsWith("Limitation reached when validating")) != null; - } -} diff --git a/test/Docfx.Build.SchemaDriven.Tests/SchemaMergerTest.cs b/test/Docfx.Build.SchemaDriven.Tests/SchemaMergerTest.cs index c943a838145..dccf1bfba21 100644 --- a/test/Docfx.Build.SchemaDriven.Tests/SchemaMergerTest.cs +++ b/test/Docfx.Build.SchemaDriven.Tests/SchemaMergerTest.cs @@ -386,7 +386,7 @@ private void BuildDocument(FileCollection files) private static IEnumerable LoadAssemblies() { yield return typeof(SchemaDrivenDocumentProcessor).Assembly; - yield return typeof(TocDocumentProcessor).Assembly; + yield return typeof(DocumentBuilder).Assembly; } private string GetRawModelFilePath(string fileName) diff --git a/test/Docfx.Build.Tests/JsonConverterTest.cs b/test/Docfx.Build.Tests/JsonConverterTest.cs deleted file mode 100644 index b632c0c3461..00000000000 --- a/test/Docfx.Build.Tests/JsonConverterTest.cs +++ /dev/null @@ -1,81 +0,0 @@ -// 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.Glob; -using Newtonsoft.Json; -using Xunit; - -namespace Docfx.Build.Engine.Tests; - -public class JsonConverterTest -{ - [Fact] - public void TestFileMetadataConverterCouldSerializeAndDeserialize() - { - var settings = new JsonSerializerSettings { Converters = new List { new FileMetadataConverter() } }; - var baseDir = "inputFolder"; - var raw = new FileMetadata(baseDir, new Dictionary> - { - ["meta"] = ImmutableArray.Create( - new FileMetadataItem(new GlobMatcher("*.md"), "meta", 1L), - new FileMetadataItem(new GlobMatcher("*.m"), "meta", true), - new FileMetadataItem(new GlobMatcher("abc"), "meta", "string"), - new FileMetadataItem(new GlobMatcher("/[]\\*.cs"), "meta", new Dictionary { ["key"] = "2" }), - new FileMetadataItem(new GlobMatcher("*/*.cs"), "meta", new object[] { "1", "2" }), - new FileMetadataItem(new GlobMatcher("**"), "meta", new Dictionary { ["key"] = new object[] { "1", "2" } }) - ) - }); - var serialized = JsonConvert.SerializeObject(raw, settings); - var expected = "{'baseDir':'inputFolder','dict':{'meta':[{'glob':'*.md','key':'meta','value':1},{'glob':'*.m','key':'meta','value':true},{'glob':'abc','key':'meta','value':'string'},{'glob':'/[]\\\\*.cs','key':'meta','value':{'key':'2'}},{'glob':'*/*.cs','key':'meta','value':['1','2']},{'glob':'**','key':'meta','value':{'key':['1','2']}}]}}".Replace('\'', '\"'); - Assert.Equal(expected, serialized); - - var actual = JsonConvert.DeserializeObject(serialized, settings); - - Assert.Equal(baseDir, actual.BaseDir); - - } - - [Fact] - public void TestSerializeFileMetadataIgnoreBaseDir() - { - var settings = new JsonSerializerSettings { Converters = new List { new FileMetadataConverter(true) } }; - var metadata = new Dictionary> - { - ["meta"] = ImmutableArray.Create( - new FileMetadataItem(new GlobMatcher("*.md"), "meta", 1L), - new FileMetadataItem(new GlobMatcher("*.m"), "meta", true), - new FileMetadataItem(new GlobMatcher("abc"), "meta", "string"), - new FileMetadataItem(new GlobMatcher("/[]\\*.cs"), "meta", new Dictionary { ["key"] = "2" }), - new FileMetadataItem(new GlobMatcher("*/*.cs"), "meta", new object[] { "1", "2" }), - new FileMetadataItem(new GlobMatcher("**"), "meta", new Dictionary { ["key"] = new object[] { "1", "2" } }) - ) - }; - var fileMetadata1 = new FileMetadata("baseDir1", metadata); - var fileMetadata2 = new FileMetadata("baseDir2", metadata); - - var str1 = JsonConvert.SerializeObject(fileMetadata1, settings); - var str2 = JsonConvert.SerializeObject(fileMetadata2, settings); - var deserialized1 = JsonConvert.DeserializeObject(str1, settings); - var deserialized2 = JsonConvert.DeserializeObject(str2, settings); - - Assert.Equal(str1, str2); - CompareFileMetadataItems(deserialized1, deserialized2); - } - - private static void CompareFileMetadataItems(FileMetadata raw, FileMetadata actual) - { - Assert.Equal(raw.Count, actual.Count); - foreach (var pair in raw) - { - Assert.True(actual.TryGetValue(pair.Key, out var array)); - Assert.Equal(pair.Value.Length, array.Length); - for (var i = 0; i < array.Length; i++) - { - Assert.Equal(pair.Value[i].Glob.Raw, array[i].Glob.Raw); - Assert.Equal(pair.Value[i].Key, array[i].Key); - Assert.Equal(pair.Value[i].Value, array[i].Value); - } - } - } -}