Skip to content

Commit

Permalink
handle possible exceptions while processing members.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthid committed Oct 5, 2014
1 parent e42ee62 commit 866b3cf
Showing 1 changed file with 46 additions and 42 deletions.
88 changes: 46 additions & 42 deletions src/FSharp.MetadataFormat/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -587,49 +587,53 @@ module Reader =
not memb.IsEventAddMethod && not memb.IsEventRemoveMethod &&
not memb.IsPropertyGetterMethod && not memb.IsPropertySetterMethod
then // support for C# member
let membFullName =
// because of generics (memb.FullName is not a correct xmlsig in this case)...
sprintf "%s.%s" (memb.EnclosingEntity.FullName) memb.CompiledName
let memberType, sigName =
if memb.IsEvent then "E", membFullName
elif memb.IsProperty then "P", membFullName
else
let name = membFullName.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 ""
try
let membFullName =
// because of generics (memb.FullName is not a correct xmlsig in this case)...
sprintf "%s.%s" (memb.EnclosingEntity.FullName) memb.CompiledName
let memberType, sigName =
if memb.IsEvent then "E", membFullName
elif memb.IsProperty then "P", membFullName
else
let name = membFullName.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 ""
let fullname = sprintf "%s%s%s" name typeargs paramList
"M", fullname
sprintf "%s:%s" memberType sigName
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 ""
let fullname = sprintf "%s%s%s" name typeargs paramList
"M", fullname
sprintf "%s:%s" memberType sigName
with exn ->
printfn "Ignoring member %s because: %s" memb.FullName exn.Message
""
else
memb.XmlDocSig
readCommentsInto ctx xmlSig (fun cat _ comment ->
Expand Down

0 comments on commit 866b3cf

Please sign in to comment.