diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.vb index b80e9f0fc0e53d5e5389405428a54eb2e7979522..6832d0e7a98d7e8dd3abe951d4cf28cea075cef1 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/PlaceholderLocalBinder.vb @@ -76,14 +76,16 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Dim typeChar As String = Nothing Dim specialType = GetSpecialTypeForTypeCharacter(identifier.GetTypeCharacter(), typeChar) Dim type = Compilation.GetSpecialType(If(specialType = SpecialType.None, SpecialType.System_Object, specialType)) - ' NOTE: Don't create the local with the canonical name since we want it to have the user's text in diagnostic messages. + ' TODO (acasey): don't canonicalize name (GH #878) + Dim canonicalName = Canonicalize(identifier.GetIdentifierText()) Dim local = LocalSymbol.Create( _containingMethod, Me, identifier, LocalDeclarationKind.ImplicitVariable, - type) - _implicitDeclarations.Add(Canonicalize(local.Name), local) + type, + canonicalName) + _implicitDeclarations.Add(canonicalName, local) If local.Name.StartsWith("$", StringComparison.Ordinal) Then diagnostics.Add(ERRID.ERR_IllegalChar, identifier.GetLocation()) End If @@ -132,7 +134,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator End Select End Function - Friend Shared Function Canonicalize(name As String) As String + Private Shared Function Canonicalize(name As String) As String Return CaseInsensitiveComparison.ToLower(name) End Function diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.vb index 32078614149df45ee5013457ee40a9e8f86494c0..72386cad25c35b3a07ce89bec5362eb9ecc82b61 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.vb @@ -60,7 +60,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator ' CreateVariable(type As Type, name As String) Dim method = PlaceholderLocalSymbol.GetIntrinsicMethod(compilation, ExpressionCompilerConstants.CreateVariableMethodName) Dim type = New BoundGetType(syntax, New BoundTypeExpression(syntax, local.Type), typeType) - Dim name = New BoundLiteral(syntax, ConstantValue.Create(PlaceholderLocalBinder.Canonicalize(local.Name)), stringType) + Dim name = New BoundLiteral(syntax, ConstantValue.Create(local.Name), stringType) Dim expr = New BoundCall( syntax, method, diff --git a/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/DeclarationTests.vb b/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/DeclarationTests.vb index fe4133c4b7d4269f829448ef5deb41eea4bcdc65..b56c95301dd02f9e80fb66b024cdee3e19bea753 100644 --- a/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/DeclarationTests.vb +++ b/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/DeclarationTests.vb @@ -819,7 +819,7 @@ End Class" // Code size 16 (0x10) .maxstack 1 IL_0000: ldstr ""x"" - IL_0005: call ""Function <>x.<>GetObjectByAlias(String) As Object"" + IL_0005: call ""Function Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetObjectByAlias(String) As Object"" IL_000a: castclass ""String"" IL_000f: ret } @@ -861,11 +861,11 @@ End Class" IL_0000: ldtoken ""Object"" IL_0005: call ""Function System.Type.GetTypeFromHandle(System.RuntimeTypeHandle) As System.Type"" IL_000a: ldstr ""x"" - IL_000f: call ""Sub <>x.<>CreateVariable(System.Type, String)"" + IL_000f: call ""Sub Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.CreateVariable(System.Type, String)"" IL_0014: ldstr ""x"" - IL_0019: call ""Function <>x.<>GetVariableAddress(Of Object)(String) As Object"" + IL_0019: call ""Function Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetVariableAddress(Of Object)(String) As Object"" IL_001e: ldstr ""x"" - IL_0023: call ""Function <>x.<>GetObjectByAlias(String) As Object"" + IL_0023: call ""Function Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetObjectByAlias(String) As Object"" IL_0028: call ""Function System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(Object) As Object"" IL_002d: stind.ref IL_002e: ret diff --git a/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/PseudoVariableTests.vb b/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/PseudoVariableTests.vb index 24281a2e336c93803c98c4ee53a80242bdfdafa3..7ae99aa6c966ab0e06a41c72f5ce0e631894ff3d 100644 --- a/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/PseudoVariableTests.vb +++ b/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/PseudoVariableTests.vb @@ -462,7 +462,8 @@ End Class" expr:="$ReturnValue(Of Object)", resultProperties:=resultProperties, errorMessage:=errorMessage) - Assert.Equal("(1) : error BC32045: '$ReturnValue' has no type parameters and so cannot have type arguments.", errorMessage) + ' TODO (acasey): don't canonicalize name (GH #878) + Assert.Equal("(1) : error BC32045: '$returnvalue' has no type parameters and so cannot have type arguments.", errorMessage) Const source = " Class C