@@ -33,7 +33,7 @@ module private Section =
3333 content
3434 |> Seq.map ( fun kv ->
3535 let text =
36- if kv.Value.Contains( " \n " ) then
36+ if kv.Value.Contains '\n' then
3737 kv.Value.Split( '\n' )
3838 |> Seq.map ( fun line -> " > " + line.TrimStart())
3939 |> String.concat Environment.NewLine
@@ -453,6 +453,8 @@ module private Format =
453453 text
454454
455455
456+ let private thsPattern = Regex " <th\s ?>"
457+
456458 let private convertTable =
457459 { TagName = " table"
458460 Formatter =
@@ -461,7 +463,7 @@ module private Format =
461463
462464 | NonVoidElement( innerText, _) ->
463465
464- let rowCount = Regex .Matches( innerText, " <th \s ?> " ). Count
466+ let rowCount = thsPattern .Matches( innerText). Count
465467
466468 let convertedTable =
467469 innerText
@@ -488,6 +490,7 @@ module private Format =
488490 type private Term = string
489491 type private Definition = string
490492
493+ [<Struct>]
491494 type private ListStyle =
492495 | Bulleted
493496 | Numbered
@@ -535,8 +538,10 @@ module private Format =
535538
536539 let tryGetTerm ( text : string ) = tryGetInnerTextOnNonVoidElement text " term"
537540
541+ let itmPattern = Regex( tagPattern " item" , RegexOptions.IgnoreCase)
542+
538543 let rec extractItemList ( res : ItemList list ) ( text : string ) =
539- match Regex .Match( text , tagPattern " item " , RegexOptions.IgnoreCase ) with
544+ match itmPattern .Match text with
540545 | m when m.Success ->
541546 let newText = text.Substring( m.Value.Length)
542547
@@ -559,8 +564,10 @@ module private Format =
559564 extractItemList res newText
560565 | _ -> res
561566
567+ let listHeader = Regex( tagPattern " listheader" , RegexOptions.IgnoreCase)
568+
562569 let rec extractColumnHeader ( res : string list ) ( text : string ) =
563- match Regex .Match( text , tagPattern " listheader " , RegexOptions.IgnoreCase ) with
570+ match listHeader .Match text with
564571 | m when m.Success ->
565572 let newText = text.Substring( m.Value.Length)
566573
@@ -580,9 +587,10 @@ module private Format =
580587 extractColumnHeader res newText
581588 | _ -> res
582589
590+ let itemPattern = Regex( tagPattern " item" , RegexOptions.IgnoreCase)
583591
584592 let rec extractRowsForTable ( res : ( string list ) list ) ( text : string ) =
585- match Regex .Match( text , tagPattern " item " , RegexOptions.IgnoreCase ) with
593+ match itemPattern .Match text with
586594 | m when m.Success ->
587595 let newText = text.Substring( m.Value.Length)
588596
@@ -707,7 +715,7 @@ module private Format =
707715 |> handleMicrosoftOrList
708716 |> unescapeSpecialCharacters
709717
710- [<RequireQualifiedAccess>]
718+ [<RequireQualifiedAccess; Struct >]
711719type FormatCommentStyle =
712720 | Legacy
713721 | FullEnhanced
@@ -907,9 +915,11 @@ let private findLocalizedXmlFile (xmlFile: string) =
907915
908916 findCultures System.Globalization.CultureInfo.CurrentUICulture
909917 |> List.map ( fun culture -> Path.Combine( path, culture, xmlName))
910- |> List.tryFind ( fun i -> File.Exists i )
918+ |> List.tryFind File.Exists
911919 |> Option.defaultValue xmlFile
912920
921+ let pPattern = Regex """ (<p .*?>)+(.*)(<\/?p>)*"""
922+
913923let private getXmlDoc dllFile =
914924 let xmlFile = Path.ChangeExtension( dllFile, " .xml" )
915925 //Workaround for netstandard.dll
@@ -925,9 +935,9 @@ let private getXmlDoc dllFile =
925935
926936 let xmlFile = findLocalizedXmlFile xmlFile
927937
928- if xmlDocCache.ContainsKey xmlFile then
929- Some xmlDocCache .[ xmlFile ]
930- else
938+ match xmlDocCache.TryGetValue xmlFile with
939+ | true , cachedXmlFile -> Some cachedXmlFile
940+ | false , _ ->
931941 let rec exists filePath tryAgain =
932942 match File.Exists filePath, tryAgain with
933943 | true , _ -> Some filePath
@@ -948,7 +958,7 @@ let private getXmlDoc dllFile =
948958 //Workaround for netstandard xmlDoc
949959 let cnt =
950960 if actualXmlFile.Contains " netstandard.xml" then
951- let cnt = Regex .Replace( cnt, """ (<p .*?>)+(.*)(<\/?p>)* """ , " $2" )
961+ let cnt = pPattern .Replace( cnt, " $2" )
952962
953963 cnt.Replace( " <p>" , " " ) .Replace( " </p>" , " " ) .Replace( " <br>" , " " )
954964 else
@@ -995,7 +1005,7 @@ let private tryGetXmlDocMember (xmlDoc: FSharpXmlDoc) =
9951005 let rec findIndentationSize ( lines : string list ) =
9961006 match lines with
9971007 | head :: tail ->
998- let lesserThanIndex = head.IndexOf( " < " , StringComparison.Ordinal)
1008+ let lesserThanIndex = head.IndexOf( '<' , StringComparison.Ordinal)
9991009
10001010 if lesserThanIndex <> - 1 then
10011011 lesserThanIndex
@@ -1012,8 +1022,10 @@ let private tryGetXmlDocMember (xmlDoc: FSharpXmlDoc) =
10121022
10131023 | FSharpXmlDoc.FromXmlFile( dllFile, memberName) ->
10141024 match getXmlDoc dllFile with
1015- | Some doc when doc.ContainsKey memberName -> TryGetXmlDocMemberResult.Some doc.[ memberName]
1016-
1025+ | Some doc ->
1026+ match doc.TryGetValue memberName with
1027+ | true , docmember -> TryGetXmlDocMemberResult.Some docmember
1028+ | false , _ -> TryGetXmlDocMemberResult.None
10171029 | _ -> TryGetXmlDocMemberResult.None
10181030
10191031 | FSharpXmlDoc.None -> TryGetXmlDocMemberResult.None
0 commit comments