protected AbstractReferenceSerializationService(
     ITemporaryStorageService storageService,
     IDocumentationProviderService documentationService)
 {
     _storageService       = storageService;
     _documentationService = documentationService;
 }
Example #2
0
 public Service(IDocumentationProviderService documentationService)
 {
     _metadataCache = new MetadataReferenceCache(
         (path, properties) =>
         MetadataReference.CreateFromFile(
             path,
             properties,
             documentationService.GetDocumentationProvider(path)
             )
         );
 }
Example #3
0
        public RoslynHost(NuGetConfiguration nuGetConfiguration       = null,
                          IEnumerable <Assembly> additionalAssemblies = null,
                          RoslynHostReferences references             = null)
        {
            _nuGetConfiguration = nuGetConfiguration;
            if (references == null)
            {
                references = RoslynHostReferences.Default;
            }

            _workspaces = new ConcurrentDictionary <DocumentId, RoslynWorkspace>();
            _diagnosticsUpdatedNotifiers = new ConcurrentDictionary <DocumentId, Action <DiagnosticsUpdatedArgs> >();

            IEnumerable <Assembly> assemblies = new[]
            {
                Assembly.Load(new AssemblyName("Microsoft.CodeAnalysis")),
                Assembly.Load(new AssemblyName("Microsoft.CodeAnalysis.CSharp")),
                Assembly.Load(new AssemblyName("Microsoft.CodeAnalysis.Features")),
                Assembly.Load(new AssemblyName("Microsoft.CodeAnalysis.CSharp.Features")),
                typeof(RoslynHost).GetTypeInfo().Assembly,
            };

            if (additionalAssemblies != null)
            {
                assemblies = assemblies.Concat(additionalAssemblies);
            }

            var partTypes = MefHostServices.DefaultAssemblies.Concat(assemblies)
                            .Distinct()
                            .SelectMany(x => x.DefinedTypes)
                            .Select(x => x.AsType())
                            .ToArray();

            _compositionContext = new ContainerConfiguration()
                                  .WithParts(partTypes)
                                  .CreateContainer();

            _host = MefHostServices.Create(_compositionContext);

            _parseOptions = new CSharpParseOptions(kind: SourceCodeKind.Script,
                                                   preprocessorSymbols: PreprocessorSymbols, languageVersion: LanguageVersion.Latest);

            _documentationProviderService = GetService <IDocumentationProviderService>();

            DefaultReferences = references.GetReferences(_documentationProviderService.GetDocumentationProvider);
            DefaultImports    = references.Imports;

            GetService <IDiagnosticService>().DiagnosticsUpdated += OnDiagnosticsUpdated;

            GetService <ISyntaxChangeNotificationService>().OpenedDocumentSyntaxChanged += OnSyntaxChanged;
        }
Example #4
0
        public RoslynHost(IEnumerable <Assembly> additionalAssemblies = null,
                          RoslynHostReferences references             = null,
                          ImmutableArray <string>?disabledDiagnostics = null)
        {
            if (references == null)
            {
                references = RoslynHostReferences.Empty;
            }

            _workspaces = new ConcurrentDictionary <DocumentId, RoslynWorkspace>();
            _diagnosticsUpdatedNotifiers = new ConcurrentDictionary <DocumentId, Action <DiagnosticsUpdatedArgs> >();

            // ReSharper disable once VirtualMemberCallInConstructor
            var assemblies = GetDefaultCompositionAssemblies();

            if (additionalAssemblies != null)
            {
                assemblies = assemblies.Concat(additionalAssemblies);
            }

            var partTypes = assemblies
                            .SelectMany(x => x.DefinedTypes)
                            .Select(x => x.AsType());

            _compositionContext = new ContainerConfiguration()
                                  .WithParts(partTypes)
                                  .CreateContainer();

            HostServices = MefHostServices.Create(_compositionContext);

            // ReSharper disable once VirtualMemberCallInConstructor
            _parseOptions = CreateDefaultParseOptions();

            _documentationProviderService = GetService <IDocumentationProviderService>();

            DefaultReferences = references.GetReferences(DocumentationProviderFactory);
            DefaultImports    = references.Imports;

            DisabledDiagnostics = disabledDiagnostics ?? ImmutableArray <string> .Empty;
            GetService <IDiagnosticService>().DiagnosticsUpdated += OnDiagnosticsUpdated;
        }
Example #5
0
        //static void WorkaroundForDesktopShim( Type typeInAssembly )
        //{
        //	// DesktopShim doesn't work on Linux, so we hack around it

        //	typeInAssembly.GetTypeInfo().Assembly
        //		.GetType( "Roslyn.Utilities.DesktopShim+FileNotFoundException" )
        //		?.GetRuntimeFields().FirstOrDefault( f => f.Name == "s_fusionLog" )
        //		?.SetValue( null, typeof( Exception ).GetRuntimeProperty( nameof( Exception.InnerException ) ) );
        //}

        public RoslynHost(NuGetConfiguration nuGetConfiguration)
        {
            instance = this;

            _nuGetConfiguration          = nuGetConfiguration;
            _diagnosticsUpdatedNotifiers = new ConcurrentDictionary <DocumentId, Action <DiagnosticsUpdatedArgs> >();

            //!!!!
            var assemblies = ImmutableArray.Create(
                // Microsoft.CodeAnalysis.Workspaces
                typeof(WorkspacesResources).GetTypeInfo().Assembly,
                // Microsoft.CodeAnalysis.CSharp.Workspaces
                typeof(CSharpWorkspaceResources).GetTypeInfo().Assembly,
                // Microsoft.CodeAnalysis.Features
                typeof(FeaturesResources).GetTypeInfo().Assembly,
                // Microsoft.CodeAnalysis.CSharp.Features
                typeof(CSharpFeaturesResources).GetTypeInfo().Assembly,
                // RoslynPad.Roslyn
                typeof(RoslynHost).GetTypeInfo().Assembly);

            //!!!!
            try
            {
                var additionalAssemblies = ImmutableArray.Create(
                    Assembly.Load(new AssemblyName("RoslynPad.Roslyn.Windows")),
                    Assembly.Load(new AssemblyName("RoslynPad.Editor.Windows"))
                    );
                assemblies = assemblies.Concat(additionalAssemblies);
            }
            catch { }

            var partTypes = assemblies.SelectMany(x => x.DefinedTypes).Select(x => x.AsType());

            _compositionContext = new ContainerConfiguration().WithParts(partTypes).CreateContainer();
            HostServices        = MefHostServices.Create(_compositionContext);

            _documentationProviderService = GetService <IDocumentationProviderService>();

            GetService <IDiagnosticService>().DiagnosticsUpdated += OnDiagnosticsUpdated;
        }
 public Service(ITemporaryStorageService service, IDocumentationProviderService documentationService) :
     base(service, documentationService)
 {
 }
Example #7
0
 public Service(IDocumentationProviderService documentationService)
 {
     _documentationService = documentationService;
     _provider             = new Provider(this);
 }
 public DocumentationProviderServiceFactory(IDocumentationProviderService service) => _service = service;
 public Service(IDocumentationProviderService documentationService)
 {
     this.documentationService = documentationService;
     this.provider = new Provider(this);
 }
 public Service(IDocumentationProviderService documentationService)
 {
     _provider = new Provider(this);
     _metadataCache = new MetadataReferenceCache((path, properties) =>
         MetadataReference.CreateFromFile(path, properties, documentationService.GetDocumentationProvider(path)));
 }
 public Provider(IDocumentationProviderService documentationService)
 {
     this.documentationService = documentationService;
 }        
Example #12
0
 public Provider(IDocumentationProviderService documentationService)
 {
     this.documentationService = documentationService;
 }