VisualStudioTestExportProvider.vb 2.2 KB
Newer Older
J
Jonathon Marolf 已提交
1 2 3
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
4

5
Imports System.Composition
6
Imports Microsoft.CodeAnalysis.Test.Utilities
7 8 9
Imports Microsoft.VisualStudio.Composition
Imports Microsoft.VisualStudio.LanguageServices.CSharp.CodeModel
Imports Microsoft.VisualStudio.LanguageServices.VisualBasic.CodeModel
H
HeeJae Chang 已提交
10 11
Imports Microsoft.CodeAnalysis.Host
Imports Microsoft.CodeAnalysis.Host.Mef
H
HeeJae Chang 已提交
12
Imports Microsoft.CodeAnalysis.Editor.UnitTests
13 14 15

Namespace Microsoft.VisualStudio.LanguageServices.UnitTests
    Public Module VisualStudioTestExportProvider
16
#Disable Warning IDE0040 ' Add accessibility modifiers - https://github.com/dotnet/roslyn/issues/45962
17
        Sub New()
18
#Enable Warning IDE0040 ' Add accessibility modifiers
19 20 21
            Dim additionalAssemblies = {GetType(CSharpCodeModelService).Assembly,
                                        GetType(VisualBasicCodeModelService).Assembly}

H
HeeJae Chang 已提交
22 23 24
            Factory = ExportProviderCache.GetOrCreateExportProviderFactory(
                TestExportProvider.EntireAssemblyCatalogWithCSharpAndVisualBasic.WithParts(
                    ExportProviderCache.GetOrCreateAssemblyCatalog(additionalAssemblies)).WithPart(GetType(MockWorkspaceEventListenerProvider)))
25 26
        End Sub

27
        Public ReadOnly Property Factory As IExportProviderFactory
H
HeeJae Chang 已提交
28 29 30

        ' mock default workspace event listener so that we don't try to enable solution crawler and etc
        ' implicitly
H
HeeJae Chang 已提交
31
        <ExportWorkspaceServiceFactory(GetType(IWorkspaceEventListenerService), ServiceLayer.Host), System.Composition.Shared>
H
HeeJae Chang 已提交
32 33
        Friend Class MockWorkspaceEventListenerProvider
            Implements IWorkspaceServiceFactory
34 35

            <ImportingConstructor>
36
            <Obsolete(MefConstruction.ImportingConstructorMessage, True)>
37 38 39
            Public Sub New()
            End Sub

H
HeeJae Chang 已提交
40 41 42 43
            Public Function CreateService(workspaceServices As HostWorkspaceServices) As IWorkspaceService Implements IWorkspaceServiceFactory.CreateService
                Return Nothing
            End Function
        End Class
44 45
    End Module
End Namespace