Vbi.vb 2.8 KB
Newer Older
1 2 3 4 5
' Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

Imports System.Globalization
Imports System.IO
Imports System.Reflection
6
Imports System.Runtime.InteropServices
7
Imports Microsoft.CodeAnalysis
8
Imports Microsoft.CodeAnalysis.Diagnostics
9 10
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.VisualStudio.Shell.Interop
11
Imports Microsoft.CodeAnalysis.Scripting
12
Imports Roslyn.Utilities
13 14 15 16 17 18 19 20
Imports VisualBasicInteractive.BasicInteractive

Friend NotInheritable Class Vbi
    Inherits VisualBasicCompiler

    Friend Const InteractiveResponseFileName As String = "vbi.rsp"

    Friend Sub New(responseFile As String, baseDirectory As String, args As String())
J
Jared Parsons 已提交
21
        MyBase.New(VisualBasicCommandLineParser.Interactive, responseFile, args, Path.GetDirectoryName(GetType(VisualBasicCompiler).Assembly.Location), baseDirectory, RuntimeEnvironment.GetRuntimeDirectory(), Nothing) ' TODO: what to pass as additionalReferencePaths?
22 23
    End Sub

B
beep boop 已提交
24
    Public Shared Function Main(args As String()) As Integer
25
        Try
26
            Dim responseFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, InteractiveResponseFileName)
J
Jared Parsons 已提交
27
            Return ScriptCompilerUtil.RunInteractive(New Vbi(responseFile, Directory.GetCurrentDirectory(), args), Console.Out)
28 29 30 31 32 33
        Catch ex As Exception
            Console.WriteLine(ex.ToString())
            Return Failed
        End Try
    End Function

J
Jared Parsons 已提交
34 35 36 37
    Public Overrides Function LoadAssembly(fullPath As String) As Assembly
        Throw New NotImplementedException()
    End Function

38 39 40 41 42
    Friend Overrides Function GetExternalMetadataResolver(touchedFiles As TouchedFileLogger) As MetadataFileReferenceResolver
        ' We don't log touched files atm.
        Return New GacFileResolver(Arguments.ReferencePaths, Arguments.BaseDirectory, GacFileResolver.Default.Architectures, CultureInfo.CurrentCulture)
    End Function

J
Jared Parsons 已提交
43
    Public Overrides Sub PrintLogo(consoleOutput As TextWriter)
44 45 46 47 48 49
        Dim thisAssembly As Assembly = GetType(Vbi).Assembly
        consoleOutput.WriteLine(VbiResources.LogoLine1, FileVersionInfo.GetVersionInfo(thisAssembly.Location).FileVersion)
        consoleOutput.WriteLine(VbiResources.LogoLine2)
        consoleOutput.WriteLine()
    End Sub

J
Jared Parsons 已提交
50
    Public Overrides Sub PrintHelp(consoleOutput As TextWriter)
51 52 53
        ' TODO
        consoleOutput.WriteLine("                        Roslyn Interactive Compiler Options")
    End Sub
J
Jared Parsons 已提交
54

55 56 57
    Protected Overrides Function GetSqmAppID() As UInt32
        Return SqmServiceProvider.BASIC_APPID
    End Function
J
Jared Parsons 已提交
58

59 60 61 62 63 64
    Protected Overrides Sub CompilerSpecificSqm(sqm As IVsSqmMulti, sqmSession As UInt32)
        sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_COMPILERTYPE, CType(SqmServiceProvider.CompilerType.Interactive, UInt32))
    End Sub

End Class