Skip to content

Commit

Permalink
Merge pull request #787 from amcasey/GH443
Browse files Browse the repository at this point in the history
Suggest adding Microsoft.VisualBasic for ERR_MissingRuntimeHelper
  • Loading branch information
amcasey committed Feb 23, 2015
2 parents 983e1b2 + c80cb40 commit 28ceb71
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal abstract class EvaluationContextBase
internal static readonly AssemblyIdentity SystemCoreIdentity = new AssemblyIdentity("System.Core");
internal static readonly AssemblyIdentity SystemXmlIdentity = new AssemblyIdentity("System.Xml");
internal static readonly AssemblyIdentity SystemXmlLinqIdentity = new AssemblyIdentity("System.Xml.Linq");
internal static readonly AssemblyIdentity MicrosoftVisualBasicIdentity = new AssemblyIdentity("Microsoft.VisualBasic");

/// <summary>
/// Compile C# expression and emit assembly with evaluation method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator
End If
Case ERRID.ERR_XmlFeaturesNotAvailable
Return ImmutableArray.Create(SystemIdentity, SystemCoreIdentity, SystemXmlIdentity, SystemXmlLinqIdentity)
Case ERRID.ERR_MissingRuntimeHelper
Return ImmutableArray.Create(MicrosoftVisualBasicIdentity)
End Select

Return Nothing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests
EvaluationContextBase.SystemXmlLinqIdentity)
End Sub

<Fact>
Public Sub ErrorsRequiringVbCore()
Assert.Equal(EvaluationContextBase.MicrosoftVisualBasicIdentity, GetMissingAssemblyIdentities(ERRID.ERR_MissingRuntimeHelper).Single())
End Sub

<Fact>
Public Sub MultipleAssemblyArguments()
Dim identity1 = New AssemblyIdentity(GetUniqueName())
Expand Down Expand Up @@ -192,6 +197,38 @@ End Class
EvaluationContextBase.SystemXmlLinqIdentity)
End Sub

<Fact>
Public Sub ERR_MissingRuntimeAssembly()
Const source = "
Public Class C
Public Sub M(o As Object)
End Sub
End Class
"
Dim comp = CreateCompilationWithMscorlib({source}, compOptions:=TestOptions.DebugDll)
Dim context = CreateMethodContextWithReferences(comp, "C.M", MscorlibRef)

Const expectedError = "(1,2): error BC35000: Requested operation is not available because the runtime library function 'Microsoft.VisualBasic.CompilerServices.Operators.CompareObjectEqual' is not defined."
Dim expectedMissingAssemblyIdentity = EvaluationContextBase.MicrosoftVisualBasicIdentity

Dim resultProperties As ResultProperties = Nothing
Dim actualError As String = Nothing
Dim actualMissingAssemblyIdentities As ImmutableArray(Of AssemblyIdentity) = Nothing

context.CompileExpression(
DefaultInspectionContext.Instance,
"o = o",
DkmEvaluationFlags.TreatAsExpression,
DiagnosticFormatter.Instance,
resultProperties,
actualError,
actualMissingAssemblyIdentities,
EnsureEnglishUICulture.PreferredOrNull,
testData:=Nothing)
Assert.Equal(expectedError, actualError)
Assert.Equal(expectedMissingAssemblyIdentity, actualMissingAssemblyIdentities.Single())
End Sub

<WorkItem(1124725, "DevDiv")>
<WorkItem(597, "GitHub")>
<Fact>
Expand Down

0 comments on commit 28ceb71

Please sign in to comment.