Пример #1
0
        private MetadataReference ResolveReference(string name)
        {
            if (_nuGetConfiguration != null)
            {
                name = _nuGetConfiguration.ResolveReference(name);
            }

            if (File.Exists(name))
            {
                return(RoslynHost.CreateMetadataReference(name));
            }
            try
            {
                var location = _gacResolver?.Resolve(name);
                if (location != null)
                {
                    return(RoslynHost.CreateMetadataReference(location));
                }
            }
            catch (Exception)
            {
            }

            return(null);
        }
Пример #2
0
        public MainWindow()
        {
            this.InitializeComponent();

            var additionalAssemblies = new[]
            {
                Assembly.Load("RoslynPad.Roslyn.Windows"),
                Assembly.Load("RoslynPad.Editor.Windows"),
                Assembly.Load("LogfileReader"),
            };

            var hostReferences = RoslynHostReferences
                                 .Default
                                 .With(typeNamespaceImports: new[]
            {
                typeof(LogEntry),
                typeof(DocumentViewModel),                                                 // ???
                typeof(Globals),
                typeof(XmlSerializer)
            });

            this.host = new RoslynHostWithGlobals <Globals>(
                additionalAssemblies: additionalAssemblies,
                references: hostReferences);

            this.DataContext = new DocumentViewModel(this.host);
        }
Пример #3
0
        public RoslynWorkspace(HostServices hostServices, string workspaceKind = WorkspaceKind.Host, RoslynHost roslynHost = null)
            : base(hostServices, workspaceKind)
        {
            DiagnosticProvider.Enable(this, DiagnosticProvider.Options.Semantic);

            RoslynHost = roslynHost;
        }
 private MetadataReference ResolveReference(string name)
 {
     if (_nuGetConfiguration != null)
     {
         name = _nuGetConfiguration.ResolveReference(name);
     }
     if (File.Exists(name))
     {
         return(RoslynHost.CreateMetadataReference(name));
     }
     try
     {
         var assemblyName = GlobalAssemblyCache.Instance.ResolvePartialName(name);
         if (assemblyName == null)
         {
             return(null);
         }
         var assembly = Assembly.Load(assemblyName.ToString());
         return(RoslynHost.CreateMetadataReference(assembly.Location));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Пример #5
0
        protected internal RoslynWorkspace(HostServices host, RoslynHost roslynHost)
            : base(host, WorkspaceKind.Host)
        {
            RoslynHost = roslynHost;

            DiagnosticProvider.Enable(this, DiagnosticProvider.Options.Semantic);
        }
Пример #6
0
        internal RoslynWorkspace(HostServices host, NuGetConfiguration nuGetConfiguration, RoslynHost roslynHost)
            : base(host, WorkspaceKind.Host)
        {
            _nuGetConfiguration   = nuGetConfiguration;
            _referencesDirectives = new ConcurrentDictionary <string, DirectiveInfo>();

            RoslynHost = roslynHost;
        }
Пример #7
0
        internal RoslynWorkspace(HostServices host, NuGetConfiguration nuGetConfiguration, RoslynHost roslynHost)
            : base(host, WorkspaceKind.Host)
        {
            _nuGetConfiguration   = nuGetConfiguration;
            _referencesDirectives = new ConcurrentDictionary <string, DirectiveInfo>();
            _gacResolver          = GacFileResolver.IsAvailable ? new GacFileResolver() : null;

            RoslynHost = roslynHost;
        }
Пример #8
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;
        }
Пример #9
0
 internal RoslynWorkspace(HostServices host, RoslynHost roslynHost)
     : base(host, WorkspaceKind.Host)
 {
     RoslynHost = roslynHost;
 }