Skip to content

Commit

Permalink
added support for C# fixes fsprojects#180.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthid committed Oct 5, 2014
1 parent 1feb3f5 commit bc9db35
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/FSharp.MetadataFormat/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,19 @@ module ValueReader =
match x.XmlMemberMap.TryGetValue(key) with
| true, v -> Some v
| _ -> None
static member private ToReplace =
([(".", "-"); ("`", "-"); ("<", "_"); (">", "_")] @
(Path.GetInvalidPathChars()
|> Seq.append (Path.GetInvalidFileNameChars())
|> Seq.map (fun inv -> (inv.ToString(), "_")) |> Seq.toList))
|> Seq.distinctBy fst
|> Seq.toList
static member Create(publicOnly, map, sourceFolderRepo, urlRangeHighlight, markDownComments) =
let usedNames = Dictionary<_, _>()
let nameGen (name:string) =
let nice = name.Replace(".", "-").Replace("`", "-").ToLower()
let nice = (ReadingContext.ToReplace
|> Seq.fold (fun (s:string) (inv, repl) -> s.Replace(inv, repl)) name)
.ToLower()
let found =
seq { yield nice
for i in Seq.initInfinite id do yield sprintf "%s-%d" nice i }
Expand Down Expand Up @@ -568,7 +577,14 @@ module Reader =
|> List.ofSeq

let tryReadMember (ctx:ReadingContext) kind (memb:FSharpMemberFunctionOrValue) =
readCommentsInto ctx memb.XmlDocSig (fun cat _ comment ->
let xmlSig =
if memb.XmlDocSig = ""
then // support for C# member
let memberType = if memb.IsProperty then "P" else "M"
sprintf "%s:%s" memberType memb.FullName
else
memb.XmlDocSig
readCommentsInto ctx xmlSig (fun cat _ comment ->
Member.Create(memb.DisplayName, kind, cat, readMemberOrVal ctx memb, comment))

let readAllMembers ctx kind (members:seq<FSharpMemberFunctionOrValue>) =
Expand Down Expand Up @@ -649,7 +665,11 @@ module Reader =
let xmlDocSig =
if typ.XmlDocSig = "" && typ.XmlDoc.Count > 0 && typ.IsProvided
then registerTypeProviderXmlDocs ctx typ
else typ.XmlDocSig
else if typ.XmlDocSig = ""
then // support for C# types
sprintf "T:%s" typ.FullName
else
typ.XmlDocSig
readCommentsInto ctx xmlDocSig (fun cat cmds comment ->
let urlName = ctx.UniqueUrlName (sprintf "%s.%s" typ.AccessPath typ.CompiledName)

Expand Down

0 comments on commit bc9db35

Please sign in to comment.