Skip to content

Commit

Permalink
Merge pull request #340 from dotnetcore/any
Browse files Browse the repository at this point in the history
fixed code
  • Loading branch information
NMSAzulX committed Jul 1, 2024
2 parents 14334f9 + 0ebb0f1 commit f4a08a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;
using System.Diagnostics;
using System.Linq;

namespace Natasha.CSharp.Extension.HotExecutor.SG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class ConsoleWriter
var node = blockSyntax.Statements.Last();
if (node.IsKind(Microsoft.CodeAnalysis.CSharp.SyntaxKind.ExpressionStatement))
{
if (node.ToString() == "Console.ReadKey();")
if (node.ToString().StartsWith("Console.Read"))
{
return blockSyntax.RemoveNode(node, SyntaxRemoveOptions.KeepExteriorTrivia);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@ internal sealed class NatashaExceptionAnalyzer
{

var diagnostics = tree.GetDiagnostics();
var errors = diagnostics.Where(item => !item.IsSuppressed).ToArray();
if (errors.Length > 0)
if (diagnostics.Any())
{
var first = errors.FirstOrDefault(item => item.DefaultSeverity == DiagnosticSeverity.Error);
if (first == null)
var errors = diagnostics.Where(item => !item.IsSuppressed).ToArray();
if (errors != null && errors.Length > 0)
{
first = errors[0];
var first = errors.FirstOrDefault(item => item.DefaultSeverity == DiagnosticSeverity.Error);
if (first == null)
{
first = errors[0];
}
var exception = new NatashaException(first.GetMessage());
exception.Diagnostics.AddRange(errors);
exception.Formatter = tree.ToString();
exception.ErrorKind = NatashaExceptionKind.Syntax;
return exception;
}
var exception = new NatashaException(first.GetMessage());
exception.Diagnostics.AddRange(errors);
exception.Formatter = tree.ToString();
exception.ErrorKind = NatashaExceptionKind.Syntax;
return exception;
}
return null;

}

internal static NatashaException GetCompileException(CSharpCompilation compilation, ImmutableArray<Diagnostic> errors)
Expand Down

0 comments on commit f4a08a4

Please sign in to comment.