From 771b43026ec6c7e3349d0f60dc7e9332aec3f335 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sun, 20 Sep 2015 20:58:00 +0200 Subject: [PATCH] General stabilization. Ignore when we cannot handle a module, type or a single member and write an error, workaround for #271 (and future FCS bugs). --- src/FSharp.MetadataFormat/Main.fs | 21 ++++++++++++------- .../files/csharpSupport/SampleClass.cs | 13 +++++++++++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/FSharp.MetadataFormat/Main.fs b/src/FSharp.MetadataFormat/Main.fs index 170753cc1..6dadfb985 100644 --- a/src/FSharp.MetadataFormat/Main.fs +++ b/src/FSharp.MetadataFormat/Main.fs @@ -790,12 +790,17 @@ module Reader = /// Reads XML documentation comments and calls the specified function /// to parse the rest of the entity, unless [omit] command is set. /// The function is called with category name, commands & comment. - let readCommentsInto ctx xmlDoc f = + let readCommentsInto name ctx xmlDoc f = let cmds, comment = readCommentAndCommands ctx xmlDoc match cmds with | Command "omit" _ -> None | Command "category" cat - | Let "" (cat, _) -> Some(f cat cmds comment) + | Let "" (cat, _) -> + try + Some(f cat cmds comment) + with e -> + Log.errorf "Could read comments from entity '%s': %O" name e + None let checkAccess ctx (access: FSharpAccessibility) = not ctx.PublicOnly || access.IsPublic @@ -809,7 +814,7 @@ module Reader = |> List.ofSeq let tryReadMember (ctx:ReadingContext) kind (memb:FSharpMemberOrFunctionOrValue) = - readCommentsInto ctx (getXmlDocSigForMember memb) (fun cat _ comment -> + readCommentsInto memb.FullName ctx (getXmlDocSigForMember memb) (fun cat _ comment -> Member.Create(memb.DisplayName, kind, cat, readMemberOrVal ctx memb, comment)) let readAllMembers ctx kind (members:seq) = @@ -837,7 +842,7 @@ module Reader = |> List.ofSeq |> List.filter (fun v -> checkAccess ctx v.Accessibility) |> List.choose (fun case -> - readCommentsInto ctx case.XmlDocSig (fun cat _ comment -> + readCommentsInto case.FullName ctx case.XmlDocSig (fun cat _ comment -> Member.Create(case.Name, MemberKind.UnionCase, cat, readUnionCase ctx case, comment))) let readRecordFields ctx (typ:FSharpEntity) = @@ -845,14 +850,14 @@ module Reader = |> List.ofSeq |> List.filter (fun field -> not field.IsCompilerGenerated) |> List.choose (fun field -> - readCommentsInto ctx field.XmlDocSig (fun cat _ comment -> + readCommentsInto field.FullName ctx field.XmlDocSig (fun cat _ comment -> Member.Create(field.Name, MemberKind.RecordField, cat, readFSharpField ctx field, comment))) let readStaticParams ctx (typ:FSharpEntity) = typ.StaticParameters |> List.ofSeq |> List.choose (fun staticParam -> - readCommentsInto ctx (getFSharpStaticParamXmlSig typ staticParam.Name) (fun cat _ comment -> + readCommentsInto staticParam.FullName ctx (getFSharpStaticParamXmlSig typ staticParam.Name) (fun cat _ comment -> Member.Create(staticParam.Name, MemberKind.StaticParameter, cat, readFSharpStaticParam ctx staticParam, comment))) // ---------------------------------------------------------------------------------------------- @@ -890,7 +895,7 @@ module Reader = if typ.IsProvided && typ.XmlDoc.Count > 0 then registerTypeProviderXmlDocs ctx typ let xmlDocSig = getXmlDocSigForType typ - readCommentsInto ctx xmlDocSig (fun cat cmds comment -> + readCommentsInto typ.FullName ctx xmlDocSig (fun cat cmds comment -> let urlName = ctx.UrlMap.GetUrl typ let rec getMembers (typ:FSharpEntity) = [ @@ -941,7 +946,7 @@ module Reader = ( name, cat, urlName, comment, ctx.Assembly, cases, fields, statParams, ctors, inst, stat )) and readModule (ctx:ReadingContext) (modul:FSharpEntity) = - readCommentsInto ctx modul.XmlDocSig (fun cat cmd comment -> + readCommentsInto modul.FullName ctx modul.XmlDocSig (fun cat cmd comment -> // Properties & value bindings in the module let urlName = ctx.UrlMap.GetUrl modul diff --git a/tests/FSharp.MetadataFormat.Tests/files/csharpSupport/SampleClass.cs b/tests/FSharp.MetadataFormat.Tests/files/csharpSupport/SampleClass.cs index abac5f103..b9dd04911 100644 --- a/tests/FSharp.MetadataFormat.Tests/files/csharpSupport/SampleClass.cs +++ b/tests/FSharp.MetadataFormat.Tests/files/csharpSupport/SampleClass.cs @@ -125,6 +125,17 @@ private void PrivateMethod() { } /// /// My_Private_Event /// - private event EventHandler PrivateEvent; + private event EventHandler PrivateEvent; + + /// + /// Event triggered when WorklistText is required + /// + public delegate void WorklistTextRequested(int medicalRecordId, string accessionNo, + int templateId, string specificationCode, string specificationText, string aeTitle); + + /// + /// Some Event with its own delegate + /// + public event WorklistTextRequested OnWorklistTextRequested; } }