Skip to content

Commit

Permalink
chore: Remove unused code (#9164)
Browse files Browse the repository at this point in the history
  • Loading branch information
filzrev authored Sep 4, 2023
1 parent 94d578f commit 0e6c556
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 198 deletions.
50 changes: 0 additions & 50 deletions src/Docfx.Build.ConceptualDocuments/ConceptualDocumentProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class ConceptualDocumentProcessor : DisposableDocumentProcessor
{
#region Fields

private readonly ResourcePoolManager<JsonSerializer> _serializerPool;
private readonly string[] SystemKeys = {
"conceptual",
"type",
Expand All @@ -37,7 +36,6 @@ public class ConceptualDocumentProcessor : DisposableDocumentProcessor

public ConceptualDocumentProcessor()
{
_serializerPool = new ResourcePoolManager<JsonSerializer>(GetSerializer, 0x10);
}

#endregion
Expand Down Expand Up @@ -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<string, object> 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<string, object> 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<Dictionary<string, object>>(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
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace Docfx.Build.ManagedReference;
public class ManagedReferenceDocumentProcessor : ReferenceDocumentProcessorBase
{
#region Fields
private readonly ResourcePoolManager<JsonSerializer> _serializerPool;
private static readonly string[] SystemKeys = {
"uid",
"isEii",
Expand Down Expand Up @@ -63,7 +62,6 @@ public class ManagedReferenceDocumentProcessor : ReferenceDocumentProcessorBase

public ManagedReferenceDocumentProcessor()
{
_serializerPool = new ResourcePoolManager<JsonSerializer>(GetSerializer, 0x10);
}

#endregion
Expand Down Expand Up @@ -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<string, object> 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<string, object> 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<string, object>)lease.Resource.Deserialize<object>(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
}
51 changes: 0 additions & 51 deletions src/Docfx.Build.SchemaDriven/SchemaDrivenDocumentProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ namespace Docfx.Build.SchemaDriven;
public class SchemaDrivenDocumentProcessor : DisposableDocumentProcessor
{
#region Fields

private readonly ResourcePoolManager<JsonSerializer> _serializerPool;
private readonly string _schemaName;
private readonly DocumentSchema _schema;
private readonly bool _allowOverwrite;
Expand Down Expand Up @@ -47,7 +45,6 @@ public SchemaDrivenDocumentProcessor(
_schema = schema;
SchemaValidator = schema.Validator;
_allowOverwrite = schema.AllowOverwrite;
_serializerPool = new ResourcePoolManager<JsonSerializer>(GetSerializer, 0x10);
_markdigMarkdownService = markdigMarkdownService;
_folderRedirectionManager = folderRedirectionManager;
if (container != null)
Expand Down Expand Up @@ -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<string, object> 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<string, object> 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<Dictionary<string, object>>(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
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ public class YamlDocumentProcessor : DisposableDocumentProcessor

public override string Name => nameof(YamlDocumentProcessor);

private readonly ResourcePoolManager<JsonSerializer> _serializerPool;

#endregion

#region Constructors

public YamlDocumentProcessor()
{
_serializerPool = new ResourcePoolManager<JsonSerializer>(GetSerializer, 0x10);
}

#endregion
Expand Down Expand Up @@ -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<string, object> 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<string, object> 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<Dictionary<string, object>>(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
}

0 comments on commit 0e6c556

Please sign in to comment.