Skip to content

Commit

Permalink
Avoid conflicting values of DkmEvaluationFlags (dotnet#55675)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat authored Aug 17, 2021
1 parent 56ccda4 commit 8ec61b8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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<DkmEvaluationFlags>().ToArray();
Assert.False(values.Contains(ResultProvider.NoResults));
Assert.False(values.Contains(ResultProvider.NotRoot));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,24 @@ namespace Microsoft.CodeAnalysis.ExpressionEvaluator
/// </remarks>
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;
Expand Down Expand Up @@ -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<DkmGetChildrenAsyncResult> completionRoutine)
{
var dataItem = evaluationResult.GetDataItem<EvalResultDataItem>();
Expand Down

0 comments on commit 8ec61b8

Please sign in to comment.