Skip to content

Conversation

@TheAngryByrd
Copy link
Member

Closes #245

dotnet run -f net8.0 -- --project ../../samples/OptionAnalyzer/OptionAnalyzer.fsproj --analyzers-path ../../artifacts/bin/OptionAnalyzer/debug
[20:18:43.021] critical: FSharp.Analyzers.Cli could not find System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. If you're using a preview version of the .NET SDK, you may need to set DOTNET_ROLL_FORWARD_TO_PRERELEASE=1 in your environment before running this tool.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Ionide.ProjInfo.WorkspaceLoader.Ionide.ProjInfo.IWorkspaceLoader.LoadProjects(FSharpList`1 projects, FSharpList`1 customProperties, BinaryLogGeneration binaryLogs)
   at [email protected](Unit unitVar) in C:\Users\jimmy\Repositories\public\TheAngryByrd\FSharp.Analyzers.SDK-wt\246-option-analyzer-editor-context\src\FSharp.Analyzers.Cli\Program.fs:line 177
   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 [email protected](AsyncActivation`1 ctxt)
   at [email protected](AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112
--- End of stack trace from previous location ---
   at Microsoft.FSharp.Control.AsyncResult`1.Commit() in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 453
   at Microsoft.FSharp.Control.AsyncPrimitives.QueueAsyncAndWaitForResultSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1138      
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1165
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1514
   at Program.main(String[] argv) in C:\Users\jimmy\Repositories\public\TheAngryByrd\FSharp.Analyzers.SDK-wt\246-option-analyzer-editor-context\src\FSharp.Analyzers.Cli\Program.fs:line 834

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds better error handling for System.Runtime load exceptions in the FSharp.Analyzers.Cli tool. The changes help diagnose issues when the analyzer fails to load the required System.Runtime assembly, particularly in preview .NET SDK scenarios.

  • Adds an unhandled exception handler that provides specific guidance for System.Runtime loading issues
  • Enhances logging to properly display exception details in non-analyzer message style mode
  • Introduces a new exit code for unhandled exceptions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/FSharp.Analyzers.Cli/Program.fs Adds unhandled exception handler and new exit code for better error diagnostics
src/FSharp.Analyzers.Cli/CustomLogging.fs Fixes exception logging to ensure exception details are written to output

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Silent failure of fsharp-analyzers when failing to load a project

3 participants