示例#1
0
        public ProjectCompileResult Compile(ZProjectModel zCompileProjectModel)
        {
            this.projectModel = zCompileProjectModel;
            //result = new ProjectCompileResult();
            projectContext = new ContextProject(projectModel);
            //projectContext.ProjectModel = projectModel;
            LoadProjectRef();
            CompileUtil.GenerateBinary(projectContext);

            ParseFiles();

            CompileEnum();
            AnalyImportUse();
            AnalyDimAndClassName();
            EmitDimAndClassName();

            CompileFileDim();
            CompileClass();

            //result.CompiledTypes.AddRange(this.projectContext.GeneratedTypeManager.EmitedZDescTypeDictionary.Values);
            SetEntry();
            if (zCompileProjectModel.NeedSave)
            {
                SaveBinary();
            }

            return(projectContext.CompileResult);
        }
示例#2
0
        public static void GenerateBinary(ContextProject projectContext)
        {
            string binFileName        = projectContext.ProjectModel.GetBinaryNameEx();
            string projectPackageName = projectContext.ProjectModel.ProjectPackageName;

            projectContext.CreateProjectEmitContext(AppDomain.CurrentDomain, projectPackageName, projectPackageName, binFileName);
            setAttr(projectContext.EmitContext.AssemblyBuilder, projectContext);
        }
示例#3
0
 public ZProjectEngine(CompileMessageCollection cmc, SourceProjectModel zCompileProjectModel)
 {
     MessageCollection        = cmc;
     this.projectModel        = zCompileProjectModel;
     result                   = new ProjectCompileResult();
     result.MessageCollection = MessageCollection;
     ProjectContext           = new ContextProject(zCompileProjectModel, MessageCollection);
 }
        public virtual ToolingFacade GetFacade(string configurationTypeName = null, bool useContextWorkingDirectory = false)
        {
            if (configurationTypeName == null)
            {
                configurationTypeName = (string)Domain.GetData("configurationTypeName");
            }

            var connectionStringName              = (string)Domain.GetData("connectionStringName");
            var connectionString                  = (string)Domain.GetData("connectionString");
            var connectionProviderName            = (string)Domain.GetData("connectionProviderName");
            DbConnectionInfo connectionStringInfo = null;

            if (!string.IsNullOrWhiteSpace(connectionStringName))
            {
                connectionStringInfo = new DbConnectionInfo(connectionStringName);
            }
            else if (!string.IsNullOrWhiteSpace(connectionString))
            {
                connectionStringInfo = new DbConnectionInfo(connectionString, connectionProviderName);
            }

            var startUpProject      = StartUpProject;
            var assemblyName        = Project.GetTargetName();
            var contextAssemblyName = ContextProject.GetTargetName();
            var workingDirectory    = useContextWorkingDirectory ? ContextProject.GetTargetDir() : Project.GetTargetDir();

            string configurationFile;
            string dataDirectory = null;

            if (startUpProject.IsWebProject())
            {
                var startUpProjectDir = startUpProject.GetProjectDir();

                configurationFile = startUpProject.GetFileName("Web.config");
                dataDirectory     = Path.Combine(startUpProjectDir, "App_Data");
            }
            else
            {
                configurationFile = startUpProject.GetFileName("App.config");
            }

            return(new ToolingFacade(
                       assemblyName,
                       contextAssemblyName,
                       configurationTypeName,
                       workingDirectory,
                       configurationFile,
                       dataDirectory,
                       connectionStringInfo)
            {
                LogInfoDelegate = WriteLine,
                LogWarningDelegate = WriteWarning,
                LogVerboseDelegate = WriteVerbose
            });
        }
示例#5
0
        public static void DeletePDB(ContextProject projectContext)
        {
            string folder       = AppDomain.CurrentDomain.BaseDirectory;
            string fileNameNoEx = projectContext.ProjectModel.BinaryFileNameNoEx;
            string pdbfile      = Path.Combine(folder, fileNameNoEx + ".pdb");

            if (File.Exists(pdbfile))
            {
                File.Delete(pdbfile);
            }
        }
示例#6
0
 /// <summary>
 /// Creates a copy if the ID that has all paths in normal form with '\' slashes instead of '/'.
 /// Note: this is needed to switch back to normal IDs for graph nodes, since graph provider nodes
 /// switch paths in their IDs to uri style with '/'.
 /// </summary>
 /// <returns></returns>
 public DependencyNodeId ToNormalizedId()
 {
     return(new DependencyNodeId(ProviderType,
                                 ItemSpec?.Replace('/', '\\'),
                                 ItemType,
                                 UniqueToken?.Replace('/', '\\'))
     {
         ContextProject = string.IsNullOrEmpty(ContextProject)
                             ? string.Empty
                             : ContextProject.Replace('/', '\\')
     });
 }
示例#7
0
        public static void GenerateBinary(ContextProject context)
        {
            string binFileName        = context.GetBinaryNameEx();
            string projectPackageName = context.ProjectModel.ProjectPackageName;

            //var assemblyName = new AssemblyName(projectPackageName);
            //AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave);
            //var moduleBuilder = assemblyBuilder.DefineDynamicModule(projectPackageName, binFileName, true);
            //context.EmitContext.AssemblyName = assemblyName;
            //context.EmitContext.AssemblyBuilder = assemblyBuilder;
            //context.EmitContext.ModuleBuilder = moduleBuilder;

            context.CreateProjectEmitContext(AppDomain.CurrentDomain, projectPackageName, projectPackageName, binFileName);
            setAttr(context.EmitContext.AssemblyBuilder, context);
        }
示例#8
0
        public static void MoveBinary(ContextProject projectContext)
        {
            string exBinFileName    = projectContext.GetBinaryNameEx();
            string fromFileFullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, exBinFileName);
            string toFileFullPath   = Path.Combine(projectContext.ProjectModel.BinarySaveDirectoryInfo.FullName, exBinFileName);

            if (File.Exists(toFileFullPath))
            {
                File.Delete(toFileFullPath);
            }
            if (File.Exists(fromFileFullPath) && fromFileFullPath != toFileFullPath)
            {
                File.Move(fromFileFullPath, toFileFullPath);
                File.Delete(fromFileFullPath);
            }
            CompileUtil.DeletePDB(projectContext);
        }
示例#9
0
 private static void setAttr(AssemblyBuilder builder, ContextProject context)
 {
     {
         Type                   myType           = typeof(AssemblyVersionAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(string) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { "0.4.0" });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(DebuggableAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(DebuggableAttribute.DebuggingModes) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(AssemblyCompanyAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(string) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { "Z语言" });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(AssemblyConfigurationAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(string) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { "" });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(AssemblyCopyrightAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(string) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { "Copyright ©  " + DateTime.Now.Year });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(AssemblyDescriptionAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(string) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { "" });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(AssemblyFileVersionAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(string) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { "" });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(AssemblyProductAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(string) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { context.ProjectModel.ProjectPackageName });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(AssemblyTitleAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(string) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { context.ProjectModel.ProjectPackageName });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(AssemblyTrademarkAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(string) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { "" });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(CompilationRelaxationsAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(int) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { 8 });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(RuntimeCompatibilityAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(ComVisibleAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(bool) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { false });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(GuidAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(string) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { Guid.NewGuid().ToString() });
         builder.SetCustomAttribute(attributeBuilder);
     }
     {
         Type                   myType           = typeof(TargetFrameworkAttribute);
         ConstructorInfo        infoConstructor  = myType.GetConstructor(new Type[] { typeof(string) });
         CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(infoConstructor, new object[] { ".NETFramework,Version=v4.0" });
         builder.SetCustomAttribute(attributeBuilder);
     }
 }
示例#10
0
        //List<Token> Tokens;

        public ZFileEngine(ContextProject projectContext)
        {
            //this.fileModel = fileModel;
            this.projectContext = projectContext;
        }
示例#11
0
 public ZFileEngine(ContextProject projectContext)
 {
     this.projectContext = projectContext;
 }