Skip to content

Conversation

ocallesp
Copy link
Contributor

@ocallesp ocallesp commented Jun 12, 2024

Fixes dotnet/try#1184

This fixes a bug in TryDotNet that occurs when a user enters invalid code.

  • Ensured project diagnostics are added only if their Id is not already present in the main diagnostics collection

image

This fixes a bug in TryDotNet that occurs when a user enters invalid code.

- Ensured project diagnostics are added only if their Id is not already present in the main diagnostics collection
@ocallesp ocallesp changed the title Avoid duplicate diagnostics by checking Id Fix TryDotnet issue "Compile errors are duplicated in output" Jun 12, 2024
@ocallesp ocallesp marked this pull request as ready for review June 12, 2024 15:53
@ocallesp ocallesp requested review from jonsequitur and colombod June 12, 2024 15:53
@@ -291,9 +291,17 @@ private static IEnumerable<Diagnostic> GetDiagnostics(string code, CompileResult
projectDiagnostics = projectDiags;
}

var allDiagnostics = diagnostics.Concat(projectDiagnostics);
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we need the project diagnostics at all. Are there ever diagnostics here that are interesting from the point of view of Try .NET?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Diagnostics contain errors introduced by the user, while ProjectDiagnostics cover errors across the entire project.

Using only Diagnostics works well for our primary focus on user-introduced errors.

For debugging purposes and to catch potential errors from changes to the background project, it might be useful to include ProjectDiagnostics. However, since the project is pre-built and we assume deployment doesn't occur with build errors, we can safely remove ProjectDiagnostics from GetDiagnostics.

@ocallesp ocallesp requested a review from jonsequitur June 12, 2024 18:20
@ocallesp ocallesp enabled auto-merge June 12, 2024 18:32
@@ -277,23 +277,14 @@ private async Task<Workspace> AppendCodeToWorkspaceAsync(string code, int positi
private static IEnumerable<Diagnostic> GetDiagnostics(string code, CompileResult result)
{
var diagnostics = Enumerable.Empty<SerializableDiagnostic>();
Copy link
Contributor

Choose a reason for hiding this comment

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

This assignment could be moved to an else block below now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good. I made the suggested change. Can you approve this cleanup change #3574

@ocallesp ocallesp merged commit ac78628 into dotnet:main Jun 12, 2024
@ocallesp ocallesp deleted the fix-trydotnet-issue1184 branch June 12, 2024 19:23
@jonsequitur jonsequitur added the bug Something isn't working label Oct 9, 2024
@jonsequitur jonsequitur added Area-Try .NET Try .NET and CSharpProjectKernel and removed bug Something isn't working labels Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Try .NET Try .NET and CSharpProjectKernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compile errors are duplicated in output
3 participants