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); }
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); }
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 }); }
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); } }
/// <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('/', '\\') }); }
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); }
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); }
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); } }
//List<Token> Tokens; public ZFileEngine(ContextProject projectContext) { //this.fileModel = fileModel; this.projectContext = projectContext; }
public ZFileEngine(ContextProject projectContext) { this.projectContext = projectContext; }