Skip to content

Commit

Permalink
Correct writeXmlDoc.addMembers
Browse files Browse the repository at this point in the history
fixes fsharp#148
closes fsharp#184

commit a43070e2e0ffb2e4630e4e1e52632aad24d58801
Merge: 5e24472 be66b39
Author: latkin <[email protected]>
Date:   Mon Feb 2 15:40:44 2015 -0800

    Merge branch 'xml-fix' of https:/ReedCopsey/visualfsharp into ReedCopsey-xml-fix

commit be66b39debb03f5bc9cbe2630d988f9fa862b729
Author: ReedCopsey <[email protected]>
Date:   Mon Feb 2 10:47:51 2015 -0800

    Corrected UnitOfMeasure XML Tests

    These previously required there to be an empty "member" variable for the
    indices to match.  Adjusted indices to match new, correct generated XML

commit fe1ef0dda5ef1373d46998379d54f121f996cd7a
Author: ReedCopsey <[email protected]>
Date:   Fri Jan 30 17:32:28 2015 -0800

    Added Basic\xmlDoc005.fs test

    To check that no empty members are generated.

commit 5450b68e9d1b518f79e74441433c4078956cbd0c
Author: ReedCopsey <[email protected]>
Date:   Fri Jan 30 13:58:43 2015 -0800

    Correct writeXmlDoc.addMembers

    Prevent members from being added to the global member list when the
    xmlDoc contains no content.
  • Loading branch information
ReedCopsey authored and latkin committed Feb 3, 2015
1 parent 5e24472 commit 6739420
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 17 deletions.
5 changes: 3 additions & 2 deletions src/fsharp/fsc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,9 @@ module XmlDocWriter =
(* the xmlDocSigOf* functions encode type into string to be used in "id" *)
let members = ref []
let addMember id xmlDoc =
let doc = getDoc xmlDoc
members := (id,doc) :: !members
if hasDoc xmlDoc then
let doc = getDoc xmlDoc
members := (id,doc) :: !members
let doVal (v:Val) = addMember v.XmlDocSig v.XmlDoc
let doUnionCase (uc:UnionCase) = addMember uc.XmlDocSig uc.XmlDoc
let doField (rf:RecdField) = addMember rf.XmlDocSig rf.XmlDoc
Expand Down
1 change: 1 addition & 0 deletions tests/fsharpqa/Source/XmlDoc/Basic/env.lst
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
SOURCE=xmlDoc002.fs SCFLAGS="-r:System.Xml.dll --doc:xmlDoc002.xml --define:WITHXMLVERIFICATION" # xmlDoc002.fs
SOURCE=xmlDoc003.fs SCFLAGS="-r:System.Xml.dll --doc:xmlDoc003.xml --define:WITHXMLVERIFICATION" # xmlDoc003.fs
SOURCE=xmlDoc004.fs SCFLAGS="-r:System.Xml.dll --doc:xmlDoc004.xml --define:WITHXMLVERIFICATION" # xmlDoc004.fs
SOURCE=xmlDoc005.fs SCFLAGS="-r:System.Xml.dll --doc:xmlDoc005.xml --define:WITHXMLVERIFICATION" # xmlDoc005.fs
SOURCE=XMLDocOnEnum01.fs SCFLAGS="-r:System.Xml.dll --doc:XMLDocOnEnum01.xml --define:WITHXMLVERIFICATION" # XMLDocOnEnum01.fs

49 changes: 49 additions & 0 deletions tests/fsharpqa/Source/XmlDoc/Basic/xmlDoc005.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// #Regression #XMLDoc
// Verify that XmlDoc names are generated, but no empty members are generated re: issue #148
//<Expects status=success></Expects>

#light

namespace MyRather.MyDeep.MyNamespace
open System.Xml

/// class1
type Class1() =
/// x
member this.X = "X"

type Class2() =
member this.Y = "Y"

///testModule
module MyModule =

let check (xml:XmlDocument) name xmlDoc =
let foundDoc = ((xml.SelectSingleNode ("/doc/members/member[@name='" + name + "']")).SelectSingleNode "summary").InnerText.Trim()
if xmlDoc <> foundDoc then
printfn "%s: generated xmlDoc <%s> differs from excpected <%s>" name foundDoc xmlDoc
xmlDoc = foundDoc

let hasEmptyMembers (xml:XmlDocument) =
let node = xml.SelectSingleNode ("/doc/members/member[@name='']")
if node <> null then
printfn "Empty member name entries found."
node <> null

let test =
let myname = System.Reflection.Assembly.GetExecutingAssembly().Location
let xmlname = System.IO.Path.ChangeExtension(myname, "xml")


#if WITHXMLVERIFICATION
let xml = new XmlDocument()
xml.Load xmlname
if check xml "P:MyRather.MyDeep.MyNamespace.Class1.X" "x"
&& check xml "T:MyRather.MyDeep.MyNamespace.Class1" "class1"
&& not(hasEmptyMembers xml)
then 0 else 1
#else
0
#endif

test |> exit
24 changes: 16 additions & 8 deletions tests/fsharpqa/Source/XmlDoc/UnitOfMeasure/UnitOfMeasure01.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,24 @@ let test =
xml.Load(xmlname)

let a1 = xml.GetElementsByTagName("summary").Item(0).FirstChild.Value = "This is B"
if not a1 then printfn "a1: expected: This is B"; exit 1
if not a1 then
printfn "a1: expected: This is B"
exit 1

let a2 = xml.GetElementsByTagName("summary").Item(1).FirstChild.Value = "This is A"
if not a2 then printfn "a2: expected: This is A"; exit 1

let a3 = xml.GetElementsByTagName("member").Item(1).Attributes.Item(0).Value = "M:UnitOfMeasure01.B(System.Single)"
if not a3 then printfn "a3: expected: M:UnitOfMeasure01.B(System.Single)"; exit 1

let a4 = xml.GetElementsByTagName("member").Item(2).Attributes.Item(0).Value = "M:UnitOfMeasure01.A(System.Double)"
if not a4 then printfn "a4: expected: M:UnitOfMeasure01.A(System.Double)"; exit 1
if not a2 then
printfn "a2: expected: This is A"
exit 1

let a3 = xml.GetElementsByTagName("member").Item(0).Attributes.Item(0).Value = "M:UnitOfMeasure01.B(System.Single)"
if not a3 then
printfn "a3: expected: M:UnitOfMeasure01.B(System.Single)"
exit 1

let a4 = xml.GetElementsByTagName("member").Item(1).Attributes.Item(0).Value = "M:UnitOfMeasure01.A(System.Double)"
if not a4 then
printfn "a4: expected: M:UnitOfMeasure01.A(System.Double)"
exit 1
#endif
0

Expand Down
22 changes: 15 additions & 7 deletions tests/fsharpqa/Source/XmlDoc/UnitOfMeasure/UnitOfMeasure02.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,24 @@ let test =
xml.Load(xmlname)

let a1 = xml.GetElementsByTagName("summary").Item(0).FirstChild.Value = "This is B"
if not a1 then printfn "a1: expected: This is B"; exit 1
if not a1 then
printfn "a1: expected: This is B"
exit 1

let a2 = xml.GetElementsByTagName("summary").Item(1).FirstChild.Value = "This is A"
if not a2 then printfn "a2: expected: This is A"; exit 1
if not a2 then
printfn "a2: expected: This is A"
exit 1

let a3 = xml.GetElementsByTagName("member").Item(1).Attributes.Item(0).Value = "M:UnitOfMeasure02.B(System.Int32,System.Int32)"
if not a3 then printfn "a3: expected: M:UnitOfMeasure02.B(System.Int32,System.Int32)"; exit 1

let a4 = xml.GetElementsByTagName("member").Item(2).Attributes.Item(0).Value = "M:UnitOfMeasure02.A(System.Double)"
if not a4 then printfn "a4: expected: M:UnitOfMeasure02.A(System.Double)"; exit 1
let a3 = xml.GetElementsByTagName("member").Item(0).Attributes.Item(0).Value = "M:UnitOfMeasure02.B(System.Int32,System.Int32)"
if not a3 then
printfn "a3: expected: M:UnitOfMeasure02.B(System.Int32,System.Int32)"
exit 1

let a4 = xml.GetElementsByTagName("member").Item(1).Attributes.Item(0).Value = "M:UnitOfMeasure02.A(System.Double)"
if not a4 then
printfn "a4: expected: M:UnitOfMeasure02.A(System.Double)"
exit 1
#endif
0

Expand Down

0 comments on commit 6739420

Please sign in to comment.