Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps move to EvaluationContext.vb

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you feel strongly, I'd prefer to keep them together for discoverability (i.e. so we don't create duplicate constants because we don't know about existing ones).


/// <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