diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ResultProviderTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ResultProviderTests.cs new file mode 100644 index 0000000000000..1f71fa8bd7178 --- /dev/null +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ResultProviderTests.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Microsoft.CodeAnalysis.ExpressionEvaluator; +using Microsoft.VisualStudio.Debugger.Evaluation; +using Xunit; + +namespace Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.UnitTests +{ + public class ResultProviderTests + { + [Fact] + public void DkmEvaluationFlagsConflict() + { + var values = Enum.GetValues(typeof(DkmEvaluationFlags)).Cast().ToArray(); + Assert.False(values.Contains(ResultProvider.NoResults)); + Assert.False(values.Contains(ResultProvider.NotRoot)); + } + } +} diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs index 4f2fa760946bf..769be393a9114 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs @@ -33,16 +33,24 @@ namespace Microsoft.CodeAnalysis.ExpressionEvaluator /// public abstract class ResultProvider : IDkmClrResultProvider { - static ResultProvider() - { - FatalError.Handler = FailFast.OnFatalException; - } + // TODO: There is a potential that these values will conflict with debugger defined flags in future. + // It'd be better if we attached these flags to the DkmClrValue object via data items, however DkmClrValue is currently mutable + // and we can't clone it -- in some cases we might need to attach different flags in different code paths and it wouldn't be possible + // to do so due to mutability. + // See https://github.com/dotnet/roslyn/issues/55676. + internal const DkmEvaluationFlags NotRoot = (DkmEvaluationFlags)(1 << 30); + internal const DkmEvaluationFlags NoResults = (DkmEvaluationFlags)(1 << 31); // Fields should be removed and replaced with calls through DkmInspectionContext. // (see https://github.com/dotnet/roslyn/issues/6899). internal readonly IDkmClrFormatter2 Formatter2; internal readonly IDkmClrFullNameProvider FullNameProvider; + static ResultProvider() + { + FatalError.Handler = FailFast.OnFatalException; + } + internal ResultProvider(IDkmClrFormatter2 formatter2, IDkmClrFullNameProvider fullNameProvider) { Formatter2 = formatter2; @@ -101,9 +109,6 @@ DkmClrValue IDkmClrResultProvider.GetClrValue(DkmSuccessEvaluationResult evaluat } } - internal const DkmEvaluationFlags NotRoot = (DkmEvaluationFlags)0x20000; - internal const DkmEvaluationFlags NoResults = (DkmEvaluationFlags)0x40000; - void IDkmClrResultProvider.GetChildren(DkmEvaluationResult evaluationResult, DkmWorkList workList, int initialRequestSize, DkmInspectionContext inspectionContext, DkmCompletionRoutine completionRoutine) { var dataItem = evaluationResult.GetDataItem();