Skip to content

Commit

Permalink
Indent internal records type definitions. (dotnet#13798)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Aug 30, 2022
1 parent b3219dd commit 7c81ac0
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 39 deletions.
18 changes: 12 additions & 6 deletions src/Compiler/Checking/NicePrint.fs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ module PrintTypes =
| Const.Zero -> tagKeyword(if isRefTy g ty then "null" else "default")
wordL str

let layoutAccessibility (denv: DisplayEnv) accessibility itemL =
let layoutAccessibilityCore (denv: DisplayEnv) accessibility =
let isInternalCompPath x =
match x with
| CompPath(ILScopeRef.Local, []) -> true
Expand All @@ -491,10 +491,13 @@ module PrintTypes =
| _ when List.forall isInternalCompPath p -> Internal
| _ -> Private
match denv.contextAccessibility, accessibility with
| Public, Internal -> WordL.keywordInternal ++ itemL // print modifier, since more specific than context
| Public, Private -> WordL.keywordPrivate ++ itemL // print modifier, since more specific than context
| Internal, Private -> WordL.keywordPrivate ++ itemL // print modifier, since more specific than context
| _ -> itemL
| Public, Internal -> WordL.keywordInternal
| Public, Private -> WordL.keywordPrivate
| Internal, Private -> WordL.keywordPrivate
| _ -> emptyL

let layoutAccessibility (denv: DisplayEnv) accessibility itemL =
layoutAccessibilityCore denv accessibility ++ itemL

/// Layout a reference to a type
let layoutTyconRef denv tcref = layoutTyconRefImpl false denv tcref
Expand Down Expand Up @@ -1977,6 +1980,9 @@ module TastDefinitionPrinting =
let addReprAccessL l =
layoutAccessibility denv tycon.TypeReprAccessibility l

let addReprAccessRecord l =
layoutAccessibilityCore denv tycon.TypeReprAccessibility --- l

let addLhs rhsL =
let brk = not (isNil allDecls) || breakTypeDefnEqn repr
if brk then
Expand Down Expand Up @@ -2019,7 +2025,7 @@ module TastDefinitionPrinting =
|> applyMaxMembers denv.maxMembers
|> aboveListL
|> (if useMultiLine then braceMultiLineL else braceL)
|> addReprAccessL
|> addReprAccessRecord
|> addMaxMembers
|> addLhs

Expand Down
8 changes: 6 additions & 2 deletions src/Compiler/Service/FSharpCheckerResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2798,7 +2798,7 @@ type FSharpCheckFileResults
let (nenv, _), _ = scope.GetBestDisplayEnvForPos cursorPos
Some(FSharpDisplayContext(fun _ -> nenv.DisplayEnv))

member _.GenerateSignature() =
member _.GenerateSignature(?pageWidth: int) =
match details with
| None -> None
| Some (scope, _builderOpt) ->
Expand All @@ -2816,7 +2816,11 @@ type FSharpCheckFileResults
let layout =
NicePrint.layoutImpliedSignatureOfModuleOrNamespace true denv infoReader ad range0 mexpr

layout |> LayoutRender.showL |> SourceText.ofString)
match pageWidth with
| None -> layout
| Some pageWidth -> Display.squashTo pageWidth layout
|> LayoutRender.showL
|> SourceText.ofString)

member _.ImplementationFile =
if not keepAssemblyContents then
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Service/FSharpCheckerResults.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ type public FSharpCheckFileResults =
member OpenDeclarations: FSharpOpenDeclaration[]

/// Lays out and returns the formatted signature for the typechecked file as source text.
member GenerateSignature: unit -> ISourceText option
member GenerateSignature: ?pageWidth: int -> ISourceText option

/// Internal constructor
static member internal MakeEmpty:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@
<Compile Include="Globalization\GlobalizationTestCases.fs" />
<Compile Include="OCamlCompat\OCamlCompat.fs" />
<Compile Include="Miscellaneous\ListLiterals.fs" />
<Compile Include="Signatures\TestHelpers.fs" />
<Compile Include="Signatures\ModuleOrNamespaceTests.fs" />
<Compile Include="Signatures\RecordTests.fs" />
</ItemGroup>
<ItemGroup>
<Content Include="resources\**" CopyToOutputDirectory="Never" CopyToPublishDirectory="PreserveNewest" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
module FSharp.Compiler.ComponentTests.Signatures.ModuleOrNamespaceTests

open System
open Xunit
open FsUnit
open FSharp.Test.Compiler

let private prependNewline v = String.Concat("\n", v)

let equal x =
let x =
match box x with
| :? String as s -> s.Replace("\r\n", "\n") |> box
| x -> x

equal x
open FSharp.Compiler.ComponentTests.Signatures.TestHelpers

[<Fact>]
let ``Type from shared namespace`` () =
Expand Down
33 changes: 33 additions & 0 deletions tests/FSharp.Compiler.ComponentTests/Signatures/RecordTests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module FSharp.Compiler.ComponentTests.Signatures.RecordTests

open Xunit
open FsUnit
open FSharp.Test.Compiler
open FSharp.Compiler.ComponentTests.Signatures.TestHelpers

[<Fact>]
let ``Internal record with xml comment`` () =
FSharp
"""
module SignatureFileGeneration.MyModule
type PullActions =
internal
{
/// Any repo which doesn't have a master branch will have one created for it.
Log : int
}
"""
|> printSignaturesWith 80
|> should
equal
"""
module SignatureFileGeneration.MyModule
type PullActions =
internal
{
/// Any repo which doesn't have a master branch will have one created for it.
Log: int
}"""
14 changes: 14 additions & 0 deletions tests/FSharp.Compiler.ComponentTests/Signatures/TestHelpers.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module FSharp.Compiler.ComponentTests.Signatures.TestHelpers

open System
open FsUnit

let prependNewline v = String.Concat("\n", v)

let equal x =
let x =
match box x with
| :? String as s -> s.Replace("\r\n", "\n") |> box
| x -> x

equal x
Original file line number Diff line number Diff line change
Expand Up @@ -1982,7 +1982,7 @@ FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FShar
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Symbols.FSharpDisplayContext] GetDisplayContextForPos(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Symbols.FSharpImplementationFileContents] ImplementationFile
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Symbols.FSharpImplementationFileContents] get_ImplementationFile()
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.ISourceText] GenerateSignature()
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.ISourceText] GenerateSignature(Microsoft.FSharp.Core.FSharpOption`1[System.Int32])
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.FSharpSymbolUse]] GetMethodsAsSymbols(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String])
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[System.String] GetF1Keyword(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String])
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: System.Collections.Generic.IEnumerable`1[FSharp.Compiler.CodeAnalysis.FSharpSymbolUse] GetAllUsesOfAllSymbolsInFile(Microsoft.FSharp.Core.FSharpOption`1[System.Threading.CancellationToken])
Expand Down Expand Up @@ -6709,10 +6709,10 @@ FSharp.Compiler.Syntax.SynExpr+Tags: Int32 Sequential
FSharp.Compiler.Syntax.SynExpr+Tags: Int32 SequentialOrImplicitYield
FSharp.Compiler.Syntax.SynExpr+Tags: Int32 Set
FSharp.Compiler.Syntax.SynExpr+Tags: Int32 TraitCall
FSharp.Compiler.Syntax.SynExpr+Tags: Int32 Typar
FSharp.Compiler.Syntax.SynExpr+Tags: Int32 TryFinally
FSharp.Compiler.Syntax.SynExpr+Tags: Int32 TryWith
FSharp.Compiler.Syntax.SynExpr+Tags: Int32 Tuple
FSharp.Compiler.Syntax.SynExpr+Tags: Int32 Typar
FSharp.Compiler.Syntax.SynExpr+Tags: Int32 TypeApp
FSharp.Compiler.Syntax.SynExpr+Tags: Int32 TypeTest
FSharp.Compiler.Syntax.SynExpr+Tags: Int32 Typed
Expand Down Expand Up @@ -6874,10 +6874,10 @@ FSharp.Compiler.Syntax.SynExpr: Boolean IsSequential
FSharp.Compiler.Syntax.SynExpr: Boolean IsSequentialOrImplicitYield
FSharp.Compiler.Syntax.SynExpr: Boolean IsSet
FSharp.Compiler.Syntax.SynExpr: Boolean IsTraitCall
FSharp.Compiler.Syntax.SynExpr: Boolean IsTypar
FSharp.Compiler.Syntax.SynExpr: Boolean IsTryFinally
FSharp.Compiler.Syntax.SynExpr: Boolean IsTryWith
FSharp.Compiler.Syntax.SynExpr: Boolean IsTuple
FSharp.Compiler.Syntax.SynExpr: Boolean IsTypar
FSharp.Compiler.Syntax.SynExpr: Boolean IsTypeApp
FSharp.Compiler.Syntax.SynExpr: Boolean IsTypeTest
FSharp.Compiler.Syntax.SynExpr: Boolean IsTyped
Expand Down Expand Up @@ -7011,10 +7011,10 @@ FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewSequential(FSh
FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewSequentialOrImplicitYield(FSharp.Compiler.Syntax.DebugPointAtSequential, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewSet(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTraitCall(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Syntax.SynMemberSig, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTypar(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTryFinally(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.DebugPointAtTry, FSharp.Compiler.Syntax.DebugPointAtFinally, FSharp.Compiler.SyntaxTrivia.SynExprTryFinallyTrivia)
FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTryWith(FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynMatchClause], FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.DebugPointAtTry, FSharp.Compiler.Syntax.DebugPointAtWith, FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia)
FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTuple(Boolean, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynExpr], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTypar(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTypeApp(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTypeTest(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTyped(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range)
Expand Down Expand Up @@ -8605,18 +8605,22 @@ FSharp.Compiler.Syntax.SynType: Int32 Tag
FSharp.Compiler.Syntax.SynType: Int32 get_Tag()
FSharp.Compiler.Syntax.SynType: System.String ToString()
FSharp.Compiler.Syntax.SynTypeConstraint
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereSelfConstrained
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereTyparDefaultsToType
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereTyparIsComparable
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereTyparIsDelegate
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereTyparIsEnum
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereTyparIsEquatable
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereTyparIsReferenceType
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereSelfConstrained
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereTyparIsUnmanaged
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereTyparIsValueType
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereTyparSubtypeOfType
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereTyparSupportsMember
FSharp.Compiler.Syntax.SynTypeConstraint+Tags: Int32 WhereTyparSupportsNull
FSharp.Compiler.Syntax.SynTypeConstraint+WhereSelfConstrained: FSharp.Compiler.Syntax.SynType get_selfConstraint()
FSharp.Compiler.Syntax.SynTypeConstraint+WhereSelfConstrained: FSharp.Compiler.Syntax.SynType selfConstraint
FSharp.Compiler.Syntax.SynTypeConstraint+WhereSelfConstrained: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynTypeConstraint+WhereSelfConstrained: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparDefaultsToType: FSharp.Compiler.Syntax.SynTypar get_typar()
FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparDefaultsToType: FSharp.Compiler.Syntax.SynTypar typar
FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparDefaultsToType: FSharp.Compiler.Syntax.SynType get_typeName()
Expand Down Expand Up @@ -8671,10 +8675,6 @@ FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsNull: FSharp.Compiler
FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsNull: FSharp.Compiler.Syntax.SynTypar typar
FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsNull: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsNull: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynTypeConstraint+WhereSelfConstrained: FSharp.Compiler.Syntax.SynType get_selfConstraint()
FSharp.Compiler.Syntax.SynTypeConstraint+WhereSelfConstrained: FSharp.Compiler.Syntax.SynType selfConstraint
FSharp.Compiler.Syntax.SynTypeConstraint+WhereSelfConstrained: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynTypeConstraint+WhereSelfConstrained: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean IsWhereSelfConstrained
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean IsWhereTyparDefaultsToType
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean IsWhereTyparIsComparable
Expand All @@ -8687,6 +8687,7 @@ FSharp.Compiler.Syntax.SynTypeConstraint: Boolean IsWhereTyparIsValueType
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean IsWhereTyparSubtypeOfType
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean IsWhereTyparSupportsMember
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean IsWhereTyparSupportsNull
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean get_IsWhereSelfConstrained()
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean get_IsWhereTyparDefaultsToType()
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean get_IsWhereTyparIsComparable()
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean get_IsWhereTyparIsDelegate()
Expand All @@ -8698,6 +8699,7 @@ FSharp.Compiler.Syntax.SynTypeConstraint: Boolean get_IsWhereTyparIsValueType()
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean get_IsWhereTyparSubtypeOfType()
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean get_IsWhereTyparSupportsMember()
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean get_IsWhereTyparSupportsNull()
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereSelfConstrained(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparDefaultsToType(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparIsComparable(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparIsDelegate(FSharp.Compiler.Syntax.SynTypar, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Text.Range)
Expand All @@ -8710,6 +8712,7 @@ FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstrai
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparSupportsMember(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Syntax.SynMemberSig, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparSupportsNull(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint+Tags
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint+WhereSelfConstrained
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparDefaultsToType
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparIsComparable
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparIsDelegate
Expand All @@ -8726,9 +8729,6 @@ FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Text.Range get_Range()
FSharp.Compiler.Syntax.SynTypeConstraint: Int32 Tag
FSharp.Compiler.Syntax.SynTypeConstraint: Int32 get_Tag()
FSharp.Compiler.Syntax.SynTypeConstraint: System.String ToString()
FSharp.Compiler.Syntax.SynTypeConstraint: Boolean get_IsWhereSelfConstrained()
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereSelfConstrained(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint+WhereSelfConstrained
FSharp.Compiler.Syntax.SynTypeDefn
FSharp.Compiler.Syntax.SynTypeDefn: FSharp.Compiler.Syntax.SynComponentInfo get_typeInfo()
FSharp.Compiler.Syntax.SynTypeDefn: FSharp.Compiler.Syntax.SynComponentInfo typeInfo
Expand Down Expand Up @@ -11099,4 +11099,4 @@ FSharp.Compiler.Xml.XmlDoc: System.String GetXmlText()
FSharp.Compiler.Xml.XmlDoc: System.String[] GetElaboratedXmlLines()
FSharp.Compiler.Xml.XmlDoc: System.String[] UnprocessedLines
FSharp.Compiler.Xml.XmlDoc: System.String[] get_UnprocessedLines()
FSharp.Compiler.Xml.XmlDoc: Void .ctor(System.String[], FSharp.Compiler.Text.Range)
FSharp.Compiler.Xml.XmlDoc: Void .ctor(System.String[], FSharp.Compiler.Text.Range)
14 changes: 8 additions & 6 deletions tests/FSharp.Test.Utilities/Compiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,15 +1313,15 @@ module rec Compiler =
let withEvalTypeEquals t (result: CompilationResult) : CompilationResult =
assertEvalOutput (fun (x: FsiValue) -> x.ReflectionType) t result

let signatureText (checkResults: FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults) =
checkResults.GenerateSignature()
let signatureText (pageWidth: int option) (checkResults: FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults) =
checkResults.GenerateSignature(?pageWidth = pageWidth)
|> Option.defaultWith (fun _ -> failwith "Unable to generate signature text.")

let signaturesShouldContain (expected: string) cUnit =
let text =
cUnit
|> typecheckResults
|> signatureText
|> signatureText None

let actual =
text.ToString().Split('\n')
Expand All @@ -1331,13 +1331,15 @@ module rec Compiler =
if not (actual |> Array.contains expected) then
failwith ($"The following signature:\n%s{expected}\n\nwas not found in:\n" + (actual |> String.concat "\n"))

let printSignatures cUnit =
let private printSignaturesImpl pageWidth cUnit =
cUnit
|> typecheckResults
|> signatureText
|> signatureText pageWidth
|> string
|> fun s ->
s.Replace("\r", "").Split('\n')
|> Array.map (fun line -> line.TrimEnd())
|> String.concat "\n"
|> fun tap -> tap

let printSignatures cUnit = printSignaturesImpl None cUnit
let printSignaturesWith pageWidth cUnit = printSignaturesImpl (Some pageWidth) cUnit

0 comments on commit 7c81ac0

Please sign in to comment.