-
Notifications
You must be signed in to change notification settings - Fork 0
Fix failing tests on main branch #2
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -452,46 +452,63 @@ let processServerEvent (logger: ILogger) state postSelf msg : Async<ServerState> | |
| PushDiagnosticsDocumentBacklog = newBacklog } | ||
|
|
||
| let wf, docForUri = docUri |> workspaceDocument state.Workspace AnyDocument | ||
| let wfPathToUri = workspaceFolderPathToUri wf.Value | ||
|
|
||
| match wf, docForUri with | ||
| | Some wf, None -> | ||
| let cshtmlPath = workspaceFolderUriToPath wf docUri |> _.Value | ||
|
|
||
| match! solutionGetRazorDocumentForPath wf.Solution.Value cshtmlPath with | ||
| | Some(_, compilation, cshtmlTree) -> | ||
| let semanticModelMaybe = compilation.GetSemanticModel cshtmlTree |> Option.ofObj | ||
|
|
||
| match semanticModelMaybe with | ||
| // Only try to process as a .cshtml file if it actually is one | ||
| match workspaceFolderUriToPath wf docUri with | ||
| | Some cshtmlPath when cshtmlPath.EndsWith(".cshtml", StringComparison.OrdinalIgnoreCase) -> | ||
|
Comment on lines
+459
to
+460
|
||
| match wf.Solution with | ||
| | None -> | ||
| Error(Exception "could not GetSemanticModelAsync") | ||
| |> PushDiagnosticsDocumentDiagnosticsResolution | ||
| |> postSelf | ||
|
|
||
| | Some semanticModel -> | ||
| let diagnostics = | ||
| semanticModel.GetDiagnostics() | ||
| |> Seq.map (Diagnostic.fromRoslynDiagnostic (workspaceFolderPathToUri wf)) | ||
| |> Seq.filter (fun (_, uri) -> uri = docUri) | ||
| |> Seq.map fst | ||
| |> Array.ofSeq | ||
|
|
||
| Ok(docUri, None, diagnostics) | ||
| |> PushDiagnosticsDocumentDiagnosticsResolution | ||
| |> postSelf | ||
|
|
||
| | None -> | ||
| // could not find document for this enqueued uri | ||
| // Solution not loaded yet, rebuild backlog and try again later | ||
| postSelf PushDiagnosticsDocumentBacklogUpdate | ||
| postSelf PushDiagnosticsProcessPendingDocuments | ||
|
Comment on lines
462
to
+465
|
||
| | Some solution -> | ||
| match! solutionGetRazorDocumentForPath solution cshtmlPath with | ||
| | Some(_, compilation, cshtmlTree) -> | ||
| let semanticModelMaybe = compilation.GetSemanticModel cshtmlTree |> Option.ofObj | ||
|
|
||
| match semanticModelMaybe with | ||
| | None -> | ||
| Error(Exception "could not GetSemanticModelAsync") | ||
| |> PushDiagnosticsDocumentDiagnosticsResolution | ||
| |> postSelf | ||
|
|
||
| | Some semanticModel -> | ||
| let diagnostics = | ||
| semanticModel.GetDiagnostics() | ||
| |> Seq.map (Diagnostic.fromRoslynDiagnostic (workspaceFolderPathToUri wf)) | ||
| |> Seq.filter (fun (_, uri) -> uri = docUri) | ||
| |> Seq.map fst | ||
| |> Array.ofSeq | ||
|
|
||
| Ok(docUri, None, diagnostics) | ||
| |> PushDiagnosticsDocumentDiagnosticsResolution | ||
| |> postSelf | ||
|
|
||
| | None -> | ||
| logger.LogDebug( | ||
| "PushDiagnosticsProcessPendingDocuments: could not find razor document for \"{cshtmlPath}\"", | ||
| cshtmlPath | ||
| ) | ||
| // Continue with next document | ||
| postSelf PushDiagnosticsProcessPendingDocuments | ||
|
|
||
| | _ -> | ||
| // Not a .cshtml file or couldn't convert URI | ||
| // This can happen if solution hasn't loaded yet - rebuild backlog for retry | ||
| logger.LogDebug( | ||
| "PushDiagnosticsProcessPendingDocuments: could not find document w/ uri \"{docUri}\"", | ||
| "PushDiagnosticsProcessPendingDocuments: could not find document w/ uri \"{docUri}\", will retry", | ||
| string docUri | ||
| ) | ||
|
|
||
| () | ||
| postSelf PushDiagnosticsDocumentBacklogUpdate | ||
| postSelf PushDiagnosticsProcessPendingDocuments | ||
|
Comment on lines
+497
to
+505
|
||
|
|
||
| return newState | ||
|
|
||
| | Some wf, Some doc -> | ||
| let wfPathToUri = workspaceFolderPathToUri wf | ||
|
|
||
| let resolveDocumentDiagnostics () : Task = task { | ||
| let! semanticModelMaybe = doc.GetSemanticModelAsync() | ||
|
|
||
|
|
||
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.
Inconsistent extension checking: The code uses
cshtmlPath.EndsWith(".cshtml", StringComparison.OrdinalIgnoreCase)here, but elsewhere in the codebase (e.g., Workspace.fs:360, 392), the pattern is to useuri.EndsWith ".cshtml"without the case-insensitive comparison. Consider using a consistent approach throughout the codebase. Note that the check should ideally be on the URI (like line 360) before converting to a path, for consistency.