Beispiel #1
0
        /// <summary>
        /// Resolves metadata references stored in command line arguments and reports errors for those that can't be resolved.
        /// </summary>
        internal List <MetadataReference> ResolveMetadataReferences(
            MetadataFileReferenceResolver externalReferenceResolver,
            MetadataFileReferenceProvider metadataProvider,
            List <DiagnosticInfo> diagnostics,
            AssemblyIdentityComparer assemblyIdentityComparer,
            TouchedFileLogger touchedFiles,
            out MetadataFileReferenceResolver referenceDirectiveResolver)
        {
            List <MetadataReference> resolved = new List <MetadataReference>();

            Arguments.ResolveMetadataReferences(new AssemblyReferenceResolver(externalReferenceResolver, metadataProvider), diagnostics, this.MessageProvider, resolved);

            if (Arguments.IsInteractive)
            {
                referenceDirectiveResolver = externalReferenceResolver;
            }
            else
            {
                // when compiling into an assembly (csc/vbc) we only allow #r that match references given on command line:
                referenceDirectiveResolver = new ExistingReferencesResolver(
                    resolved.Where(r => r.Properties.Kind == MetadataImageKind.Assembly).OfType <PortableExecutableReference>().AsImmutable(),
                    Arguments.ReferencePaths,
                    Arguments.BaseDirectory,
                    assemblyIdentityComparer,
                    touchedFiles);
            }

            return(resolved);
        }
Beispiel #2
0
        public void Run()
        {
            Solution sln = LoadSolution();

            //var externalProject = sln.Projects.FirstOrDefault(x => x.AssemblyName == externalNs);
            //if (externalProject == null)
            //{
            //    var msg = string.Format("Project for given external-facing namespace of {0} not found.", externalNs);
            //    messagePump.OnError(new ArgumentException(msg));
            //    return;
            //}

            SendMessage(string.Format("{1}Using {0} for process discovery{1}", processTypeName ?? DefaultProcessIfxName, Environment.NewLine));

            var token = new CancellationToken();
            var analyzer = new MIL.Services.ProcessAnalysisService(processIName);

            //ProcessDefinition processDefinition = null;
            var excludeList = sln.Projects.Where(x => ExcludedAssemblies.Any(e => x.AssemblyName.Contains(e))).ToList();
            if (excludeList.Any())
            {
                SendMessage(string.Format("Ignoring {0} Assemblies{1}", excludeList.Count, Environment.NewLine),
                    () => "Ignored assemblies: " + Environment.NewLine + string.Join(Environment.NewLine, excludeList.Select(x => x.AssemblyName)) + Environment.NewLine);
            }

            MilSyntaxWalker treeData = new MilSyntaxWalker();
            foreach (var proj in sln.Projects.Except(excludeList))
            {
                SendMessage(".", () => Environment.NewLine + "# Processing assembly " + proj.AssemblyName + Environment.NewLine);

                MilSemanticAnalyzer semantics = null;
                MetadataFileReferenceProvider provider = new MetadataFileReferenceProvider();
                Compilation compilation = (Compilation)proj.GetCompilationAsync(token).Result
                    .AddReferences(new MetadataFileReference(typeof(object).Assembly.Location))
                    .AddReferences(new MetadataFileReference(typeof(IEnumerable<>).Assembly.Location)); ;

                try
                {
                    semantics = new MilSemanticAnalyzer(compilation);
                }
                catch (InvalidOperationException ex)
                {
                    SendMessage("x", () => string.Join(Environment.NewLine, compilation.GetDeclarationDiagnostics().Select(x => x.ToString())) + Environment.NewLine);
                    continue;
                }

                semantics.ExtractMessagingSyntax(treeData);

                //if (proj.AssemblyName == externalProject.AssemblyName)
                //    continue;

                //processDefinition = analyzer.GetProcessDefinition(compilation, processTypeName);


                //if (processDefinition != null)
                //{
                //    var procToke = ProcessDefinition.GetTokenFromDefinition(processDefinition);

                //    if (procToke.Token != MilTypeConstant.EmptyToken)
                //        SendMessage(procToke.ToString());
                //}
                //foreach (var pubCall in semantics.GetMessagePublicationData())
                //{
                //    SendMessage(pubCall.ToString());
                //}
            }

            DumpSyntaxData(treeData);

            messagePump.OnCompleted();
        }
 public CSharpScriptEngine(MetadataFileReferenceProvider metadataReferenceProvider = null)
     : base(metadataReferenceProvider)
 {
 }
Beispiel #4
0
        /// <summary>
        /// Resolves metadata references stored in command line arguments and reports errors for those that can't be resolved.
        /// </summary>
        internal List<MetadataReference> ResolveMetadataReferences(
            MetadataFileReferenceResolver externalReferenceResolver,
            MetadataFileReferenceProvider metadataProvider,
            List<DiagnosticInfo> diagnostics,
            AssemblyIdentityComparer assemblyIdentityComparer,
            TouchedFileLogger touchedFiles,
            out MetadataFileReferenceResolver referenceDirectiveResolver)
        {
            List<MetadataReference> resolved = new List<MetadataReference>();
            Arguments.ResolveMetadataReferences(new AssemblyReferenceResolver(externalReferenceResolver, metadataProvider), diagnostics, this.MessageProvider, resolved);

            if (Arguments.IsInteractive)
            {
                referenceDirectiveResolver = externalReferenceResolver;
            }
            else
            {
                // when compiling into an assembly (csc/vbc) we only allow #r that match references given on command line:
                referenceDirectiveResolver = new ExistingReferencesResolver(
                    CreateLoggingMetadataResolver(touchedFiles),
                    resolved.Where(r => r.Properties.Kind == MetadataImageKind.Assembly).OfType<PortableExecutableReference>().AsImmutable(),
                    assemblyIdentityComparer);
            }

            return resolved;
        }
Beispiel #5
0
 public AssemblyReferenceResolver(MetadataFileReferenceResolver pathResolver, MetadataFileReferenceProvider provider)
 {
     Debug.Assert(pathResolver != null && provider != null);
     this.PathResolver = pathResolver;
     this.Provider     = provider;
 }
Beispiel #6
0
 public CSharpScriptEngine(MetadataFileReferenceProvider metadataReferenceProvider = null, AssemblyLoader assemblyLoader = null)
     : base(metadataReferenceProvider, assemblyLoader)
 {
 }
Beispiel #7
0
        /// <summary>
        /// Creates a new <see cref="ScriptOptions"/> with the reference provider specified.
        /// </summary>
        internal ScriptOptions WithReferenceProvider(MetadataFileReferenceProvider provider)
        {
            if (provider == _referenceResolver.Provider)
            {
                return this;
            }

            return With(resolver: new AssemblyReferenceResolver(_referenceResolver.PathResolver, provider));
        }
 public AssemblyReferenceResolver(MetadataFileReferenceResolver pathResolver, MetadataFileReferenceProvider provider)
 {
     Debug.Assert(pathResolver != null && provider != null);
     this.PathResolver = pathResolver;
     this.Provider = provider;
 }