예제 #1
0
        public void SlowSetup(MirrorSharpOptions options)
        {
            // ReSharper disable HeapView.ObjectAllocation.Evident
            // ReSharper disable HeapView.DelegateAllocation
            options.EnableVisualBasic(o => {
                // This setup will only run if the language is used, so branches
                // where no one ever used VB will be faster to open.
                var maxLanguageVersion = Enum.GetValues(typeof(LanguageVersion)).Cast <LanguageVersion>().Max();

                o.ParseOptions = new VisualBasicParseOptions(
                    maxLanguageVersion,
                    documentationMode: DocumentationMode.Diagnose
                    );
                var referencedAssemblies = _referenceCollector.SlowGetAllReferencedAssembliesRecursive(
                    // Essential
                    NetFrameworkRuntime.AssemblyOfValueTuple,
                    NetFrameworkRuntime.AssemblyOfValueTask,
                    NetFrameworkRuntime.AssemblyOfSpan,
                    typeof(StandardModuleAttribute).Assembly,

                    // Runtime
                    typeof(JitGenericAttribute).Assembly,

                    // Requested
                    typeof(XDocument).Assembly,  // System.Xml.Linq
                    typeof(HttpUtility).Assembly // System.Web
                    ).ToImmutableList();
                _assemblyReferenceDiscoveryTaskSource.Complete(referencedAssemblies.Select(a => a.Location).ToImmutableList());
                o.MetadataReferences = referencedAssemblies
                                       .Select(a => (MetadataReference)MetadataReference.CreateFromFile(a.Location, documentation: _documentationResolver.GetDocumentation(a)))
                                       .ToImmutableList();
            });
            // ReSharper restore HeapView.DelegateAllocation
            // ReSharper restore HeapView.ObjectAllocation.Evident
        }
예제 #2
0
        public CSharpAdapter(IAssemblyReferenceCollector referenceCollector, IAssemblyDocumentationResolver documentationResolver)
        {
            var referencedAssemblies = referenceCollector.SlowGetAllReferencedAssembliesRecursive(
                // Essential
                NetFrameworkRuntime.AssemblyOfValueTask,
                NetFrameworkRuntime.AssemblyOfValueTuple,
                NetFrameworkRuntime.AssemblyOfSpan,
                typeof(Binder).Assembly,

                // Runtime
                typeof(JitGenericAttribute).Assembly,

                // Requested
                typeof(XDocument).Assembly,   // System.Xml.Linq
                typeof(IDataReader).Assembly, // System.Data
                typeof(HttpUtility).Assembly  // System.Web
                ).ToImmutableList();

            var assemblyReferenceTaskSource = new AssemblyReferenceDiscoveryTaskSource();

            assemblyReferenceTaskSource.Complete(referencedAssemblies.Select(a => a.Location).ToImmutableList());
            AssemblyReferenceDiscoveryTask = assemblyReferenceTaskSource.Task;

            _references = referencedAssemblies
                          .Select(a => (MetadataReference)MetadataReference.CreateFromFile(a.Location, documentation: documentationResolver.GetDocumentation(a)))
                          .ToImmutableList();
        }