public void TestAnalyzerLoading_AppDomain()
        {
            var dir = Temp.CreateDirectory();

            dir.CopyFile(typeof(AppDomainUtils).Assembly.Location);
            dir.CopyFile(typeof(RemoteAnalyzerFileReferenceTest).Assembly.Location);
            var analyzerFile = DesktopTestHelpers.CreateCSharpAnalyzerAssemblyWithTestAnalyzer(
                dir,
                "MyAnalyzer"
                );
            var loadDomain = AppDomainUtils.Create("AnalyzerTestDomain", basePath: dir.Path);

            try
            {
                // Test analyzer load success.
                var remoteTest =
                    (RemoteAnalyzerFileReferenceTest)loadDomain.CreateInstanceAndUnwrap(
                        typeof(RemoteAnalyzerFileReferenceTest).Assembly.FullName,
                        typeof(RemoteAnalyzerFileReferenceTest).FullName
                        );
                var exception = remoteTest.LoadAnalyzer(analyzerFile.Path);
                Assert.Null(exception);
            }
            finally
            {
                AppDomain.Unload(loadDomain);
            }
        }
예제 #2
0
        private static Type[] GetNeutralAndCSharpAndVisualBasicTypes()
        {
            var types = new[]
            {
                // ROSLYN
                typeof(CodeAnalysis.CSharp.IntroduceVariable.CSharpIntroduceVariableService),           // Ensures that CSharpFeatures is included in the composition
                typeof(CodeAnalysis.VisualBasic.IntroduceVariable.VisualBasicIntroduceVariableService), // Ensures that BasicFeatures is included in the composition
                typeof(CSharp.ContentType.ContentTypeDefinitions),                                      // CSharp Content Type
                typeof(VisualBasic.ContentType.ContentTypeDefinitions),                                 // VB Content Type
                typeof(VisualBasic.Formatting.Indentation.VisualBasicIndentationService),
                typeof(CSharp.Formatting.Indentation.CSharpIndentationService),
                typeof(CodeAnalysis.CSharp.CSharpCompilationFactoryService),
                typeof(CodeAnalysis.VisualBasic.VisualBasicCompilationFactoryService),
                typeof(CodeAnalysis.CSharp.CSharpSyntaxTreeFactoryServiceFactory),           // CSharpServicesCore
                typeof(CodeAnalysis.VisualBasic.VisualBasicSyntaxTreeFactoryServiceFactory), // BasicServicesCore
                typeof(CodeAnalysis.CSharp.CodeGeneration.CSharpCodeGenerationServiceFactory),
                typeof(CodeAnalysis.VisualBasic.CodeGeneration.VisualBasicCodeGenerationServiceFactory),
                typeof(CodeAnalysis.CSharp.CSharpSyntaxFactsServiceFactory),
                typeof(CodeAnalysis.VisualBasic.VisualBasicSyntaxFactsServiceFactory),
                typeof(CodeAnalysis.CSharp.CSharpSymbolDeclarationService),
                typeof(CodeAnalysis.VisualBasic.VisualBasicSymbolDeclarationService),
                typeof(CSharp.LanguageServices.CSharpSymbolDisplayServiceFactory),
                typeof(CSharp.Interactive.CSharpInteractiveEvaluator),
                typeof(VisualBasic.LanguageServices.VisualBasicSymbolDisplayServiceFactory),
                typeof(VisualBasic.Interactive.VisualBasicInteractiveEvaluator),
                typeof(CodeAnalysis.CSharp.Simplification.CSharpSimplificationService),
                typeof(CodeAnalysis.VisualBasic.Simplification.VisualBasicSimplificationService),
                typeof(CodeAnalysis.CSharp.Rename.CSharpRenameConflictLanguageService),
                typeof(CodeAnalysis.VisualBasic.Rename.VisualBasicRenameRewriterLanguageServiceFactory),
                typeof(CodeAnalysis.CSharp.CSharpSemanticFactsServiceFactory),
                typeof(CodeAnalysis.VisualBasic.VisualBasicSemanticFactsServiceFactory),
                typeof(CodeAnalysis.CSharp.CodeGeneration.CSharpSyntaxGenerator),
                typeof(CodeAnalysis.VisualBasic.CodeGeneration.VisualBasicSyntaxGenerator),
                typeof(CSharp.LanguageServices.CSharpContentTypeLanguageService),
                typeof(VisualBasic.LanguageServices.VisualBasicContentTypeLanguageService),
                typeof(CodeAnalysis.CSharp.Execution.CSharpOptionsSerializationService),
                typeof(CodeAnalysis.VisualBasic.Execution.VisualBasicOptionsSerializationService),
                typeof(CodeAnalysis.Execution.DesktopReferenceSerializationServiceFactory),
                typeof(TestExportProvider)
            };

            return(ServiceTestExportProvider.GetLanguageNeutralTypes()
                   .Concat(types)
                   .Concat(DesktopTestHelpers.GetAllTypesImplementingGivenInterface(
                               typeof(CodeAnalysis.CSharp.Formatting.DefaultOperationProvider).Assembly, typeof(ISyntaxFormattingService)))
                   .Concat(DesktopTestHelpers.GetAllTypesImplementingGivenInterface(
                               typeof(CodeAnalysis.VisualBasic.Formatting.DefaultOperationProvider).Assembly, typeof(ISyntaxFormattingService)))
                   .Concat(DesktopTestHelpers.GetAllTypesImplementingGivenInterface(
                               typeof(CodeAnalysis.CSharp.Formatting.DefaultOperationProvider).Assembly, typeof(IFormattingRule)))
                   .Concat(DesktopTestHelpers.GetAllTypesImplementingGivenInterface(
                               typeof(CodeAnalysis.VisualBasic.Formatting.DefaultOperationProvider).Assembly, typeof(IFormattingRule)))
                   .Concat(DesktopTestHelpers.GetAllTypesImplementingGivenInterface(
                               typeof(CodeAnalysis.CSharp.Formatting.DefaultOperationProvider).Assembly, typeof(ICodeGenerationService)))
                   .Concat(DesktopTestHelpers.GetAllTypesImplementingGivenInterface(
                               typeof(CodeAnalysis.VisualBasic.Formatting.DefaultOperationProvider).Assembly, typeof(ICodeGenerationService)))
                   .Concat(TestHelpers.GetAllTypesWithStaticFieldsImplementingType(typeof(CodeAnalysis.CSharp.Formatting.CSharpFormattingOptions).Assembly, typeof(CodeAnalysis.Options.IOption)))
                   .Distinct()
                   .ToArray());
        }
예제 #3
0
 static IntegrationTests()
 {
     s_msbuildDirectory = DesktopTestHelpers.GetMSBuildDirectory();
     if (s_msbuildDirectory != null)
     {
         s_msbuildExecutable = Path.Combine(s_msbuildDirectory, "MSBuild.exe");
     }
 }
예제 #4
0
        protected override ExportProvider GetExportProvider()
        {
            // Get all the liveshare request handlers in this assembly.
            var liveShareRequestHelperTypes = DesktopTestHelpers.GetAllTypesImplementingGivenInterface(
                typeof(LoadHandler).Assembly, typeof(ILspRequestHandler));
            // Get all of the roslyn request helpers in M.CA.LanguageServer
            var roslynRequestHelperTypes = DesktopTestHelpers.GetAllTypesImplementingGivenInterface(
                typeof(RoslynHandlers.IRequestHandler).Assembly, typeof(RoslynHandlers.IRequestHandler));
            var exportProviderFactory = ExportProviderCache.GetOrCreateExportProviderFactory(
                TestExportProvider.EntireAssemblyCatalogWithCSharpAndVisualBasic
                .WithPart(typeof(MockDocumentNavigationServiceFactory))
                .WithParts(liveShareRequestHelperTypes)
                .WithParts(roslynRequestHelperTypes));

            return(exportProviderFactory.CreateExportProvider());
        }
예제 #5
0
 static IntegrationTests()
 {
     s_msbuildDirectory = DesktopTestHelpers.GetMSBuildDirectory();
 }