Example #1
0
 public static ComposableCatalog GetCSharpAndVisualBasicAssemblyCatalog()
 {
     return(ExportProviderCache.GetOrCreateAssemblyCatalog(
                GetNeutralAndCSharpAndVisualBasicTypes().Select(t => t.Assembly).Distinct(), ExportProviderCache.CreateResolver())
            .WithParts(MinimalTestExportProvider.GetEditorAssemblyCatalog())
            .WithDefaultFakes());
 }
Example #2
0
        private static Type[] GetNeutralAndCSharpAndVisualBasicTypes()
        {
            var types = new[]
            {
                // ROSLYN
                typeof(Workspaces.NoCompilationLanguageServiceFactory),
                typeof(Workspaces.NoCompilationContentTypeDefinitions),
                typeof(Workspaces.NoCompilationContentTypeLanguageService),
                typeof(Microsoft.CodeAnalysis.CSharp.IntroduceVariable.CSharpIntroduceVariableService),           // Ensures that CSharpFeatures is included in the composition
                typeof(Microsoft.CodeAnalysis.VisualBasic.IntroduceVariable.VisualBasicIntroduceVariableService), // Ensures that BasicFeatures is included in the composition
                typeof(Microsoft.CodeAnalysis.Editor.CSharp.ContentType.ContentTypeDefinitions),                  // CSharp Content Type
                typeof(Microsoft.CodeAnalysis.Editor.VisualBasic.ContentType.ContentTypeDefinitions),             // VB Content Type
                typeof(Microsoft.CodeAnalysis.Editor.Implementation.SmartIndent.SmartIndentProvider),
                typeof(Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation.VisualBasicIndentationService),
                typeof(Microsoft.CodeAnalysis.Editor.CSharp.Formatting.Indentation.CSharpIndentationService),
                typeof(Microsoft.CodeAnalysis.Editor.Implementation.ForegroundNotification.ForegroundNotificationService),
                typeof(Microsoft.CodeAnalysis.CSharp.CSharpCompilationFactoryService),
                typeof(Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilationFactoryService),
                typeof(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTreeFactoryServiceFactory),           // CSharpServicesCore
                typeof(Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTreeFactoryServiceFactory), // BasicServicesCore
                typeof(CodeAnalysis.CSharp.CodeGeneration.CSharpCodeGenerationServiceFactory),
                typeof(CodeAnalysis.VisualBasic.CodeGeneration.VisualBasicCodeGenerationServiceFactory),
                typeof(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxFactsServiceFactory),
                typeof(Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxFactsServiceFactory),
                typeof(CodeAnalysis.CSharp.CSharpSymbolDeclarationService),
                typeof(CodeAnalysis.VisualBasic.VisualBasicSymbolDeclarationService),
                typeof(CodeAnalysis.Editor.CSharp.LanguageServices.CSharpSymbolDisplayServiceFactory),
                typeof(Microsoft.CodeAnalysis.Editor.CSharp.Interactive.CSharpInteractiveEvaluator),
                typeof(CodeAnalysis.Editor.VisualBasic.LanguageServices.VisualBasicSymbolDisplayServiceFactory),
                typeof(Microsoft.CodeAnalysis.Editor.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.CSharpSemanticFactsService),
                typeof(CodeAnalysis.VisualBasic.VisualBasicSemanticFactsService),
                typeof(CodeAnalysis.CSharp.CodeGeneration.CSharpSyntaxGenerator),
                typeof(CodeAnalysis.VisualBasic.CodeGeneration.VisualBasicSyntaxGenerator),
                typeof(CSharp.LanguageServices.CSharpContentTypeLanguageService),
                typeof(VisualBasic.LanguageServices.VisualBasicContentTypeLanguageService),
                typeof(IncrementalCaches.SymbolTreeInfoIncrementalAnalyzerProvider),
                typeof(CodeAnalysis.Diagnostics.EngineV2.InProcCodeAnalysisDiagnosticAnalyzerExecutor)
            };

            return(MinimalTestExportProvider.GetLanguageNeutralTypes()
                   .Concat(types)
                   .Concat(TestHelpers.GetAllTypesImplementingGivenInterface(typeof(Microsoft.CodeAnalysis.CSharp.Formatting.DefaultOperationProvider).Assembly, typeof(ISyntaxFormattingService)))
                   .Concat(TestHelpers.GetAllTypesImplementingGivenInterface(typeof(Microsoft.CodeAnalysis.VisualBasic.Formatting.DefaultOperationProvider).Assembly, typeof(ISyntaxFormattingService)))
                   .Concat(TestHelpers.GetAllTypesImplementingGivenInterface(typeof(Microsoft.CodeAnalysis.CSharp.Formatting.DefaultOperationProvider).Assembly, typeof(IFormattingRule)))
                   .Concat(TestHelpers.GetAllTypesImplementingGivenInterface(typeof(Microsoft.CodeAnalysis.VisualBasic.Formatting.DefaultOperationProvider).Assembly, typeof(IFormattingRule)))
                   .Concat(TestHelpers.GetAllTypesImplementingGivenInterface(typeof(Microsoft.CodeAnalysis.CSharp.Formatting.DefaultOperationProvider).Assembly, typeof(ICodeGenerationService)))
                   .Concat(TestHelpers.GetAllTypesImplementingGivenInterface(typeof(Microsoft.CodeAnalysis.VisualBasic.Formatting.DefaultOperationProvider).Assembly, typeof(ICodeGenerationService)))
                   .Concat(TestHelpers.GetAllTypesWithStaticFieldsImplementingType(typeof(Microsoft.CodeAnalysis.CSharp.Formatting.CSharpFormattingOptions).Assembly, typeof(Microsoft.CodeAnalysis.Options.IOption)))
                   .Distinct()
                   .ToArray());
        }
        private static ExportProvider GetExportProvider(bool useMinimumCatalog, ComposableCatalog extraParts)
        {
            var baseCatalog = useMinimumCatalog
                ? TestExportProvider.MinimumCatalogWithCSharpAndVisualBasic
                : TestExportProvider.EntireAssemblyCatalogWithCSharpAndVisualBasic;

            if (extraParts == null)
            {
                return(MinimalTestExportProvider.CreateExportProvider(baseCatalog));
            }

            return(MinimalTestExportProvider.CreateExportProvider(baseCatalog.WithParts(extraParts)));
        }
        public static Type[] GetLanguageNeutralTypes()
        {
            var types = new[]
            {
                // ROSLYN
                typeof(Workspaces.NoCompilationLanguageServiceFactory),
                typeof(Workspaces.NoCompilationContentTypeDefinitions),
                typeof(Workspaces.NoCompilationContentTypeLanguageService),
                typeof(Microsoft.CodeAnalysis.Editor.Implementation.SmartIndent.SmartIndentProvider),
                typeof(Microsoft.CodeAnalysis.Editor.Implementation.ForegroundNotification.ForegroundNotificationService),
                typeof(Implementation.InlineRename.InlineRenameService), // Ensure that EditorFeatures.Wpf is included in the composition
                typeof(IncrementalCaches.SymbolTreeInfoIncrementalAnalyzerProvider)
            };

            return(MinimalTestExportProvider.GetLanguageNeutralTypes().Concat(types).Distinct().ToArray());
        }
        public static Type[] GetLanguageNeutralTypes()
        {
            var types = new[]
            {
                // ROSLYN
                typeof(Workspaces.NoCompilationLanguageServiceFactory),
                typeof(Workspaces.NoCompilationContentTypeDefinitions),
                typeof(Workspaces.NoCompilationContentTypeLanguageService),
                typeof(Microsoft.CodeAnalysis.Editor.Implementation.SmartIndent.SmartIndentProvider),
                typeof(Microsoft.CodeAnalysis.Editor.Implementation.ForegroundNotification.ForegroundNotificationService),
                typeof(IncrementalCaches.SymbolTreeInfoIncrementalAnalyzerProvider),
                typeof(CodeAnalysis.Diagnostics.EngineV2.InProcCodeAnalysisDiagnosticAnalyzerExecutor)
            };

            return(MinimalTestExportProvider.GetLanguageNeutralTypes().Concat(types).Distinct().ToArray());
        }
Example #6
0
 public static IEnumerable <Assembly> GetCSharpAndVisualBasicAssemblies()
 {
     return(GetNeutralAndCSharpAndVisualBasicTypes().Select(t => t.Assembly).Distinct().Concat(MinimalTestExportProvider.GetVisualStudioAssemblies()));
 }
Example #7
0
 /// <summary>
 /// Create fresh ComposableCatalog that doest share anything with others. Everything under
 /// this catalog should have been created from scratch that doesn't share anything with
 /// others.
 /// </summary>
 public static ComposableCatalog CreateAssemblyCatalogWithCSharpAndVisualBasic()
 {
     return(MinimalTestExportProvider.CreateAssemblyCatalog(
                GetCSharpAndVisualBasicAssemblies(),
                MinimalTestExportProvider.CreateResolver()));
 }
Example #8
0
 /// <summary>
 /// Create fresh ExportProvider that doesn't share anything with others. Tests can use this
 /// export provider to create all new MEF components not shared with others.
 /// </summary>
 public static ExportProvider CreateExportProviderWithCSharpAndVisualBasic()
 {
     return(MinimalTestExportProvider.CreateExportProvider(CreateAssemblyCatalogWithCSharpAndVisualBasic()));
 }
 public static ComposableCatalog CreateAssemblyCatalog()
 {
     return(MinimalTestExportProvider.CreateAssemblyCatalog(
                GetLanguageNeutralTypes().Select(t => t.Assembly).Distinct().Concat(MinimalTestExportProvider.GetEditorAssemblies()), MinimalTestExportProvider.CreateResolver()));
 }
 public static ComposableCatalog CreateAssemblyCatalog()
 {
     return(ExportProviderCache.GetOrCreateAssemblyCatalog(GetLanguageNeutralTypes().Select(t => t.Assembly).Distinct(), ExportProviderCache.CreateResolver())
            .WithParts(MinimalTestExportProvider.GetEditorAssemblyCatalog()));
 }
Example #11
0
 /// <summary>
 /// Create fresh ComposableCatalog that doesnt share anything with others.
 /// everything under this catalog should have been created from scratch that doesnt share anything with others.
 /// </summary>
 public static ComposableCatalog CreateAssemblyCatalogWithCSharpAndVisualBasic()
 {
     return(MinimalTestExportProvider.CreateAssemblyCatalog(
                GetNeutralAndCSharpAndVisualBasicTypes().Select(t => t.Assembly).Distinct().Concat(MinimalTestExportProvider.GetVisualStudioAssemblies()),
                MinimalTestExportProvider.CreateResolver()));
 }