Skip to content

Commit

Permalink
FailFast on GetOperation exception
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan committed Apr 5, 2024
1 parent e4d7ea6 commit f70f6ce
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
Expand Down Expand Up @@ -114,8 +115,19 @@ internal static bool IsConstantByteOrCharArrayCreationExpression(SemanticModel s
}
else
{
IOperation? operation;
try
{
operation = semanticModel.GetOperation(expression);
}
catch (Exception ex)
{
Environment.FailFast(ex.Message, ex);
throw;
}

return
semanticModel.GetOperation(expression) is { } operation &&
operation is not null &&
IsConstantByteOrCharCollectionExpression(operation, values, out length);
}

Expand Down

0 comments on commit f70f6ce

Please sign in to comment.