Skip to content

Exception from the ReturnStructPartialActivePatternAnalyzer analyzer in the latest Ionide when using the transparent compiler #147

@Numpsy

Description

@Numpsy

Describe the bug
Whilst running Ionide with Verbose logging enabled to test something else, I noticed this in the log output when it ran the latest version of the analyzers on my project:

[09:42:03.456 ERR] [Analyzers] Analyzer ReturnStructPartialActivePatternAnalyzer errored while processing s:\BJKCTitDev\DocLabellerMicro\DocLabellerMicro\src\DocLabellerMicro\Types.fs: ProjectOptions are not available. This is expected when using FSharpChecker with useTransparentCompiler=true.
System.Exception: ProjectOptions are not available. This is expected when using FSharpChecker with useTransparentCompiler=true.
   at FSharp.Compiler.CodeAnalysis.FSharpProjectContext.get_ProjectOptions() in D:\a\_work\1\s\src\Compiler\Service\FSharpCheckerResults.fs:line 3333
   at Ionide.Analyzers.Performance.ReturnStructPartialActivePatternAnalyzer.runIfLanguageFeatureIsSupported(ISourceText sourceText, ParsedInput parsedInput, FSharpCheckFileResults checkResults) in /_//src/Ionide.Analyzers/Performance/ReturnStructPartialActivePatternAnalyzer.fs:line 215
   at Ionide.Analyzers.Performance.ReturnStructPartialActivePatternAnalyzer.returnStructPartialActivePatternEditorAnalyzer@238.Invoke(Unit unitVar) in /_//src/Ionide.Analyzers/Performance/ReturnStructPartialActivePatternAnalyzer.fs:line 238
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 509
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112

As the error suggests, it only occurs when the transparent compiler is enabled.

I'd guess that was down to dotnet/fsharp#18205? Not sure what the fix is outside of handling the exceptions though, or how important it is if the transparent compiler is off by default, but raising ot for the record.

To Reproduce
I just saw the errors in the verbose logging when it tried to analyze my project with the latest Ionide and analyzers, with the transparent compiler enabled.

Environment (please complete the following information):

  • OS: Windows 10
  • Ionide version: 7.25.10
  • VSCode version: 1.100.2
  • dotnet SDK version: 9.0.300

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions