-
Notifications
You must be signed in to change notification settings - Fork 833
[WIP] Generate signature based on ModuleOrNamespaceType #11303
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
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4795f27
Initial commit for signature generation
TIHan 6faf000
Basic generation
TIHan 38fbcca
Added basic namespace test
TIHan 0a547d9
Added another test
TIHan 37d15a1
Added another test
TIHan 786168f
Added another test
TIHan 7d6ec71
Simplifying tests. Added linebreaks
TIHan b025e20
More tests
TIHan 68e6099
one test fails
TIHan e6c4fac
Tests finally pass
TIHan b502088
Better indent
TIHan be3410b
Added a failing test
TIHan 9179b45
Verifying area
TIHan 2de2390
Do not shrink overloads
TIHan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
tests/fsharp/Compiler/Service/SignatureGenerationTests.fs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
|
||
| namespace FSharp.Compiler.UnitTests | ||
|
|
||
| open FSharp.Compiler.Diagnostics | ||
| open NUnit.Framework | ||
| open FSharp.Test.Utilities | ||
| open FSharp.Test.Utilities.Utilities | ||
| open FSharp.Test.Utilities.Compiler | ||
| open FSharp.Tests | ||
|
|
||
| [<TestFixture>] | ||
| module SignatureGenerationTests = | ||
|
|
||
| let sigText (checkResults: FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults) = | ||
| match checkResults.GenerateSignatureText() with | ||
| | None -> failwith "Unable to generate signature text." | ||
| | Some text -> text | ||
|
|
||
| let sigShouldBe (expected: string) src = | ||
| let text = | ||
| FSharp src | ||
| |> withLangVersion50 | ||
| |> typecheckResults | ||
| |> sigText | ||
|
|
||
| let actual = text.ToString() | ||
| let expected2 = expected.Replace("\r\n", "\n") | ||
| Assert.shouldBeEquivalentTo expected2 actual | ||
|
|
||
| [<Test>] | ||
| let ``Generate signature with correct namespace``() = | ||
| """ | ||
| namespace ANamespaceForSignature | ||
| """ | ||
| |> sigShouldBe """namespace rec ANamespaceForSignature""" | ||
|
|
||
| [<Test>] | ||
| let ``Generate signature with correct namespace 2``() = | ||
| """ | ||
| namespace Test.ANamespaceForSignature | ||
| """ | ||
| |> sigShouldBe """namespace rec Test.ANamespaceForSignature""" | ||
|
|
||
| [<Test>] | ||
| let ``Generate signature with correct namespace 3``() = | ||
| """ | ||
| namespace Test.ANamespaceForSignature | ||
|
|
||
| namespace Test2.ANamespaceForSignature2 | ||
| """ | ||
| |> sigShouldBe """namespace rec Test.ANamespaceForSignature | ||
|
|
||
| namespace rec Test2.ANamespaceForSignature2""" | ||
|
|
||
|
|
||
| [<Test>] | ||
| let ``Generate signature with correct namespace and type``() = | ||
| """ | ||
| namespace Test.ANamespaceForSignature | ||
|
|
||
| type TestType = class end | ||
| """ | ||
| |> sigShouldBe """namespace rec Test.ANamespaceForSignature | ||
|
|
||
| type TestType""" | ||
|
|
||
| [<Test>] | ||
| let ``Generate signature with correct namespace and private inner record type``() = | ||
| """ | ||
| namespace Test.ANamespaceForSignature | ||
|
|
||
| type TestType = private { x: int } | ||
| """ | ||
| |> sigShouldBe """namespace rec Test.ANamespaceForSignature | ||
|
|
||
| type TestType = | ||
| private { x: int }""" | ||
|
|
||
| [<Test>] | ||
| let ``Generate signature with correct namespace and private inner record type and module with private inner record type``() = | ||
| """ | ||
| namespace Test.ANamespaceForSignature | ||
|
|
||
| type TestType = private { x: int } | ||
|
|
||
| module ModuleA = | ||
|
|
||
| type TestType2 = private { x: float32 } | ||
| """ | ||
| |> sigShouldBe """namespace rec Test.ANamespaceForSignature | ||
|
|
||
| type TestType = | ||
| private { x: int } | ||
|
|
||
| module rec ModuleA = | ||
|
|
||
| type TestType2 = | ||
| private { x: float32 }""" | ||
|
|
||
| [<Test>] | ||
| let ``Generate signature with correct module``() = | ||
| """ | ||
| module AModuleForSignature | ||
| """ | ||
| |> sigShouldBe """module rec AModuleForSignature""" | ||
|
|
||
| [<Test>] | ||
| let ``Generate signature with correct module 2``() = | ||
| """ | ||
| module Test.AModuleForSignature | ||
| """ | ||
| |> sigShouldBe """namespace rec Test | ||
|
|
||
| module rec AModuleForSignature = begin end""" | ||
|
|
||
| [<Test>] | ||
| let ``Generate signature with correct module includes attributes``() = | ||
| // TODO: This should trim the "Attribute ()". | ||
| """ | ||
| [<RequireQualifiedAccess>] | ||
| module AModuleForSignature | ||
| """ | ||
| |> sigShouldBe """[<RequireQualifiedAccessAttribute ()>] | ||
| module rec AModuleForSignature""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this impact tooltips? We shrink overloads for those
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is a separate pass to generating text versus tooltips.