-
Notifications
You must be signed in to change notification settings - Fork 834
Properly handle console-only fsc options in the VS context #13702
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a920326
The fix
psfinaki d27940f
Update CompilerOptions.fs
psfinaki fe73c5e
Tests
psfinaki 65b21c9
Update VisualStudioVersusConsoleContextTests.fs
psfinaki 8541d2c
Update
psfinaki 5ca0cf1
Merge branch 'main' into psfinaki/13549
psfinaki 5a26d86
Update
psfinaki 46b03c2
Merge branch 'main' into psfinaki/13549
psfinaki 67584a2
Merge branch 'main' into psfinaki/13549
psfinaki ef2de50
Merge branch 'main' into psfinaki/13549
psfinaki 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
60 changes: 60 additions & 0 deletions
60
tests/FSharp.Compiler.Service.Tests/VisualStudioVersusConsoleContextTests.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,60 @@ | ||
| // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
|
||
| module FSharp.Compiler.Service.Tests.VisualStudioVersusConsoleContextTests | ||
|
|
||
| open FSharp.Compiler.Text | ||
| open NUnit.Framework | ||
| open System.IO | ||
| open FSharp.Compiler.CompilerConfig | ||
| open FSharp.Compiler.CompilerOptions | ||
| open Internal.Utilities | ||
| open FSharp.Compiler.AbstractIL.ILBinaryReader | ||
|
|
||
| // copypasted from the CompilerOptions code, | ||
| // not worth changing that code's accessibility just for this test | ||
| let private getOptionsFromOptionBlocks blocks = | ||
| let GetOptionsOfBlock block = | ||
| match block with | ||
| | PublicOptions (_, opts) -> opts | ||
| | PrivateOptions opts -> opts | ||
|
|
||
| List.collect GetOptionsOfBlock blocks | ||
|
|
||
| [<Test>] // controls https://github.com/dotnet/fsharp/issues/13549 | ||
| let ``Console-only options are filtered out for fsc in the VS context`` () = | ||
| // just a random thing to make things work | ||
| let builder = TcConfigBuilder.CreateNew( | ||
| null, | ||
| FSharpEnvironment.BinFolderOfDefaultFSharpCompiler(None).Value, | ||
| ReduceMemoryFlag.Yes, | ||
| Directory.GetCurrentDirectory(), | ||
| false, | ||
| false, | ||
| CopyFSharpCoreFlag.No, | ||
| (fun _ -> None), | ||
| None, | ||
| Range.Zero) | ||
|
|
||
| let blocks = GetCoreServiceCompilerOptions builder | ||
| let options = getOptionsFromOptionBlocks blocks | ||
|
|
||
| // this is a very whitebox testing but arguably better than nothing | ||
| Assert.IsFalse( | ||
| options | ||
| |> List.exists (function | ||
| | CompilerOption (_, _, OptionConsoleOnly _, _, _) -> true | ||
| | _ -> false)) | ||
|
|
||
| // and a couple of shots in the dark | ||
| Assert.False( | ||
| options | ||
| |> List.exists (function | ||
| // ignore deprecated options | ||
| // one of them actually allows specifying the compiler version | ||
| | CompilerOption (name, _, _, None, _) -> name = "version" | ||
| | _ -> false)) | ||
|
|
||
| Assert.False( | ||
| options | ||
| |> List.exists (function | ||
| | CompilerOption (name, _, _, _, _) -> name = "help")) |
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.
Uh oh!
There was an error while loading. Please reload this page.