Skip to content

Commit

Permalink
chore: suppress IDE0044 message
Browse files Browse the repository at this point in the history
  • Loading branch information
filzrev committed Sep 20, 2023
1 parent 2ce102a commit a661ac1
Show file tree
Hide file tree
Showing 42 changed files with 91 additions and 91 deletions.
2 changes: 1 addition & 1 deletion src/Docfx.App/Config/FileMetadataPairs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Docfx;
internal class FileMetadataPairs
{
// Order matters, the latter one overrides the former one
private List<FileMetadataPairsItem> _items;
private readonly List<FileMetadataPairsItem> _items;

/// <summary>
/// Gets FileMetadataPairs items.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract class BaseModelAttributeHandler<T> : IModelAttributeHandler wher
private const int MaximumNestedLevel = 32;
private readonly TypeInfo _typeInfo;
protected readonly IModelAttributeHandler Handler;
private Type _type;
private readonly Type _type;
protected BaseModelAttributeHandler(Type type, IModelAttributeHandler handler)
{
ArgumentNullException.ThrowIfNull(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Docfx.Build.Common;

public class CompositeModelAttributeHandler : IModelAttributeHandler
{
private IModelAttributeHandler[] _handlers;
private readonly IModelAttributeHandler[] _handlers;
public CompositeModelAttributeHandler(params IModelAttributeHandler[] handlers)
{
_handlers = handlers;
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build.Engine/HostServiceCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Docfx.Build.Engine;

internal class HostServiceCreator : IHostServiceCreator
{
private DocumentBuildContext _context;
private readonly DocumentBuildContext _context;

public HostServiceCreator(DocumentBuildContext context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Docfx.Build.Engine;
internal class PostProcessorsManager : IDisposable
{
private readonly List<PostProcessor> _postProcessors;
private IPostProcessorsHandler _postProcessorsHandler;
private readonly IPostProcessorsHandler _postProcessorsHandler;

public PostProcessorsManager(CompositionHost container, ImmutableArray<string> postProcessorNames)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build.Engine/PostProcessors/ValidateBookmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public sealed class ValidateBookmark : HtmlDocumentHandler
/// </summary>
private readonly OSPlatformSensitiveDictionary<string> _fileMapping =
new();
private OSPlatformSensitiveDictionary<List<LinkItem>> _linksWithBookmark =
private readonly OSPlatformSensitiveDictionary<List<LinkItem>> _linksWithBookmark =
new();

#region IHtmlDocumentHandler members
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public sealed class LocalFileResourceReader : ResourceFileReader
{
private const int MaxSearchLevel = 5;
// keep comparer to be case sensitive as to be consistent with zip entries
private static StringComparer ResourceComparer = StringComparer.Ordinal;
private string _directory = null;
private static readonly StringComparer ResourceComparer = StringComparer.Ordinal;
private readonly string _directory = null;
private readonly int _maxDepth;
private readonly HashSet<string> NamesHashSet;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Docfx.Build.Engine;

public class TemplateCollection : Dictionary<string, TemplateBundle>
{
private TemplateBundle _defaultTemplate = null;
private readonly TemplateBundle _defaultTemplate = null;

public IResourceFileReader Reader { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Docfx.Build.ManagedReference;
[Export(nameof(ManagedReferenceDocumentProcessor), typeof(IDocumentBuildStep))]
public class FillReferenceInformation : BaseDocumentBuildStep
{
private Dictionary<string, SourceInfo> _items = new();
private readonly Dictionary<string, SourceInfo> _items = new();

public override string Name => nameof(FillReferenceInformation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public class MarkdownFragmentsCreator

private int _position;

private InlineCodeHeadingRule _inlineCodeHeadingRule = new();
private readonly InlineCodeHeadingRule _inlineCodeHeadingRule = new();

private L1InlineCodeHeadingRule _l1InlineCodeHeadingRule = new();
private readonly L1InlineCodeHeadingRule _l1InlineCodeHeadingRule = new();

private L2InlineCodeHeadingRule _l2InlineCodeHeadingRule = new();
private readonly L2InlineCodeHeadingRule _l2InlineCodeHeadingRule = new();

private YamlCodeBlockRule _yamlCodeBlockRule = new();
private readonly YamlCodeBlockRule _yamlCodeBlockRule = new();

public IEnumerable<MarkdownFragmentModel> Create(MarkdownDocument document)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Docfx.Build.OverwriteDocuments;

public class OverwriteDocumentModelCreator
{
string _file;
private readonly string _file;

public OverwriteDocumentModelCreator(string file)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build.SchemaDriven/ValidateFragmentsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Docfx.Build.SchemaDriven;

public class ValidateFragmentsHandler : ISchemaFragmentsHandler
{
Dictionary<string, bool> _isMissingUidsLogged = new();
private readonly Dictionary<string, bool> _isMissingUidsLogged = new();

public void HandleUid(string uidKey, YamlMappingNode node, Dictionary<string, MarkdownFragment> fragments, BaseSchema schema, string oPathPrefix, string uid)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Common/FileItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Docfx;
[Serializable]
public class FileItems : List<string>
{
private static IEnumerable<string> Empty = new List<string>();
private static readonly IEnumerable<string> Empty = new List<string>();
public FileItems(string file) : base()
{
Add(file);
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Common/FileMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Docfx;
[Serializable]
public class FileMapping
{
private List<FileMappingItem> _items = new();
private readonly List<FileMappingItem> _items = new();

/// <summary>
/// Flags to distinguish items are expanded or not.
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Dotnet/SymbolFormatter.Syntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class SyntaxFormatter
public SyntaxLanguage Language { get; init; }
public SymbolFilter Filter { get; init; } = default!;

private ImmutableArray<SymbolDisplayPart>.Builder _parts = ImmutableArray.CreateBuilder<SymbolDisplayPart>();
private readonly ImmutableArray<SymbolDisplayPart>.Builder _parts = ImmutableArray.CreateBuilder<SymbolDisplayPart>();

public ImmutableArray<SymbolDisplayPart> GetSyntax(ISymbol symbol)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Docfx.Glob/GlobMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public class GlobMatcher : IEquatable<GlobMatcher>

private static readonly Regex GlobStarRegex = new(@"^\*{2,}/?$", RegexOptions.Compiled);

private GlobRegexItem[][] _items;
private bool _negate = false;
private bool _ignoreCase = false;
private readonly GlobRegexItem[][] _items;
private readonly bool _negate = false;
private readonly bool _ignoreCase = false;
#endregion

public const GlobMatcherOptions DefaultOptions = GlobMatcherOptions.AllowNegate | GlobMatcherOptions.IgnoreCase | GlobMatcherOptions.AllowGlobStar | GlobMatcherOptions.AllowExpand | GlobMatcherOptions.AllowEscape;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Docfx.MarkdigEngine.Extensions;

public class BlockAggregateContext
{
private ContainerBlock _blocks;
private readonly ContainerBlock _blocks;
private int _currentBlockIndex = -1;

public BlockAggregateContext(ContainerBlock blocks)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Docfx.MarkdigEngine.Extensions;
public class HtmlInclusionBlockRenderer : HtmlObjectRenderer<InclusionBlock>
{
private readonly MarkdownContext _context;
private MarkdownPipeline _pipeline;
private readonly MarkdownPipeline _pipeline;

public HtmlInclusionBlockRenderer(MarkdownContext context, MarkdownPipeline pipeline)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Docfx.MarkdigEngine.Extensions;
public class ActiveAndVisibleRewriter : IMarkdownObjectRewriter
{
private readonly MarkdownContext _context;
private List<string[]> tabSelectionInfo = new();
private readonly List<string[]> tabSelectionInfo = new();

public ActiveAndVisibleRewriter(MarkdownContext context)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Plugins/TreeNavigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Docfx.Plugins;

public class TreeNavigator
{
private NavigatorTreeItem _tree;
private readonly NavigatorTreeItem _tree;
private NavigatorTreeItem _current;

public TreeNavigator(TreeItem tree)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Docfx.YamlSerialization.NodeDeserializers;

public class EmitArrayNodeDeserializer : INodeDeserializer
{
private static MethodInfo DeserializeHelperMethod =
private static readonly MethodInfo DeserializeHelperMethod =
typeof(EmitArrayNodeDeserializer).GetMethod(nameof(DeserializeHelper));
private static readonly ConcurrentDictionary<Type, Func<IParser, Type, Func<IParser, Type, object>, object>> _funcCache =
new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class FullObjectGraphTraversalStrategy : IObjectGraphTraversalStrategy
private readonly int _maxRecursion;
private readonly ITypeInspector _typeDescriptor;
private readonly ITypeResolver _typeResolver;
private INamingConvention _namingConvention;
private readonly INamingConvention _namingConvention;
private readonly Dictionary<Tuple<Type, Type>, Action<IObjectDescriptor, IObjectGraphVisitor, int, IObjectGraphVisitorContext>> _behaviorCache =
new();
private readonly Dictionary<Tuple<Type, Type, Type>, Action<FullObjectGraphTraversalStrategy, object, IObjectGraphVisitor, int, INamingConvention, IObjectGraphVisitorContext>> _traverseGenericDictionaryCache =
Expand Down
2 changes: 1 addition & 1 deletion src/docfx/Models/InitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ private static bool Converter(string input)

private class SingleChoiceQuestion<T> : Question<T>
{
private Func<string, T> _converter;
private readonly Func<string, T> _converter;
/// <summary>
/// Options, the first one as the default one
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class ConceptualDocumentProcessorTest : TestBase
private readonly string _templateFolder;
private readonly FileCollection _defaultFiles;
private readonly FileCreator _fileCreator;
private ApplyTemplateSettings _applyTemplateSettings;
private TemplateManager _templateManager;
private readonly ApplyTemplateSettings _applyTemplateSettings;
private readonly TemplateManager _templateManager;
private const string RawModelFileExtension = ".raw.json";

public ConceptualDocumentProcessorTest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Docfx.Build.Engine.Tests;
[Collection("docfx STA")]
public class ExtractSearchIndexFromHtmlTest
{
private static ExtractSearchIndex _extractor = new();
private static readonly ExtractSearchIndex _extractor = new();

[Fact]
public void TestBasicFeature()
Expand Down
2 changes: 1 addition & 1 deletion test/Docfx.Build.Engine.Tests/ValidateBookmarkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Docfx.Build.Engine.Tests;
public class ValidateBookmarkTest : TestBase
{
private readonly string _outputFolder;
private TestLoggerListener _listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter("validate_bookmark.ValidateBookmark");
private readonly TestLoggerListener _listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter("validate_bookmark.ValidateBookmark");

public ValidateBookmarkTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ namespace Docfx.Build.ManagedReference.Tests;

public class ManagedReferenceDocumentProcessorTest : TestBase
{
private string _outputFolder;
private string _inputFolder;
private FileCollection _defaultFiles;
private ApplyTemplateSettings _applyTemplateSettings;
private TemplateManager _templateManager;
private readonly string _outputFolder;
private readonly string _inputFolder;
private readonly FileCollection _defaultFiles;
private readonly ApplyTemplateSettings _applyTemplateSettings;
private readonly TemplateManager _templateManager;

private const string RawModelFileExtension = ".raw.json";
private const string MrefDirectory = "mref";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Docfx.Build.OverwriteDocuments.Tests;

public class OverwriteDocumentModelCreatorTest
{
private TestLoggerListener _listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter("overwrite_document_model_creator");
private readonly TestLoggerListener _listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter("overwrite_document_model_creator");

[Fact]
public void YamlCodeBlockTest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ namespace Docfx.Build.RestApi.Tests;
[Collection("docfx STA")]
public class RestApiDocumentProcessorTest : TestBase
{
private string _outputFolder;
private string _inputFolder;
private FileCollection _defaultFiles;
private ApplyTemplateSettings _applyTemplateSettings;
private readonly string _outputFolder;
private readonly string _inputFolder;
private readonly FileCollection _defaultFiles;
private readonly ApplyTemplateSettings _applyTemplateSettings;

private const string RawModelFileExtension = ".raw.json";
private const string SwaggerDirectory = "swagger";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ namespace Docfx.Build.RestApi.WithPlugins.Tests;
[Collection("docfx STA")]
public class SplitRestApiToOperationLevelTest : TestBase
{
private string _inputFolder;
private string _outputFolder;
private FileCollection _defaultFiles;
private readonly string _inputFolder;
private readonly string _outputFolder;
private readonly FileCollection _defaultFiles;
private readonly ApplyTemplateSettings _applyTemplateSettings;
private TemplateManager _templateManager;
private readonly TemplateManager _templateManager;

private const string RawModelFileExtension = ".raw.json";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ namespace Docfx.Build.RestApi.WithPlugins.Tests;
[Collection("docfx STA")]
public class SplitRestApiToTagLevelTest : TestBase
{
private string _inputFolder;
private string _outputFolder;
private FileCollection _defaultFiles;
private readonly string _inputFolder;
private readonly string _outputFolder;
private readonly FileCollection _defaultFiles;
private readonly ApplyTemplateSettings _applyTemplateSettings;
private TemplateManager _templateManager;
private readonly TemplateManager _templateManager;

private const string RawModelFileExtension = ".raw.json";

Expand Down
16 changes: 8 additions & 8 deletions test/Docfx.Build.SchemaDriven.Tests/LimitationReachedTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ namespace Docfx.Build.SchemaDriven.Tests;
[Collection("docfx STA")]
public class LimitationReachedTest : TestBase
{
private static Regex InputMatcher = new(@"```(yml|yaml)\s*(### YamlMime:[\s\S]*?)\s*```", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static Regex SchemaMatcher = new(@"```json\s*(\{\s*""\$schema""[\s\S]*?)\s*```", RegexOptions.Compiled | RegexOptions.IgnoreCase);
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 string _outputFolder;
private string _inputFolder;
private string _templateFolder;
private FileCollection _defaultFiles;
private ApplyTemplateSettings _applyTemplateSettings;
private TemplateManager _templateManager;
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";

Expand Down
20 changes: 10 additions & 10 deletions test/Docfx.Build.SchemaDriven.Tests/MergeMarkdownFragmentsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ namespace Docfx.Build.SchemaDriven.Tests;
[Collection("docfx STA")]
public class MergeMarkdownFragmentsTest : TestBase
{
private string _outputFolder;
private string _inputFolder;
private string _templateFolder;
private FileCollection _defaultFiles;
private ApplyTemplateSettings _applyTemplateSettings;
private TemplateManager _templateManager;
private FileCollection _files;

private TestLoggerListener _listener;
private string _rawModelFilePath;
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 readonly FileCollection _files;

private readonly TestLoggerListener _listener;
private readonly string _rawModelFilePath;

private const string RawModelFileExtension = ".raw.json";

Expand Down
12 changes: 6 additions & 6 deletions test/Docfx.Build.SchemaDriven.Tests/SchemaMergerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ namespace Docfx.Build.SchemaDriven.Tests;
[Collection("docfx STA")]
public class SchemaMergerTest : TestBase
{
private string _outputFolder;
private string _inputFolder;
private string _templateFolder;
private FileCollection _defaultFiles;
private ApplyTemplateSettings _applyTemplateSettings;
private TemplateManager _templateManager;
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";

Expand Down
Loading

0 comments on commit a661ac1

Please sign in to comment.