dotnet/roslyn

EE does not parse format specifiers when compiling assignments

Open

#60,639 建立於 2022年4月7日

在 GitHub 查看
 (0 留言) (0 反應) (0 負責人)C# (4,257 fork)batch import
Area-InteractiveBughelp wanted

倉庫指標

Star
 (20,414 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 256 個 PR)

描述

Version Used: VS 17.3.0 Preview 1.0 [32405.266.main]

Steps to Reproduce:

  1. Create a new .NET 6 console app:
for (int i = 50; i < 60; ++i)
{
    Debugger.Break();
}
  1. Evaluate the following in the watch window:
i, d
  1. Attempt to edit value

Expected i has the new value..

Actual image

Metadata When modifying the value of the variable, the debugger evaluates the expression with IDkmClrExpressionCompiler.CompileAssignment, which Roslyn does not clean up formatters when compiling expression.Text with ParseAssignemnt:

>	Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.SyntaxHelpers.ParseAssignment(string target, string expr, Microsoft.CodeAnalysis.DiagnosticBag diagnostics) Line 76	C#
 	Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.EvaluationContext.CompileAssignment(string target, string expr, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ExpressionEvaluator.Alias> aliases, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, out Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProperties resultProperties, Microsoft.CodeAnalysis.CodeGen.CompilationTestData testData) Line 356	C#
 	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmClrExpressionCompiler.CompileAssignment.AnonymousMethod__1(Microsoft.CodeAnalysis.ExpressionEvaluator.EvaluationContextBase context, Microsoft.CodeAnalysis.DiagnosticBag diagnostics) Line 161	C#
 	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileWithRetry<Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileExpressionResult>(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ExpressionEvaluator.MetadataBlock> metadataBlocks, Microsoft.CodeAnalysis.DiagnosticFormatter formatter, Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CreateContextDelegate createContext, Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileDelegate<Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileExpressionResult> compile, Microsoft.CodeAnalysis.ExpressionEvaluator.DkmUtilities.GetMetadataBytesPtrFunction getMetaDataBytesPtr, out string errorMessage) Line 392	C#
 	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileWithRetry<Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileExpressionResult>(Microsoft.VisualStudio.Debugger.Clr.DkmClrAppDomain appDomain, Microsoft.VisualStudio.Debugger.Clr.DkmClrRuntimeInstance runtimeInstance, Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CreateContextDelegate createContext, Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileDelegate<Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileExpressionResult> compile, out string errorMessage) Line 364	C#
 	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmClrExpressionCompiler.CompileAssignment(Microsoft.VisualStudio.Debugger.Evaluation.DkmLanguageExpression expression, Microsoft.VisualStudio.Debugger.Clr.DkmClrInstructionAddress instructionAddress, Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResult lValue, out string error, out Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmCompiledClrInspectionQuery result) Line 155	C#
 	Microsoft.VisualStudio.Debugger.Engine.dll!Microsoft.VisualStudio.Debugger.EntryPoint.IDkmClrExpressionCompiler_CompileAssignment(System.IntPtr pvClassInfo, System.IntPtr Expression, System.IntPtr InstructionAddress, System.IntPtr LValue, ref System.IntPtr Error, ref System.IntPtr Result)	Unknown

When evaluating an expression to display the result, a different entrypoint is used, which parses any custom formatting as an expression.

貢獻者指南