From 33432ec51add295c511e8f8266eea4e39b1ce1b1 Mon Sep 17 00:00:00 2001 From: Antyipin Artyom Date: Tue, 29 Dec 2015 10:41:52 +0100 Subject: [PATCH 1/4] Add CompliedName to MemberOrValue --- src/FSharp.MetadataFormat/Main.fs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/FSharp.MetadataFormat/Main.fs b/src/FSharp.MetadataFormat/Main.fs index dec1b019b..d435fac45 100755 --- a/src/FSharp.MetadataFormat/Main.fs +++ b/src/FSharp.MetadataFormat/Main.fs @@ -29,14 +29,16 @@ type MemberOrValue = Modifiers : string list TypeArguments : string list Signature : string - SourceLocation : string option } + SourceLocation : string option + CompiledName : string option } member x.FormatUsage(maxLength) = x.Usage(maxLength) member x.FormatTypeArguments = String.concat ", " x.TypeArguments member x.FormatModifiers = String.concat " " x.Modifiers member x.FormatSourceLocation = defaultArg x.SourceLocation "" - static member Create(usage, mods, typars, sign, location) = + member x.FormatCompiledName = defaultArg x.CompiledName "" + static member Create(usage, mods, typars, sign, location, compiledName) = { Usage = usage; Modifiers = mods; TypeArguments = typars; - Signature = sign; SourceLocation = location } + Signature = sign; SourceLocation = location; CompiledName = compiledName } type MemberKind = // In a module @@ -190,6 +192,12 @@ module ValueReader = CompilerOptions = compilerOptions FormatAgent = formatAgent } + let inline private getCompiledName (s : ^a when ^a :> FSharpSymbol) = + let compiledName = (^a : (member CompiledName : string) (s)) + match compiledName = s.DisplayName with + | true -> None + | _ -> Some compiledName + let formatSourceLocation (urlRangeHighlight : Uri -> int -> int -> string) (sourceFolderRepo : (string * string) option) (location : range option) = location |> Option.bind (fun location -> sourceFolderRepo |> Option.map (fun (baseFolder, repo) -> @@ -408,7 +416,7 @@ module ValueReader = // If there is a signature file, we should go for implementation file let loc = tryGetLocation v let location = formatSourceLocation ctx.UrlRangeHighlight ctx.SourceFolderRepository loc - MemberOrValue.Create(buildShortUsage, modifiers, typars, signature, location) + MemberOrValue.Create(buildShortUsage, modifiers, typars, signature, location, getCompiledName v) (* @@ -462,7 +470,7 @@ module ValueReader = let signature = fields |> List.map (fun field -> formatType field.FieldType) |> String.concat " * " let loc = tryGetLocation case let location = formatSourceLocation ctx.UrlRangeHighlight ctx.SourceFolderRepository loc - MemberOrValue.Create(usage, modifiers, typeparams, signature, location) + MemberOrValue.Create(usage, modifiers, typeparams, signature, location, getCompiledName case) let readFSharpField (ctx:ReadingContext) (field:FSharpField) = let usage (maxLength:int) = field.Name @@ -473,7 +481,7 @@ module ValueReader = let signature = formatType field.FieldType let loc = tryGetLocation field let location = formatSourceLocation ctx.UrlRangeHighlight ctx.SourceFolderRepository loc - MemberOrValue.Create(usage, modifiers, typeparams, signature, location) + MemberOrValue.Create(usage, modifiers, typeparams, signature, location, if field.Name <> field.DisplayName then Some field.Name else None) let getFSharpStaticParamXmlSig (typeProvider:FSharpEntity) parameterName = "SP:" + typeProvider.AccessPath + "." + typeProvider.LogicalName + "." + parameterName @@ -485,7 +493,7 @@ module ValueReader = let signature = formatType staticParam.Kind + (if staticParam.IsOptional then sprintf " (optional, default = %A)" staticParam.DefaultValue else "") let loc = tryGetLocation staticParam let location = formatSourceLocation ctx.UrlRangeHighlight ctx.SourceFolderRepository loc - MemberOrValue.Create(usage, modifiers, typeparams, signature, location) + MemberOrValue.Create(usage, modifiers, typeparams, signature, location, if staticParam.Name <> staticParam.DisplayName then Some staticParam.Name else None) module Reader = open FSharp.Markdown From de4d80dafdeaba928c4891eb3a09b9203d2faccb Mon Sep 17 00:00:00 2001 From: Antyipin Artyom Date: Tue, 29 Dec 2015 10:49:11 +0100 Subject: [PATCH 2/4] Update template to display CompiledName --- misc/templates/reference/part-members.cshtml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/misc/templates/reference/part-members.cshtml b/misc/templates/reference/part-members.cshtml index 590a25160..95ba93ce0 100644 --- a/misc/templates/reference/part-members.cshtml +++ b/misc/templates/reference/part-members.cshtml @@ -32,9 +32,13 @@ } @it.Comment.FullText + @if (!String.IsNullOrEmpty(it.Details.FormatCompiledName)) + { + @:

CompiledName: @it.Details.FormatCompiledName

+ } } -} \ No newline at end of file +} From d80a5162eddecaf17368e730e98832084c46e452 Mon Sep 17 00:00:00 2001 From: Antyipin Artyom Date: Tue, 29 Dec 2015 11:13:19 +0100 Subject: [PATCH 3/4] Make template more consistent --- misc/templates/reference/part-members.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/templates/reference/part-members.cshtml b/misc/templates/reference/part-members.cshtml index 95ba93ce0..624798b76 100644 --- a/misc/templates/reference/part-members.cshtml +++ b/misc/templates/reference/part-members.cshtml @@ -34,7 +34,7 @@ @it.Comment.FullText @if (!String.IsNullOrEmpty(it.Details.FormatCompiledName)) { - @:

CompiledName: @it.Details.FormatCompiledName

+ @:

CompiledName: @it.Details.FormatCompiledName

} From 1fa78aba1e9c5f1b25d2450900fcdbef169be781 Mon Sep 17 00:00:00 2001 From: Antyipin Artyom Date: Tue, 29 Dec 2015 13:45:58 +0100 Subject: [PATCH 4/4] Fix broken whitespace. --- misc/templates/reference/part-members.cshtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/misc/templates/reference/part-members.cshtml b/misc/templates/reference/part-members.cshtml index 624798b76..2a5ffcdf0 100644 --- a/misc/templates/reference/part-members.cshtml +++ b/misc/templates/reference/part-members.cshtml @@ -33,9 +33,9 @@ } @it.Comment.FullText @if (!String.IsNullOrEmpty(it.Details.FormatCompiledName)) - { - @:

CompiledName: @it.Details.FormatCompiledName

- } + { + @:

CompiledName: @it.Details.FormatCompiledName

+ } }