Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fsdocs cannot load XML generated by MSBuild #707

Closed
sergey-tihon opened this issue Sep 21, 2021 · 5 comments
Closed

fsdocs cannot load XML generated by MSBuild #707

sergey-tihon opened this issue Sep 21, 2021 · 5 comments

Comments

@sergey-tihon
Copy link
Member

During the migration of FSharpx.Collection to latest version of fsdocs I found that following xml comment

    interface IEnumerable<byte> with
        /// Gets an enumerator for the bytes stored in the byte string.
        member this.GetEnumerator() = this.GetEnumerator()

    interface IEnumerable with
        /// Gets an enumerator for the bytes stored in the byte string.
        member this.GetEnumerator() = this.GetEnumerator() :> IEnumerator

generate xml docs that fsdocs cannot parse

it fails with error

API docs:
  generating model for 1 assemblies in API docs...
  loading 1 assemblies...
isNetCoreApp = true
  registering entities for assembly Lib...
  reading XML doc for /Users/sergey/github/fsdocs-generic-params/src/Lib/bin/Debug/netstandard2.0/Lib.dll...
  reading assembly data for /Users/sergey/github/fsdocs-generic-params/src/Lib/bin/Debug/netstandard2.0/Lib.dll...
Error : 
System.Xml.XmlException: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 10, position 86.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
   at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
   at System.Xml.XmlTextReaderImpl.ParseAttributes()
   at System.Xml.XmlTextReaderImpl.ParseElement()
   at System.Xml.XmlTextReaderImpl.ParseElementContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
   at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
   at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)
   at FSharp.Formatting.ApiDocs.SymbolReader.readAssembly(FSharpAssembly assembly, Boolean publicOnly, String xmlFile, FSharpList`1 substitutions, FSharpOption`1 sourceFolderRepo, FSharpFunc`2 urlRangeHighlight, Boolean mdcomments, CrossReferenceResolver urlMap, String codeFormatCompilerArgs, Boolean warn) in /home/runner/work/FSharp.Formatting/FSharp.Formatting/src/FSharp.Formatting.ApiDocs/GenerateModel.fs:line 2028
   at <StartupCode$FSharp-Formatting-ApiDocs>[email protected](Tuple`2 tupledArg) in /home/runner/work/FSharp.Formatting/FSharp.Formatting/src/FSharp.Formatting.ApiDocs/GenerateModel.fs:line 2226
   at Microsoft.FSharp.Primitives.Basics.List.choose[T,TResult](FSharpFunc`2 f, FSharpList`1 xs) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 189
   at FSharp.Formatting.ApiDocs.ApiDocModel.Generate(FSharpList`1 projects, String collectionName, FSharpOption`1 libDirs, FSharpOption`1 otherFlags, Boolean qualify, FSharpOption`1 urlRangeHighlight, String root, FSharpList`1 substitutions, Boolean strict, ApiDocFileExtensions extensions) in /home/runner/work/FSharp.Formatting/FSharp.Formatting/src/FSharp.Formatting.ApiDocs/GenerateModel.fs:line 2180
   at FSharp.Formatting.ApiDocs.ApiDocs.GenerateHtmlPhased[b](FSharpList`1 inputs, String output, String collectionName, FSharpList`1 substitutions, FSharpOption`1 template, FSharpOption`1 root, FSharpOption`1 qualify, FSharpOption`1 libDirs, FSharpOption`1 otherFlags, FSharpOption`1 urlRangeHighlight, FSharpOption`1 strict) in /home/runner/work/FSharp.Formatting/FSharp.Formatting/src/FSharp.Formatting.ApiDocs/ApiDocs.fs:line 62
   at <StartupCode$fsdocs>[email protected](Unit unitVar0) in /home/runner/work/FSharp.Formatting/FSharp.Formatting/src/FSharp.Formatting.CommandTool/BuildCommand.fs:line 646
   at <StartupCode$fsdocs>.$BuildCommand.protect@388(CoreBuildOptions this, String phase, FSharpFunc`2 f) in /home/runner/work/FSharp.Formatting/FSharp.Formatting/src/FSharp.Formatting.CommandTool/BuildCommand.fs:line 390

here is minimal repo - https://github.com/sergey-tihon/fsdocs-generic-params

@dsyme
Copy link
Contributor

dsyme commented Sep 21, 2021

This looks like an F# compiler bug. Could you paste in the XML at this line please?

System.Xml.XmlException: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 10, position 86.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)

@sergey-tihon
Copy link
Member Author

Line 10

<member name="M:FSharpx.Collections.ByteString.System.Collections.Generic.IEnumerable<System.Byte>.GetEnumerator">

@dsyme
Copy link
Contributor

dsyme commented Sep 22, 2021

I see, thanks, yes this is an F# compiler issue, using the wrong name (or not escaping it). Ideally it should not be emitting these in docs at all.

In the meantime don't put /// on such members, just //

@sergey-tihon
Copy link
Member Author

sergey-tihon commented Sep 22, 2021

Thank you, I did exactly this during migration
https://github.com/fsprojects/FSharpx.Collections/blob/master/src/FSharpx.Collections/ByteString.fs#L94-L100

but then decided to report the issue.

It is rare, but can affect others. Should I open issue in dotnet/fsharp repo?

@dsyme
Copy link
Contributor

dsyme commented Sep 22, 2021

dotnet/fsharp#12177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants