예제 #1
0
        private void ImportScriptAssembly(MetadataSource mdSource, string assemblyPath, bool coreAssembly)
        {
            string scriptNamespace = null;
            string scriptName      = null;

            AssemblyDefinition assembly;

            if (coreAssembly)
            {
                assembly = mdSource.CoreAssemblyMetadata;
            }
            else
            {
                assembly        = mdSource.GetMetadata(assemblyPath);
                scriptNamespace = MetadataHelpers.GetScriptNamespace(assembly);
            }

            scriptName = MetadataHelpers.GetScriptAssemblyName(assembly);
            if (String.IsNullOrEmpty(scriptName) == false)
            {
                _options.AddReferencedDependency(scriptName);
            }

            if (coreAssembly)
            {
                // Always add an execution reference to the core assembly, since
                // it contains things like the type system, and other APIs assumed by the compiler
                Debug.Assert(String.IsNullOrEmpty(scriptName) == false);
                _options.AddExecutionDependency(scriptName);
            }

            foreach (TypeDefinition type in assembly.MainModule.Types)
            {
                try {
                    if (MetadataHelpers.IsCompilerGeneratedType(type))
                    {
                        continue;
                    }

                    ImportType(mdSource, type, coreAssembly, scriptNamespace, scriptName);
                }
                catch (Exception e) {
                    Debug.Fail(e.ToString());
                }
            }
        }
예제 #2
0
        private void ImportScriptAssembly(MetadataSource mdSource, string assemblyPath, bool coreAssembly)
        {
            string scriptName       = null;
            string scriptIdentifier = null;

            AssemblyDefinition assembly;

            if (coreAssembly)
            {
                assembly = mdSource.CoreAssemblyMetadata;
            }
            else
            {
                assembly = mdSource.GetMetadata(assemblyPath);
            }

            string scriptNamespace = null;

            scriptName = MetadataHelpers.GetScriptAssemblyName(assembly, out scriptIdentifier);
            if (String.IsNullOrEmpty(scriptName) == false)
            {
                ScriptReference dependency = new ScriptReference(scriptName, scriptIdentifier);

                _symbols.AddDependency(dependency);
                scriptNamespace = dependency.Identifier;
            }

            foreach (TypeDefinition type in assembly.MainModule.Types)
            {
                try {
                    if (MetadataHelpers.IsCompilerGeneratedType(type))
                    {
                        continue;
                    }

                    ImportType(mdSource, type, coreAssembly, scriptNamespace);
                }
                catch (Exception e) {
                    Debug.Fail(e.ToString());
                }
            }
        }
예제 #3
0
        private void ImportScriptAssembly(MetadataSource mdSource, string assemblyPath, bool coreAssembly)
        {
            string scriptNamespace = null;
            string scriptName = null;

            AssemblyDefinition assembly;
            if (coreAssembly) {
                assembly = mdSource.CoreAssemblyMetadata;
            }
            else {
                assembly = mdSource.GetMetadata(assemblyPath);
                scriptNamespace = MetadataHelpers.GetScriptNamespace(assembly);
            }

            scriptName = MetadataHelpers.GetScriptAssemblyName(assembly);
            if (String.IsNullOrEmpty(scriptName) == false) {
                _options.AddReferencedDependency(scriptName);
            }

            if (coreAssembly) {
                // Always add an execution reference to the core assembly, since
                // it contains things like the type system, and other APIs assumed by the compiler
                Debug.Assert(String.IsNullOrEmpty(scriptName) == false);
                _options.AddExecutionDependency(scriptName);
            }

            foreach (TypeDefinition type in assembly.MainModule.Types) {
                try {
                    if (MetadataHelpers.IsCompilerGeneratedType(type)) {
                        continue;
                    }

                    ImportType(mdSource, type, coreAssembly, scriptNamespace, scriptName);
                }
                catch (Exception e) {
                    Debug.Fail(e.ToString());
                }
            }
        }