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

C# support (suggestion) #208

Merged
merged 2 commits into from
Dec 30, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions src/FSharp.MetadataFormat/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,53 @@ module Reader =
| n , _ -> n

let getMemberXmlDocsSigPrefix (memb:FSharpMemberFunctionOrValue) =
if memb.IsProperty then "P" else "M"
if memb.IsEvent then "E"
elif memb.IsProperty then "P"
else "M"

let getXmlDocSigForMember (memb:FSharpMemberFunctionOrValue) =
let memberName =
try
let name = memb.CompiledName.Replace(".ctor", "#ctor")
let typeGenericParameters =
memb.EnclosingEntity.GenericParameters |> Seq.mapi (fun num par -> par.Name, sprintf "`%d" num)
let methodGenericParameters =
memb.GenericParameters |> Seq.mapi (fun num par -> par.Name, sprintf "``%d" num)
let typeArgsMap =
Seq.append methodGenericParameters typeGenericParameters
|> Seq.groupBy fst
|> Seq.map (fun (name, grp) -> grp |> Seq.head)
|> dict
let typeargs =
if memb.GenericParameters.Count > 0
then sprintf "``%d" memb.GenericParameters.Count
else ""

let paramList =
if memb.CurriedParameterGroups.Count > 0 && memb.CurriedParameterGroups.[0].Count > 0
then
let head = memb.CurriedParameterGroups.[0]
let paramTypeList =
head
|> Seq.map (fun param ->
if param.Type.IsGenericParameter then
typeArgsMap.[param.Type.GenericParameter.Name]
else
let rec reduceAbb (t:FSharpType) =
if t.IsAbbreviation
then reduceAbb t.AbbreviatedType
else t
let paramType = reduceAbb param.Type
paramType.TypeDefinition.FullName)
"(" + System.String.Join(",", paramTypeList) + ")"
else ""
sprintf "%s%s%s" name typeargs paramList
with exn ->
Log.logf "Error while building member-name for %s because: %s" memb.FullName exn.Message
memb.CompiledName
match (memb.XmlDocSig, memb.EnclosingEntity.TryFullName) with
| "", None -> ""
| "", Some(n) -> sprintf "%s:%s.%s" (getMemberXmlDocsSigPrefix memb) n memb.CompiledName
| "", Some(n) -> sprintf "%s:%s.%s" (getMemberXmlDocsSigPrefix memb) n memberName
| n, _ -> n

//
Expand Down Expand Up @@ -692,6 +733,10 @@ module Reader =
|> List.ofSeq
|> List.filter (fun v -> checkAccess ctx v.Accessibility)
|> List.filter (fun v -> not v.IsCompilerGenerated)
|> List.filter (fun v ->
if v.EnclosingEntity.IsFSharp then true else
not v.IsEventAddMethod && not v.IsEventRemoveMethod &&
not v.IsPropertyGetterMethod && not v.IsPropertySetterMethod)
|> List.partition (fun v -> v.IsInstanceMember)
let cvals, svals = svals |> List.partition (fun v -> v.CompiledName = ".ctor")

Expand Down