diff --git a/src/Docfx.App/Helpers/DocumentBuilderWrapper.cs b/src/Docfx.App/Helpers/DocumentBuilderWrapper.cs index bc542a514fb..2bafb81bef6 100644 --- a/src/Docfx.App/Helpers/DocumentBuilderWrapper.cs +++ b/src/Docfx.App/Helpers/DocumentBuilderWrapper.cs @@ -23,7 +23,7 @@ public static void BuildDocument(BuildJsonConfig config, BuildOptions options, T // Ensure "_enableSearch" adds the right post processor if (metadata != null && metadata.TryGetValue("_enableSearch", out object value)) { - if (value is bool isSearchable && isSearchable && !postProcessorNames.Contains("ExtractSearchIndex")) + if (value is true && !postProcessorNames.Contains("ExtractSearchIndex")) { postProcessorNames = postProcessorNames.Add("ExtractSearchIndex"); } diff --git a/src/Docfx.Build.Common/ModelAttributeHandlers/Handlers/BaseModelAttributeHandler.cs b/src/Docfx.Build.Common/ModelAttributeHandlers/Handlers/BaseModelAttributeHandler.cs index 847a3da6406..1178c9062bf 100644 --- a/src/Docfx.Build.Common/ModelAttributeHandlers/Handlers/BaseModelAttributeHandler.cs +++ b/src/Docfx.Build.Common/ModelAttributeHandlers/Handlers/BaseModelAttributeHandler.cs @@ -78,7 +78,7 @@ public object Handle(object obj, HandleModelAttributesContext context) protected virtual bool ShouldHandle(object currentObj, object declaringObject, PropInfo currentPropInfo, HandleModelAttributesContext context) { - return currentPropInfo != null && currentPropInfo.Attr != null; + return currentPropInfo is {Attr: not null}; } /// diff --git a/src/Docfx.Build.ManagedReference/BuildOutputs/ApiReferenceBuildOutput.cs b/src/Docfx.Build.ManagedReference/BuildOutputs/ApiReferenceBuildOutput.cs index e168b7949b4..14416d04deb 100644 --- a/src/Docfx.Build.ManagedReference/BuildOutputs/ApiReferenceBuildOutput.cs +++ b/src/Docfx.Build.ManagedReference/BuildOutputs/ApiReferenceBuildOutput.cs @@ -300,7 +300,7 @@ public void Expand(Dictionary references, strin public static List GetSpecNames(string xref, string[] supportedLanguages, SortedList> specs = null) { - if (specs != null && specs.Count > 0) + if (specs is {Count: > 0}) { return (from spec in specs where supportedLanguages.Contains(spec.Key) diff --git a/src/Docfx.Build.RestApi/BuildRestApiDocument.cs b/src/Docfx.Build.RestApi/BuildRestApiDocument.cs index 75d60adb8d8..479fa53a900 100644 --- a/src/Docfx.Build.RestApi/BuildRestApiDocument.cs +++ b/src/Docfx.Build.RestApi/BuildRestApiDocument.cs @@ -102,7 +102,7 @@ private static void MarkupRecursive(JToken jToken, IHostService host, FileModel { if (MarkupKeys.Contains(pair.Key) && pair.Value != null) { - if (pair.Value is JValue jValue && jValue.Type == JTokenType.String) + if (pair.Value is JValue {Type: JTokenType.String} jValue) { jObject[pair.Key] = Markup(host, (string)jValue, model, filter); } diff --git a/src/Docfx.Build.RestApi/RestApiDocumentProcessor.cs b/src/Docfx.Build.RestApi/RestApiDocumentProcessor.cs index 8e6e4a5e608..fe922ad87a2 100644 --- a/src/Docfx.Build.RestApi/RestApiDocumentProcessor.cs +++ b/src/Docfx.Build.RestApi/RestApiDocumentProcessor.cs @@ -211,7 +211,7 @@ private static bool IsSwaggerFile(string filePath) if (jObject.TryGetValue("swagger", out JToken swaggerValue)) { var swaggerString = (string)swaggerValue; - if (swaggerString != null && swaggerString.Equals("2.0")) + if (swaggerString is "2.0") { return true; } diff --git a/src/Docfx.Build.SchemaDriven/Models/JsonPointer.cs b/src/Docfx.Build.SchemaDriven/Models/JsonPointer.cs index 5b1284e1ea1..99bb7ddba2d 100644 --- a/src/Docfx.Build.SchemaDriven/Models/JsonPointer.cs +++ b/src/Docfx.Build.SchemaDriven/Models/JsonPointer.cs @@ -49,7 +49,7 @@ public JsonPointer GetParentPointer() public static bool TryCreate(string raw, out JsonPointer pointer) { pointer = null; - if (raw != null && raw.Length > 0 && raw[0] != '/') + if (raw is {Length: > 0} && raw[0] != '/') { return false; } diff --git a/src/Docfx.Build.SchemaDriven/Processors/FileInterpreter.cs b/src/Docfx.Build.SchemaDriven/Processors/FileInterpreter.cs index 1874563298d..d67f99742ed 100644 --- a/src/Docfx.Build.SchemaDriven/Processors/FileInterpreter.cs +++ b/src/Docfx.Build.SchemaDriven/Processors/FileInterpreter.cs @@ -19,7 +19,7 @@ public FileInterpreter(bool exportFileLink, bool updateValue) public bool CanInterpret(BaseSchema schema) { - return schema != null && schema.ContentType == ContentType.File; + return schema is {ContentType: ContentType.File}; } public object Interpret(BaseSchema schema, object value, IProcessContext context, string path) diff --git a/src/Docfx.Build.SchemaDriven/Processors/HrefInterpreter.cs b/src/Docfx.Build.SchemaDriven/Processors/HrefInterpreter.cs index e6c95f1def9..64fee4703e3 100644 --- a/src/Docfx.Build.SchemaDriven/Processors/HrefInterpreter.cs +++ b/src/Docfx.Build.SchemaDriven/Processors/HrefInterpreter.cs @@ -21,7 +21,7 @@ public HrefInterpreter(bool exportFileLink, bool updateValue, string siteHostNam public bool CanInterpret(BaseSchema schema) { - return schema != null && schema.ContentType == ContentType.Href; + return schema is {ContentType: ContentType.Href}; } public object Interpret(BaseSchema schema, object value, IProcessContext context, string path) diff --git a/src/Docfx.Build.SchemaDriven/Processors/MarkdownInterpreter.cs b/src/Docfx.Build.SchemaDriven/Processors/MarkdownInterpreter.cs index f2b8c36260f..2ac605ee96e 100644 --- a/src/Docfx.Build.SchemaDriven/Processors/MarkdownInterpreter.cs +++ b/src/Docfx.Build.SchemaDriven/Processors/MarkdownInterpreter.cs @@ -9,7 +9,7 @@ public class MarkdownInterpreter : IInterpreter { public bool CanInterpret(BaseSchema schema) { - return schema != null && schema.ContentType == ContentType.Markdown; + return schema is {ContentType: ContentType.Markdown}; } public object Interpret(BaseSchema schema, object value, IProcessContext context, string path) diff --git a/src/Docfx.Build.SchemaDriven/Processors/XrefInterpreter.cs b/src/Docfx.Build.SchemaDriven/Processors/XrefInterpreter.cs index a865871c960..e4c0f1618f3 100644 --- a/src/Docfx.Build.SchemaDriven/Processors/XrefInterpreter.cs +++ b/src/Docfx.Build.SchemaDriven/Processors/XrefInterpreter.cs @@ -19,7 +19,7 @@ public XrefInterpreter(bool aggregateXrefs, bool resolveXref) public bool CanInterpret(BaseSchema schema) { - return schema != null && schema.ContentType == ContentType.Xref; + return schema is {ContentType: ContentType.Xref}; } public object Interpret(BaseSchema schema, object value, IProcessContext context, string path) diff --git a/src/Docfx.Build/TableOfContents/TocDocumentProcessor.cs b/src/Docfx.Build/TableOfContents/TocDocumentProcessor.cs index 85edc54ffdb..79172edce58 100644 --- a/src/Docfx.Build/TableOfContents/TocDocumentProcessor.cs +++ b/src/Docfx.Build/TableOfContents/TocDocumentProcessor.cs @@ -91,7 +91,7 @@ private void UpdateTocItemHref(TocItemViewModel toc, FileModel model, IDocumentB toc.OriginalTopicHref = null; includedFrom = toc.IncludedFrom ?? includedFrom; - if (toc.Items != null && toc.Items.Count > 0) + if (toc.Items is {Count: > 0}) { foreach (var item in toc.Items) { diff --git a/src/Docfx.Build/TableOfContents/TocResolver.cs b/src/Docfx.Build/TableOfContents/TocResolver.cs index 242a7bddbec..6ea34f31a3b 100644 --- a/src/Docfx.Build/TableOfContents/TocResolver.cs +++ b/src/Docfx.Build/TableOfContents/TocResolver.cs @@ -122,7 +122,7 @@ private TocItemInfo ResolveItemCore(TocItemInfo wrapper, Stack stac { case HrefType.AbsolutePath: case HrefType.RelativeFile: - if (item.Items != null && item.Items.Count > 0) + if (item.Items is {Count: > 0}) { item.Items = new List(from i in item.Items select ResolveItem(new TocItemInfo(file, i), stack) into r diff --git a/src/Docfx.Build/TableOfContents/TocRestructureUtility.cs b/src/Docfx.Build/TableOfContents/TocRestructureUtility.cs index c22f925242f..ead7255750e 100644 --- a/src/Docfx.Build/TableOfContents/TocRestructureUtility.cs +++ b/src/Docfx.Build/TableOfContents/TocRestructureUtility.cs @@ -28,7 +28,7 @@ private static void RestructureCore(TocItemViewModel item, List 0) + if (item.Items is {Count: > 0}) { var parentItems = new List(item.Items); foreach (var i in item.Items) diff --git a/src/Docfx.Build/TemplateProcessors/TemplateManager.cs b/src/Docfx.Build/TemplateProcessors/TemplateManager.cs index 760989cb1f8..d4345e937f4 100644 --- a/src/Docfx.Build/TemplateProcessors/TemplateManager.cs +++ b/src/Docfx.Build/TemplateProcessors/TemplateManager.cs @@ -78,7 +78,7 @@ private IEnumerable GetTemplateDirectories(IEnumerable names) public void ProcessTheme(string outputDirectory, bool overwrite) { - if (_themes != null && _themes.Count > 0) + if (_themes is {Count: > 0}) { TryExportResourceFiles(_themes, outputDirectory, overwrite); Logger.LogInfo($"Theme(s) {_themes.ToDelimitedString()} applied."); diff --git a/src/Docfx.Build/XRefMaps/XRefArchiveBuilder.cs b/src/Docfx.Build/XRefMaps/XRefArchiveBuilder.cs index 0a43a29fa30..61d2f99d36e 100644 --- a/src/Docfx.Build/XRefMaps/XRefArchiveBuilder.cs +++ b/src/Docfx.Build/XRefMaps/XRefArchiveBuilder.cs @@ -53,7 +53,7 @@ private async Task DownloadCoreAsync(Uri uri, XRefArchive xa, Cancellati // Sort is not needed if `map.Sorted == true`. // But there are some xrefmap files that is not propery sorted by using InvariantCulture. // (e.g. Unity xrefmap that maintained by community) - if (map.References != null && map.References.Count > 0) + if (map.References is {Count: > 0}) { map.References.Sort(XRefSpecUidComparer.Instance); map.Sorted = true; diff --git a/src/Docfx.Common/Path/RelativePath.cs b/src/Docfx.Common/Path/RelativePath.cs index a804d5db46f..8e783c36c42 100644 --- a/src/Docfx.Common/Path/RelativePath.cs +++ b/src/Docfx.Common/Path/RelativePath.cs @@ -54,11 +54,10 @@ public static RelativePath FromUrl(string path) public static bool IsRelativePath(string path) { // TODO : to merge with the PathUtility one - return path != null && - path.Length > 0 && - path[0] != '/' && - path[0] != '\\' && - path.IndexOfAny(PathUtility.InvalidPathChars) == -1; + return path is {Length: > 0} && + path[0] != '/' && + path[0] != '\\' && + path.IndexOfAny(PathUtility.InvalidPathChars) == -1; } public static RelativePath Parse(string path) => TryParseCore(path, true); diff --git a/src/Docfx.Dotnet/DotnetApiCatalog.Toc.cs b/src/Docfx.Dotnet/DotnetApiCatalog.Toc.cs index 5dcb7ecd79e..788da38ef94 100644 --- a/src/Docfx.Dotnet/DotnetApiCatalog.Toc.cs +++ b/src/Docfx.Dotnet/DotnetApiCatalog.Toc.cs @@ -61,7 +61,7 @@ IEnumerable CreateToc(ISymbol symbol, Compilation compilation) switch (symbol) { - case INamespaceSymbol ns when ns.IsGlobalNamespace: + case INamespaceSymbol {IsGlobalNamespace: true} ns: foreach (var child in ns.GetNamespaceMembers()) foreach (var item in CreateToc(child, compilation)) yield return item; @@ -248,7 +248,7 @@ void InsertCategory(TocNodeType type, string name) case CategoryLayout.Nested: { // Skip when parent node is category node. - if (parentTocNode != null && parentTocNode.type == TocNodeType.None) + if (parentTocNode is {type: TocNodeType.None}) return; // If items contains specified type node. Create new TocNode for category. and move related node to child node. diff --git a/src/Docfx.Dotnet/ManagedReference/Resolvers/NormalizeSyntax.cs b/src/Docfx.Dotnet/ManagedReference/Resolvers/NormalizeSyntax.cs index 1fe8e00c895..61794226839 100644 --- a/src/Docfx.Dotnet/ManagedReference/Resolvers/NormalizeSyntax.cs +++ b/src/Docfx.Dotnet/ManagedReference/Resolvers/NormalizeSyntax.cs @@ -17,7 +17,7 @@ public void Run(MetadataModel yaml, ResolverContext context) (member, parent) => { // get all the possible places where link is possible - if (member.Syntax != null && member.Syntax.Content != null) + if (member.Syntax is {Content: not null}) { SyntaxLanguage[] keys = new SyntaxLanguage[member.Syntax.Content.Count]; member.Syntax.Content.Keys.CopyTo(keys, 0); diff --git a/src/Docfx.Dotnet/ManagedReference/Resolvers/ResolveReference.cs b/src/Docfx.Dotnet/ManagedReference/Resolvers/ResolveReference.cs index 074c5318ea6..1b59b26ee8c 100644 --- a/src/Docfx.Dotnet/ManagedReference/Resolvers/ResolveReference.cs +++ b/src/Docfx.Dotnet/ManagedReference/Resolvers/ResolveReference.cs @@ -27,7 +27,7 @@ public void Run(MetadataModel yaml, ResolverContext context) page = parent; current.References = null; } - if (documentReferences != null && documentReferences.Count > 0) + if (documentReferences is {Count: > 0}) { foreach (var key in documentReferences.Keys) { diff --git a/src/Docfx.Dotnet/ManagedReference/Resolvers/SetDerivedClass.cs b/src/Docfx.Dotnet/ManagedReference/Resolvers/SetDerivedClass.cs index 8a9401b2a32..c812f1a6e0d 100644 --- a/src/Docfx.Dotnet/ManagedReference/Resolvers/SetDerivedClass.cs +++ b/src/Docfx.Dotnet/ManagedReference/Resolvers/SetDerivedClass.cs @@ -11,7 +11,7 @@ internal class SetDerivedClass : IResolverPipeline public void Run(MetadataModel yaml, ResolverContext context) { - if (yaml.Members != null && yaml.Members.Count > 0) + if (yaml.Members is {Count: > 0}) { UpdateDerivedClassMapping(yaml.Members, context.References); AppendDerivedClass(yaml.Members); @@ -23,7 +23,7 @@ private void UpdateDerivedClassMapping(List items, Dictionary()) { var inheritance = item.Inheritance; - if (inheritance != null && inheritance.Count > 0) + if (inheritance is {Count: > 0}) { var superClass = inheritance[inheritance.Count - 1]; diff --git a/src/Docfx.Dotnet/ManagedReference/Visitors/SymbolVisitorAdapter.cs b/src/Docfx.Dotnet/ManagedReference/Visitors/SymbolVisitorAdapter.cs index b283661a9a3..0ede8bde10a 100644 --- a/src/Docfx.Dotnet/ManagedReference/Visitors/SymbolVisitorAdapter.cs +++ b/src/Docfx.Dotnet/ManagedReference/Visitors/SymbolVisitorAdapter.cs @@ -238,7 +238,7 @@ public override MetadataItem VisitMethod(IMethodSymbol symbol) } _generator.GenerateSyntax(symbol, result.Syntax, _filter); - if (symbol.IsOverride && symbol.OverriddenMethod != null) + if (symbol is {IsOverride: true, OverriddenMethod: not null}) { result.Overridden = AddSpecReference(symbol.OverriddenMethod, typeGenericParameters, methodGenericParameters); } @@ -296,7 +296,7 @@ public override MetadataItem VisitEvent(IEventSymbol symbol) var typeGenericParameters = symbol.ContainingType.IsGenericType ? symbol.ContainingType.Accept(TypeGenericParameterNameVisitor.Instance) : EmptyListOfString; - if (symbol.IsOverride && symbol.OverriddenEvent != null) + if (symbol is {IsOverride: true, OverriddenEvent: not null}) { result.Overridden = AddSpecReference(symbol.OverriddenEvent, typeGenericParameters); } @@ -350,7 +350,7 @@ public override MetadataItem VisitProperty(IPropertySymbol symbol) Debug.Assert(result.Syntax.Return.Type != null); } - if (symbol.IsOverride && symbol.OverriddenProperty != null) + if (symbol is {IsOverride: true, OverriddenProperty: not null}) { result.Overridden = AddSpecReference(symbol.OverriddenProperty, typeGenericParameters); } diff --git a/src/Docfx.Dotnet/ManagedReference/Visitors/VisitorHelper.cs b/src/Docfx.Dotnet/ManagedReference/Visitors/VisitorHelper.cs index d60fbf4f395..0db6a1a587f 100644 --- a/src/Docfx.Dotnet/ManagedReference/Visitors/VisitorHelper.cs +++ b/src/Docfx.Dotnet/ManagedReference/Visitors/VisitorHelper.cs @@ -29,7 +29,7 @@ public static string GetId(ISymbol symbol) return null; } - if (symbol is INamespaceSymbol namespaceSymbol && namespaceSymbol.IsGlobalNamespace) + if (symbol is INamespaceSymbol {IsGlobalNamespace: true}) { return GlobalNamespaceId; } diff --git a/src/Docfx.Dotnet/Parsers/XmlComment.cs b/src/Docfx.Dotnet/Parsers/XmlComment.cs index 1cfc7312d61..52b3b1d6a29 100644 --- a/src/Docfx.Dotnet/Parsers/XmlComment.cs +++ b/src/Docfx.Dotnet/Parsers/XmlComment.cs @@ -356,7 +356,7 @@ private void ResolveCrefLink(XNode node, string nodeSelector, Action= 'a' && c <= 'z') || (c >= '0' && c <= '9'): + case char and (>= 'a' and <= 'z' or >= '0' and <= '9'): case '(' or ')' or '*' or '@': sb.Append(ch); break; diff --git a/src/Docfx.Dotnet/YamlViewModelExtensions.cs b/src/Docfx.Dotnet/YamlViewModelExtensions.cs index b24dba95762..e1690b0bce4 100644 --- a/src/Docfx.Dotnet/YamlViewModelExtensions.cs +++ b/src/Docfx.Dotnet/YamlViewModelExtensions.cs @@ -180,7 +180,7 @@ private static ReferenceViewModel ToReferenceViewModel(KeyValuePair 0) + if (model.Value.NameParts is {Count: > 0}) { result.Name = GetName(model.Value.NameParts, SyntaxLanguage.Default); var nameForCSharp = GetName(model.Value.NameParts, SyntaxLanguage.CSharp); @@ -270,7 +270,7 @@ public static ItemViewModel ToItemViewModel(this MetadataItem model, ExtractMeta Attributes = model.Attributes, }; - if (model.Parent != null && model.Parent.Name != null && !model.Name.StartsWith(model.Parent.Name)) + if (model.Parent is {Name: not null} && !model.Name.StartsWith(model.Parent.Name)) { result.Id = model.Name.Substring(model.Name.LastIndexOf('.') + 1); } @@ -330,7 +330,7 @@ public static SyntaxDetailViewModel ToSyntaxDetailViewModel(this SyntaxDetail mo TypeParameters = model.TypeParameters, Return = model.Return, }; - if (model.Content != null && model.Content.Count > 0) + if (model.Content is {Count: > 0}) { result.Content = model.Content.GetLanguageProperty(SyntaxLanguage.Default); var contentForCSharp = model.Content.GetLanguageProperty(SyntaxLanguage.CSharp); @@ -379,7 +379,7 @@ public static TValue GetLanguageProperty(this SortedList 0) + if (model.Items is {Count: > 0}) { foreach (var item in model.Items) { diff --git a/src/Docfx.MarkdigEngine.Extensions/Aggregator/TabGroupAggregator.cs b/src/Docfx.MarkdigEngine.Extensions/Aggregator/TabGroupAggregator.cs index 6c10611f183..b2d531fccd1 100644 --- a/src/Docfx.MarkdigEngine.Extensions/Aggregator/TabGroupAggregator.cs +++ b/src/Docfx.MarkdigEngine.Extensions/Aggregator/TabGroupAggregator.cs @@ -106,7 +106,7 @@ private static TabItemBlock CreateTabItem( private static Tuple ParseHeading(HeadingBlock block) { var child = block.Inline.FirstChild; - if (child != null && child.NextSibling == null && child is LinkInline link) + if (child is {NextSibling: null} and LinkInline link) { var m = HrefRegex.Match(link.Url); if (m.Success) diff --git a/src/Docfx.MarkdigEngine.Extensions/MonikerRange/MonikerRangeParser.cs b/src/Docfx.MarkdigEngine.Extensions/MonikerRange/MonikerRangeParser.cs index 7a0f3e7e480..3e8a92f5756 100644 --- a/src/Docfx.MarkdigEngine.Extensions/MonikerRange/MonikerRangeParser.cs +++ b/src/Docfx.MarkdigEngine.Extensions/MonikerRange/MonikerRangeParser.cs @@ -142,7 +142,7 @@ public override BlockState TryContinue(BlockProcessor processor, Block block) public override bool Close(BlockProcessor processor, Block block) { var monikerRange = (MonikerRangeBlock)block; - if (monikerRange != null && monikerRange.Closed == false) + if (monikerRange is {Closed: false}) { _context.LogWarning("invalid-moniker-range", $"No \"::: {EndString}\" found for \"{monikerRange.MonikerRange}\", MonikerRange does not end explicitly.", block); } diff --git a/src/Docfx.MarkdigEngine.Extensions/PlantUml/PlantUmlCodeBlockRenderer.cs b/src/Docfx.MarkdigEngine.Extensions/PlantUml/PlantUmlCodeBlockRenderer.cs index 776df0e678b..5957c059df4 100644 --- a/src/Docfx.MarkdigEngine.Extensions/PlantUml/PlantUmlCodeBlockRenderer.cs +++ b/src/Docfx.MarkdigEngine.Extensions/PlantUml/PlantUmlCodeBlockRenderer.cs @@ -44,9 +44,8 @@ public PlantUmlCodeBlockRenderer(MarkdownContext context, PlantUmlOptions settin protected override void Write(HtmlRenderer renderer, CodeBlock obj) { - if (obj is FencedCodeBlock fencedCodeBlock - && fencedCodeBlock.Info is string info - && info.Equals("plantuml", StringComparison.OrdinalIgnoreCase)) + if (obj is FencedCodeBlock {Info: string info} fencedCodeBlock + && info.Equals("plantuml", StringComparison.OrdinalIgnoreCase)) { IPlantUmlRenderer plantUmlRenderer = rendererFactory.CreateRenderer(_settings); diff --git a/src/Docfx.MarkdigEngine.Extensions/ResolveLink/ResolveLinkExtension.cs b/src/Docfx.MarkdigEngine.Extensions/ResolveLink/ResolveLinkExtension.cs index 2d7a45322b3..321d577d9ad 100644 --- a/src/Docfx.MarkdigEngine.Extensions/ResolveLink/ResolveLinkExtension.cs +++ b/src/Docfx.MarkdigEngine.Extensions/ResolveLink/ResolveLinkExtension.cs @@ -49,7 +49,7 @@ private void UpdateLinks(MarkdownObject markdownObject) } break; - case LeafBlock leafBlock when leafBlock.Inline != null: + case LeafBlock {Inline: not null} leafBlock: foreach (var subInline in leafBlock.Inline) { UpdateLinks(subInline); diff --git a/src/Docfx.MarkdigEngine.Extensions/Rewriter/MarkdownDocumentVisitor.cs b/src/Docfx.MarkdigEngine.Extensions/Rewriter/MarkdownDocumentVisitor.cs index 04fd32e116d..fa3e396666e 100644 --- a/src/Docfx.MarkdigEngine.Extensions/Rewriter/MarkdownDocumentVisitor.cs +++ b/src/Docfx.MarkdigEngine.Extensions/Rewriter/MarkdownDocumentVisitor.cs @@ -43,7 +43,7 @@ private void RewriteContainerBlock(ContainerBlock blocks) for (var i = 0; i < blocks.Count; i++) { var block = blocks[i]; - if (block is LeafBlock leafBlock && leafBlock.Inline != null) + if (block is LeafBlock {Inline: not null} leafBlock) { RewriteContainerInline(leafBlock.Inline); } diff --git a/src/Docfx.MarkdigEngine/MarkdigMarkdownService.cs b/src/Docfx.MarkdigEngine/MarkdigMarkdownService.cs index 46d7f5c6ebf..dcfeb4e0c57 100644 --- a/src/Docfx.MarkdigEngine/MarkdigMarkdownService.cs +++ b/src/Docfx.MarkdigEngine/MarkdigMarkdownService.cs @@ -141,7 +141,7 @@ private MarkdownPipeline CreateMarkdownPipeline(bool isInline, bool multipleYaml builder.UseInlineOnly(); } - if (_parameters?.Extensions?.MarkdigExtensions is { } extensions && extensions.Length > 0) + if (_parameters?.Extensions?.MarkdigExtensions is {Length: > 0} extensions) { builder.UseOptionalExtensions(extensions); } diff --git a/src/Docfx.YamlSerialization/NodeTypeResolvers/ScalarYamlNodeTypeResolver.cs b/src/Docfx.YamlSerialization/NodeTypeResolvers/ScalarYamlNodeTypeResolver.cs index b1e3f9c9ece..bca576600d1 100644 --- a/src/Docfx.YamlSerialization/NodeTypeResolvers/ScalarYamlNodeTypeResolver.cs +++ b/src/Docfx.YamlSerialization/NodeTypeResolvers/ScalarYamlNodeTypeResolver.cs @@ -13,7 +13,7 @@ bool INodeTypeResolver.Resolve(NodeEvent nodeEvent, ref Type currentType) { if (currentType == typeof(string) || currentType == typeof(object)) { - if (nodeEvent is Scalar scalar && scalar.IsPlainImplicit) + if (nodeEvent is Scalar {IsPlainImplicit: true} scalar) { if (Regexes.BooleanLike.IsMatch(scalar.Value)) { diff --git a/src/Docfx.YamlSerialization/ObjectFactories/DefaultEmitObjectFactory.cs b/src/Docfx.YamlSerialization/ObjectFactories/DefaultEmitObjectFactory.cs index 0b6ab897df4..300a7cf9cbb 100644 --- a/src/Docfx.YamlSerialization/ObjectFactories/DefaultEmitObjectFactory.cs +++ b/src/Docfx.YamlSerialization/ObjectFactories/DefaultEmitObjectFactory.cs @@ -18,7 +18,7 @@ public override object Create(Type type) if (!_cache.TryGetValue(type, out Func func)) { var realType = type; - if (type.IsInterface && type.IsGenericType) + if (type is {IsInterface: true, IsGenericType: true}) { var def = type.GetGenericTypeDefinition(); var args = type.GetGenericArguments();