From 0e6c55604217f5f286650d2fb2c43c9a21efb705 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 4 Sep 2023 10:50:48 +0900 Subject: [PATCH] chore: Remove unused code (#9164) --- .../ConceptualDocumentProcessor.cs | 50 ------------------ .../ManagedReferenceDocumentProcessor.cs | 46 ----------------- .../SchemaDrivenDocumentProcessor.cs | 51 ------------------- .../YamlDocumentProcessor.cs | 51 ------------------- 4 files changed, 198 deletions(-) diff --git a/src/Docfx.Build.ConceptualDocuments/ConceptualDocumentProcessor.cs b/src/Docfx.Build.ConceptualDocuments/ConceptualDocumentProcessor.cs index 7ca42a26197..f1ecd047c71 100644 --- a/src/Docfx.Build.ConceptualDocuments/ConceptualDocumentProcessor.cs +++ b/src/Docfx.Build.ConceptualDocuments/ConceptualDocumentProcessor.cs @@ -19,7 +19,6 @@ public class ConceptualDocumentProcessor : DisposableDocumentProcessor { #region Fields - private readonly ResourcePoolManager _serializerPool; private readonly string[] SystemKeys = { "conceptual", "type", @@ -37,7 +36,6 @@ public class ConceptualDocumentProcessor : DisposableDocumentProcessor public ConceptualDocumentProcessor() { - _serializerPool = new ResourcePoolManager(GetSerializer, 0x10); } #endregion @@ -128,52 +126,4 @@ public override SaveResult Save(FileModel model) } #endregion - - #region Protected Methods - - protected virtual void SerializeModel(object model, Stream stream) - { - using var sw = new StreamWriter(stream, Encoding.UTF8, 0x100, true); - using var lease = _serializerPool.Rent(); - lease.Resource.Serialize(sw, model); - } - - protected virtual object DeserializeModel(Stream stream) - { - using var sr = new StreamReader(stream, Encoding.UTF8, false, 0x100, true); - using var jr = new JsonTextReader(sr); - using var lease = _serializerPool.Rent(); - return lease.Resource.Deserialize(jr); - } - - protected virtual void SerializeProperties(IDictionary properties, Stream stream) - { - using var sw = new StreamWriter(stream, Encoding.UTF8, 0x100, true); - using var lease = _serializerPool.Rent(); - lease.Resource.Serialize(sw, properties); - } - - protected virtual IDictionary DeserializeProperties(Stream stream) - { - using var sr = new StreamReader(stream, Encoding.UTF8, false, 0x100, true); - using var jr = new JsonTextReader(sr); - using var lease = _serializerPool.Rent(); - return lease.Resource.Deserialize>(jr); - } - - protected virtual JsonSerializer GetSerializer() - { - return new JsonSerializer - { - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Serialize, - Converters = - { - new Newtonsoft.Json.Converters.StringEnumConverter(), - }, - TypeNameHandling = TypeNameHandling.All, // lgtm [cs/unsafe-type-name-handling] - }; - } - - #endregion } diff --git a/src/Docfx.Build.ManagedReference/ManagedReferenceDocumentProcessor.cs b/src/Docfx.Build.ManagedReference/ManagedReferenceDocumentProcessor.cs index 5dd6460c28e..414a81c1064 100644 --- a/src/Docfx.Build.ManagedReference/ManagedReferenceDocumentProcessor.cs +++ b/src/Docfx.Build.ManagedReference/ManagedReferenceDocumentProcessor.cs @@ -20,7 +20,6 @@ namespace Docfx.Build.ManagedReference; public class ManagedReferenceDocumentProcessor : ReferenceDocumentProcessorBase { #region Fields - private readonly ResourcePoolManager _serializerPool; private static readonly string[] SystemKeys = { "uid", "isEii", @@ -63,7 +62,6 @@ public class ManagedReferenceDocumentProcessor : ReferenceDocumentProcessorBase public ManagedReferenceDocumentProcessor() { - _serializerPool = new ResourcePoolManager(GetSerializer, 0x10); } #endregion @@ -310,49 +308,5 @@ private static XRefSpec GetXRefSpecFromReference(ReferenceViewModel item) return result; } - protected virtual void SerializeModel(object model, Stream stream) - { - using var sw = new StreamWriter(stream, Encoding.UTF8, 0x100, true); - using var lease = _serializerPool.Rent(); - lease.Resource.Serialize(sw, model); - } - - protected virtual object DeserializeModel(Stream stream) - { - using var sr = new StreamReader(stream, Encoding.UTF8, false, 0x100, true); - using var jr = new JsonTextReader(sr); - using var lease = _serializerPool.Rent(); - return lease.Resource.Deserialize(jr); - } - - protected virtual void SerializeProperties(IDictionary properties, Stream stream) - { - using var sw = new StreamWriter(stream, Encoding.UTF8, 0x100, true); - using var lease = _serializerPool.Rent(); - lease.Resource.Serialize(sw, properties); - } - - protected virtual IDictionary DeserializeProperties(Stream stream) - { - using var sr = new StreamReader(stream, Encoding.UTF8, false, 0x100, true); - using var jr = new JsonTextReader(sr); - using var lease = _serializerPool.Rent(); - return (IDictionary)lease.Resource.Deserialize(jr); - } - - protected virtual JsonSerializer GetSerializer() - { - return new JsonSerializer - { - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Serialize, - Converters = - { - new Newtonsoft.Json.Converters.StringEnumConverter(), - }, - TypeNameHandling = TypeNameHandling.All, // lgtm [cs/unsafe-type-name-handling] - }; - } - #endregion } diff --git a/src/Docfx.Build.SchemaDriven/SchemaDrivenDocumentProcessor.cs b/src/Docfx.Build.SchemaDriven/SchemaDrivenDocumentProcessor.cs index e6c61255768..03a202c92d4 100644 --- a/src/Docfx.Build.SchemaDriven/SchemaDrivenDocumentProcessor.cs +++ b/src/Docfx.Build.SchemaDriven/SchemaDrivenDocumentProcessor.cs @@ -16,8 +16,6 @@ namespace Docfx.Build.SchemaDriven; public class SchemaDrivenDocumentProcessor : DisposableDocumentProcessor { #region Fields - - private readonly ResourcePoolManager _serializerPool; private readonly string _schemaName; private readonly DocumentSchema _schema; private readonly bool _allowOverwrite; @@ -47,7 +45,6 @@ public SchemaDrivenDocumentProcessor( _schema = schema; SchemaValidator = schema.Validator; _allowOverwrite = schema.AllowOverwrite; - _serializerPool = new ResourcePoolManager(GetSerializer, 0x10); _markdigMarkdownService = markdigMarkdownService; _folderRedirectionManager = folderRedirectionManager; if (container != null) @@ -216,52 +213,4 @@ public override void UpdateHref(FileModel model, IDocumentBuildContext context) } #endregion - - #region Protected Methods - - protected virtual void SerializeModel(object model, Stream stream) - { - using var sw = new StreamWriter(stream, Encoding.UTF8, 0x100, true); - using var lease = _serializerPool.Rent(); - lease.Resource.Serialize(sw, model); - } - - protected virtual object DeserializeModel(Stream stream) - { - using var sr = new StreamReader(stream, Encoding.UTF8, false, 0x100, true); - using var jr = new JsonTextReader(sr); - using var lease = _serializerPool.Rent(); - return lease.Resource.Deserialize(jr); - } - - protected virtual void SerializeProperties(IDictionary properties, Stream stream) - { - using var sw = new StreamWriter(stream, Encoding.UTF8, 0x100, true); - using var lease = _serializerPool.Rent(); - lease.Resource.Serialize(sw, properties); - } - - protected virtual IDictionary DeserializeProperties(Stream stream) - { - using var sr = new StreamReader(stream, Encoding.UTF8, false, 0x100, true); - using var jr = new JsonTextReader(sr); - using var lease = _serializerPool.Rent(); - return lease.Resource.Deserialize>(jr); - } - - protected virtual JsonSerializer GetSerializer() - { - return new JsonSerializer - { - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Serialize, - Converters = - { - new Newtonsoft.Json.Converters.StringEnumConverter(), - }, - TypeNameHandling = TypeNameHandling.All, // lgtm [cs/unsafe-type-name-handling] - }; - } - - #endregion } diff --git a/test/Docfx.Build.Engine.Tests/DocumentProcessors/YamlDocumentProcessor.cs b/test/Docfx.Build.Engine.Tests/DocumentProcessors/YamlDocumentProcessor.cs index c20ceca26ab..1a6424e7c55 100644 --- a/test/Docfx.Build.Engine.Tests/DocumentProcessors/YamlDocumentProcessor.cs +++ b/test/Docfx.Build.Engine.Tests/DocumentProcessors/YamlDocumentProcessor.cs @@ -23,15 +23,12 @@ public class YamlDocumentProcessor : DisposableDocumentProcessor public override string Name => nameof(YamlDocumentProcessor); - private readonly ResourcePoolManager _serializerPool; - #endregion #region Constructors public YamlDocumentProcessor() { - _serializerPool = new ResourcePoolManager(GetSerializer, 0x10); } #endregion @@ -98,52 +95,4 @@ public override SaveResult Save(FileModel model) } #endregion - - #region Protected Methods - - protected virtual void SerializeModel(object model, Stream stream) - { - using var sw = new StreamWriter(stream, Encoding.UTF8, 0x100, true); - using var lease = _serializerPool.Rent(); - lease.Resource.Serialize(sw, model); - } - - protected virtual object DeserializeModel(Stream stream) - { - using var sr = new StreamReader(stream, Encoding.UTF8, false, 0x100, true); - using var jr = new JsonTextReader(sr); - using var lease = _serializerPool.Rent(); - return lease.Resource.Deserialize(jr); - } - - protected virtual void SerializeProperties(IDictionary properties, Stream stream) - { - using var sw = new StreamWriter(stream, Encoding.UTF8, 0x100, true); - using var lease = _serializerPool.Rent(); - lease.Resource.Serialize(sw, properties); - } - - protected virtual IDictionary DeserializeProperties(Stream stream) - { - using var sr = new StreamReader(stream, Encoding.UTF8, false, 0x100, true); - using var jr = new JsonTextReader(sr); - using var lease = _serializerPool.Rent(); - return lease.Resource.Deserialize>(jr); - } - - protected virtual JsonSerializer GetSerializer() - { - return new JsonSerializer - { - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Serialize, - Converters = - { - new Newtonsoft.Json.Converters.StringEnumConverter(), - }, - TypeNameHandling = TypeNameHandling.All, // lgtm [cs/unsafe-type-name-handling] - }; - } - - #endregion }