Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
psfinaki merged 10 commits intomainfrompsfinaki/13549
Aug 22, 2022

Conversation

psfinaki
Copy link
Member

@psfinakipsfinaki commentedAug 16, 2022
edited
Loading

fixes#13549

Changes the notion of help options to the console-only related options, which now include--help and--version.
Also added a test (best effort).

Video proof :D

TestCrash.-.Microsoft.Visual.Studio.Int.Preview.2022-08-16.17-46-09.mp4

@psfinaki
Copy link
MemberAuthor

psfinaki commentedAug 16, 2022
edited
Loading

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@abelbraaksma
Copy link
Contributor

Copying here, as the ‘resolved’ review comments get hidden:

Got it, tx. Does this mean using -version or any illegal option, will now be simply ignored? Or would it allow outputting the version info on each build to the VS console?

@KevinRansom
Copy link
Contributor

@psfinaki --- hey there, there is another case, and it's a little bit wierder.

The command fsc --langversion:4.7 allows you to use ? to get the list of valid versions and then does an exit 1

image

The handler is here:
https://github.com/dotnet/fsharp/blob/main/src/Compiler/Driver/CompilerOptions.fs#L1078

And the specification is here:
https://github.com/dotnet/fsharp/blob/main/src/Compiler/Driver/CompilerOptions.fs#L1111

I think it may be a lit bit different from your CONSOLE_ONLY items, because it can also contain real options, as well as the help request.

@psfinaki
Copy link
MemberAuthor

@KevinRansom Yep, thanks for the point, I think I will address that separately in a followup. That thing is just ridiculous - the function is called "setLanguageVersion" but actually it sometimes sets the version and sometimes gets the versions. That's like against all the coding principles, so I'll better do a small refactoring and testing around that.

@psfinaki
Copy link
MemberAuthor

@abelbraaksma so normally invalid compiler options are reported. Both in console:
image
and in VS:
image

It's just that you hit a special/reserved case with this--version :) This is for getting info about the compiler itself, not giving it any instructions. And so I don't think it makes sense to output this info when building a project - because this info would be unrelated to the project.

So the current implementation will preserve reporting errors in VS for bad options whereas for these special readonly options VS will be just silent. Now as I'm thinking about, I might actually come with a followup to somehow point this out instead of remaining silent - but let this PR just fix the bug itself.

@psfinakipsfinakienabled auto-merge (squash)August 18, 2022 13:42
@vzarytovskii
Copy link
Member

On the review with@KevinRansom, we've realized that there's an existing mechanism for proper exit from the compiler - using of exiters (with StopProcessing exceptions probably).

For example:

letquitProcessExiter=
{new Exiterwith
member_.Exit(n)=
try
exit n
with_->
()
failwithf"%s"(FSComp.SR.elSysEnvExitDidntExit())
}
// Get the handler for legacy resolution of references via MSBuild.
letlegacyReferenceResolver= LegacyMSBuildReferenceResolver.getResolver()
// Perform the main compilation.
//
// This is the only place where ReduceMemoryFlag.No is set. This is because fsc.exe is not a long-running process and
// thus we can use file-locking memory mapped files.
//
// This is also one of only two places where CopyFSharpCoreFlag.Yes is set. The other is in LegacyHostedCompilerForTesting.
CompileFromCommandLineArguments(
ctok,
argv,
legacyReferenceResolver,
false,
ReduceMemoryFlag.No,
CopyFSharpCoreFlag.Yes,
quitProcessExiter,
ConsoleLoggerProvider(),
None,
None
)

or:

letexiter=
{new Exiterwith
memberx.Exit n= raise StopProcessing
}
try
f exiter
0
with e->
stopProcessingRecovery e range0
1

Wondering how easy will it be to plug into the cli options, since it is designed for cases like this and is probably the right way of dealing with it.

@psfinaki
Copy link
MemberAuthor

On the review with@KevinRansom, we've realized that there's an existing mechanism for proper exit from the compiler - using of exiters (with StopProcessing exceptions probably).

@vzarytovskii Good point - I'd say it's a related possible improvement so will do it as a followup.

Tickets for followups:#13748,#13749,#13750

@vzarytovskii
Copy link
Member

Ok, I'm going to merge it, and let's have the one with exiter next.

psfinaki reacted with thumbs up emoji

@abelbraaksma
Copy link
Contributor

I finally had some time actually test this locally. Excellent work@psfinaki, solution works like a charm!

psfinaki reacted with heart emoji

@psfinaki
Copy link
MemberAuthor

@abelbraaksma, my pleasure :)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@abelbraaksmaabelbraaksmaabelbraaksma left review comments

@vzarytovskiivzarytovskiivzarytovskii approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

I can make Visual Studio disappear by using "Other flags" in the properties window
4 participants
@psfinaki@abelbraaksma@KevinRansom@vzarytovskii

[8]ページ先頭

©2009-2025 Movatter.jp