private ProjectPropertyGroup[] GetConfigurations(ProjectPropertyGroup basicProjectProperties) { int i = 0; ProjectPropertyGroup[] configurations = new ProjectPropertyGroup[this.platforms.Count * 2]; foreach (string platform in this.platforms) { if (platform == "Any CPU") { ProjectPropertyGroup configuration; bool isVisualBasic = this.language is VisualBasic; configuration = base.CreateConfiguration("AnyCPU", true); //Debug if (isVisualBasic) { configuration.NoConfig = true; configuration.NoConfigSpecified = true; } configurations[i++] = configuration; configuration = base.CreateConfiguration("AnyCPU", false); //Release if (isVisualBasic) { configuration.NoStdLib = true; configuration.NoStdLibSpecified = true; configuration.NoConfig = true; configuration.NoConfigSpecified = true; } configurations[i++] = configuration; } else { configurations[i++] = this.CreateConfiguration(platform, true); configurations[i++] = this.CreateConfiguration(platform, false); } } return configurations; }
protected override object[] GetProjectItems(ModuleDefinition module, ProjectPropertyGroup basicProjectProperties) { object[] items = null; bool isVisualBasic = this.language is VisualBasic; if (this.projectType == WinRTProjectType.Component || this.projectType == WinRTProjectType.ComponentForWindows) { items = isVisualBasic ? new object[15] : new object[14]; int i = 0; items[i++] = this.GenerateCommonPropsProjectImportProperty(); items[i++] = basicProjectProperties; object[] configurations = this.GetConfigurations(basicProjectProperties); for (int j = 0; j < configurations.Length; j++, i++) { items[j + 2] = configurations[j]; } items[i++] = this.CreatePojectReferences(module, basicProjectProperties); items[i++] = this.fileGenContext.GetProjectItemGroup(); items[i++] = this.GetVisualStudioVersionPropertyGroup(); if (isVisualBasic) { items[i++] = this.GetCompileOptions(); } items[i++] = this.GenerateLanguageTargetsProjectImportProperty(); } else if (this.projectType == WinRTProjectType.ComponentForUniversal) { items = new object[8]; items[0] = this.GenerateCommonPropsProjectImportProperty(); items[1] = basicProjectProperties; object[] configurations = this.GetConfigurations(basicProjectProperties); for (int i = 0; i < configurations.Length; i++) { items[i + 2] = configurations[i]; } items[4] = this.CreatePojectReferences(module, basicProjectProperties); items[5] = new ProjectItemGroup() { TargetPlatform = new ProjectItemGroupTargetPlatform[] { new ProjectItemGroupTargetPlatform() { Include = "WindowsPhoneApp, Version=8.1" }, new ProjectItemGroupTargetPlatform() { Include = "Windows, Version=8.1" } } }; items[6] = this.fileGenContext.GetProjectItemGroup(); items[7] = this.GenerateLanguageTargetsProjectImportProperty(); } else if (this.projectType == WinRTProjectType.ComponentForWindowsPhone) { items = isVisualBasic ? new object[14] : new object[13]; int i = 0; items[i++] = this.GenerateCommonPropsProjectImportProperty(); items[i++] = basicProjectProperties; object[] configurations = this.GetConfigurations(basicProjectProperties); for (int j = 0; j < configurations.Length; j++, i++) { items[j + 2] = configurations[j]; } items[i++] = this.CreatePojectReferences(module, basicProjectProperties); items[i++] = this.fileGenContext.GetProjectItemGroup(); items[i++] = this.GetVisualStudioVersionPropertyGroup(); items[i++] = new ProjectPropertyGroup() { Condition = " '$(TargetPlatformIdentifier)' == '' ", TargetPlatformIdentifier = "WindowsPhoneApp" }; if (isVisualBasic) { items[i++] = this.GetCompileOptions(); } items[i++] = this.GenerateLanguageTargetsProjectImportProperty(); } return items; }
private void AddAdditionalProjectProperties(ProjectPropertyGroup project) { project.ProjectTypeGuids = this.GetProjectTypeGuids(this.assembly.MainModule); project.MinimumVisualStudioVersion = this.GetMinimumVisualStudioVersion(); project.TargetPlatformVersion = this.GetTargetPlatformVersion(); project.TargetFrameworkProfile = this.GetTargetFrameworkProfile(); }
protected virtual object[] GetProjectItems(ModuleDefinition module, ProjectPropertyGroup basicProjectProperties) { bool isVisualBasic = this.language is VisualBasic; object[] items = isVisualBasic ? new object[7] : new object[6]; int i = 0; if (this.visualStudioVersion == VisualStudioVersion.VS2012 || this.visualStudioVersion == VisualStudioVersion.VS2013) { items = new object[items.Length + 1]; items[i++] = GenerateCommonPropsProjectImportProperty(); } items[i++] = basicProjectProperties; items[i++] = CreateConfiguration(basicProjectProperties, true); //Debug items[i++] = CreateConfiguration(basicProjectProperties, false); //Release items[i++] = CreatePojectReferences(module, basicProjectProperties); items[i++] = fileGenContext.GetProjectItemGroup(); if (isVisualBasic) { items[i++] = GetCompileOptions(); } items[i++] = GenerateLanguageTargetsProjectImportProperty(); return items; }
protected object GetCompileOptions() { ProjectPropertyGroup compileOptions = new ProjectPropertyGroup(); compileOptions.OptionExplicit = "On"; compileOptions.OptionCompare = "Binary"; compileOptions.OptionStrict = "Off"; compileOptions.OptionInfer = "On"; return compileOptions; }
protected virtual ProjectPropertyGroup GetNetmoduleBasicProjectProperties(ModuleDefinition module) { if (module.Kind != ModuleKind.NetModule) { throw new Exception("Unexpected type of module."); } ProjectPropertyGroup basicProjectProperties = new ProjectPropertyGroup(); basicProjectProperties.TargetFrameworkVersion = this.GetTargetFrameworkVersion(module); basicProjectProperties.AssemblyName = Utilities.GetNetmoduleName(module); basicProjectProperties.OutputType = GetOutputType(module); basicProjectProperties.Platform = new ProjectPropertyGroupPlatform() { Condition = " '$(Platform)' == '' " }; basicProjectProperties.Platform.Value = Utilities.GetModuleArchitecturePropertyValue(module); basicProjectProperties.Configuration = new ProjectPropertyGroupConfiguration() { Condition = " '$(Configuration)' == '' ", Value = "Debug" }; Guid guid = Guid.NewGuid(); modulesProjectsGuids.Add(module, guid); basicProjectProperties.ProjectGuid = "{" + guid.ToString() + "}"; if (this.visualStudioVersion == VisualStudioVersion.VS2010) { basicProjectProperties.SchemaVersion = (decimal)2.0; //constant in VS 2010 basicProjectProperties.SchemaVersionSpecified = true; //constant in VS 2010roperties.ProjectType //basicProjectProperties.SchemaVersionSpecified //basicProjectProperties.ProductVersion - the version of the project template VS used to create the project file } if (!(this.language is Telerik.JustDecompiler.Languages.VisualBasic.VisualBasic)) { basicProjectProperties.RootNamespace = fileGenContext.NamespacesTree.RootNamespace; } return basicProjectProperties; }
protected virtual ProjectPropertyGroup GetMainModuleBasicProjectProperties() { ProjectPropertyGroup basicProjectProperties = new ProjectPropertyGroup(); basicProjectProperties.TargetFrameworkVersion = GetTargetFrameworkVersion(this.assembly.MainModule); basicProjectProperties.AssemblyName = assembly.Name.Name; basicProjectProperties.OutputType = GetOutputType(this.assembly.MainModule); basicProjectProperties.Platform = new ProjectPropertyGroupPlatform() { Condition = " '$(Platform)' == '' " }; basicProjectProperties.Platform.Value = Utilities.GetModuleArchitecturePropertyValue(assembly.MainModule); basicProjectProperties.Configuration = new ProjectPropertyGroupConfiguration() { Condition = " '$(Configuration)' == '' ", Value = "Debug" }; Guid guid = Guid.NewGuid(); modulesProjectsGuids.Add(assembly.MainModule, guid); basicProjectProperties.ProjectGuid = "{" + guid.ToString() + "}"; if (this.visualStudioVersion == VisualStudioVersion.VS2010) { basicProjectProperties.SchemaVersion = (decimal)2.0; //constant in VS 2010 basicProjectProperties.SchemaVersionSpecified = true; //constant in VS 2010roperties.ProjectType //basicProjectProperties.SchemaVersionSpecified //basicProjectProperties.ProductVersion - the version of the project template VS used to create the project file } // VB compiler injects RootNamespace in all types // so we let it stay in the source code and remove it from the project settings if (!(this.language is Telerik.JustDecompiler.Languages.VisualBasic.VisualBasic)) { basicProjectProperties.RootNamespace = fileGenContext.NamespacesTree.RootNamespace; } return basicProjectProperties; }
protected ProjectPropertyGroup CreateConfiguration(ProjectPropertyGroup basicProjectProperties, bool debugConfiguration) { return this.CreateConfiguration(basicProjectProperties.Platform.Value, debugConfiguration); }
protected virtual ProjectPropertyGroup CreateConfiguration(string platform, bool debugConfiguration) { ProjectPropertyGroup result = new ProjectPropertyGroup(); if (debugConfiguration) { result.Condition = " '$(Configuration)|$(Platform)' == 'Debug|" + platform + "' "; result.DebugSymbols = true; result.DebugType = "full"; result.Optimize = false; result.OutputPath = GetOutputPath(platform, debugConfiguration); } else { result.Condition = " '$(Configuration)|$(Platform)' == 'Release|" + platform + "' "; result.DebugSymbols = false; result.DebugType = "pdbonly"; result.Optimize = true; result.OutputPath = GetOutputPath(platform, debugConfiguration); } string separator = this.language is VisualBasic ? "," : ";"; string defineConstants = string.Join(separator, GetConfigurationConstants(debugConfiguration)); if (defineConstants != string.Empty) { result.DefineConstants = defineConstants; } if (this.language is CSharp) { result.ErrorReport = "prompt"; result.WarningLevel = 4; result.WarningLevelSpecified = true; } else if (this.language is VisualBasic) { result.DefineDebug = debugConfiguration; result.DefineDebugSpecified = true; result.DefineTrace = true; result.DefineTraceSpecified = true; result.DocumentationFile = string.Format("{0}.xml", this.assembly.Name.Name); result.NoWarn = string.Join(",", this.GetWarningConfigurations()); } else { throw new NotSupportedException(); } result.PlatformTarget = platform; result.OptimizeSpecified = true; result.DebugSymbolsSpecified = true; return result; }
protected ProjectItemGroup CreatePojectReferences(ModuleDefinition module, ProjectPropertyGroup basicProjectProperties) { ProjectItemGroup result = new ProjectItemGroup(); ICollection<AssemblyNameReference> dependingOnAssemblies = GetAssembliesDependingOn(module); result.Reference = new ProjectItemGroupReference[dependingOnAssemblies.Count]; string copiedReferencesSubfolder = basicProjectProperties.AssemblyName + "References"; string referencesPath = TargetPath.Remove(TargetPath.LastIndexOf(Path.DirectorySeparatorChar)) + Path.DirectorySeparatorChar + copiedReferencesSubfolder; int assemblyReferenceIndex = 0; foreach (AssemblyNameReference reference in dependingOnAssemblies) { if (reference.Name == "mscorlib" || reference.Name == "Windows" && reference.Version.Equals(new Version(255, 255, 255, 255)) || reference.Name == "System.Runtime") { continue; } AssemblyName assemblyName = new AssemblyName(reference.Name, reference.FullName, reference.Version, reference.PublicKeyToken); string currentReferenceInitialLocation = this.currentAssemblyResolver.FindAssemblyPath(assemblyName, null); AssemblyDefinition referencedAssembly = this.currentAssemblyResolver.Resolve(reference, "", assembly.MainModule.GetModuleArchitecture()); #if NET35 if (!currentReferenceInitialLocation.IsNullOrWhiteSpace()) #else if (!string.IsNullOrWhiteSpace(currentReferenceInitialLocation)) #endif { result.Reference[assemblyReferenceIndex] = new ProjectItemGroupReference(); if (IsInReferenceAssemblies(referencedAssembly)) { //TODO: Consider doing additional check, to see if the assembly is resolved because it was pointed by the used/already in the tree // In this case, it might be better to copy it. result.Reference[assemblyReferenceIndex].Include = reference.Name; } else // Copy the referenced assembly { if (!Directory.Exists(referencesPath)) { Directory.CreateDirectory(referencesPath); } string currentReferenceFileName = Path.GetFileName(currentReferenceInitialLocation); string currentReferenceFinalLocation = Path.Combine(referencesPath, currentReferenceFileName); File.Copy(currentReferenceInitialLocation, currentReferenceFinalLocation, true); // set to normal for testing purposes- to allow the test project to delete the coppied file between test runs File.SetAttributes(currentReferenceFinalLocation, FileAttributes.Normal); string relativePath = Path.Combine(".", copiedReferencesSubfolder); relativePath = Path.Combine(relativePath, currentReferenceFileName); result.Reference[assemblyReferenceIndex].Include = Path.GetFileNameWithoutExtension(currentReferenceFinalLocation); result.Reference[assemblyReferenceIndex].Item = relativePath; } } assemblyReferenceIndex++; } ICollection<ModuleReference> dependingOnModules = GetModulesDependingOn(module); result.AddModules = new ProjectItemGroupAddModules[dependingOnModules.Count * 2]; int moduleReferenceIndex = 0; foreach (ModuleReference moduleRef in dependingOnModules) { result.AddModules[moduleReferenceIndex] = new ProjectItemGroupAddModules(); result.AddModules[moduleReferenceIndex].Include = @"bin\Debug\" + Utilities.GetNetmoduleName(moduleRef) + ".netmodule"; result.AddModules[moduleReferenceIndex].Condition = " '$(Configuration)' == 'Debug' "; moduleReferenceIndex++; result.AddModules[moduleReferenceIndex] = new ProjectItemGroupAddModules(); result.AddModules[moduleReferenceIndex].Include = @"bin\Release\" + Utilities.GetNetmoduleName(moduleRef) + ".netmodule"; result.AddModules[moduleReferenceIndex].Condition = " '$(Configuration)' == 'Release' "; moduleReferenceIndex++; } return result; }
private ProjectPropertyGroup[] GetConfigurations(ProjectPropertyGroup basicProjectProperties) { ProjectPropertyGroup[] configurations = new ProjectPropertyGroup[2]; // Debug + Release configurations[0] = this.CreateConfiguration(basicProjectProperties.Platform.Value, true); configurations[1] = this.CreateConfiguration(basicProjectProperties.Platform.Value, false); return configurations; }
private void AddAdditionalProjectProperties(ProjectPropertyGroup project) { project.ProjectTypeGuids = this.GetProjectTypeGuids(this.assembly.MainModule); project.MinimumVisualStudioVersion = this.GetMinimumVisualStudioVersion(); project.TargetPlatformVersion = this.GetTargetPlatformVersion(); project.TargetFrameworkProfile = this.GetTargetFrameworkProfile(); if (IsUWPProject) { project.TargetPlatformMinVersion = this.minInstalledUAPVersion.ToString(); project.TargetPlatformIdentifier = UAPPlatformIdentifier; } project.AllowCrossPlatformRetargeting = false; project.AllowCrossPlatformRetargetingSpecified = this.projectType == WinRTProjectType.UWPComponent; }
protected override object[] GetProjectItems(ModuleDefinition module, ProjectPropertyGroup basicProjectProperties) { bool shouldAddVisualBasicItems = this.language is IVisualBasic && this.projectType != WinRTProjectType.ComponentForUniversal; object[] items = new object[GetNumberOfProjectItems(shouldAddVisualBasicItems)]; int currentItem = 0; items[currentItem++] = this.GenerateCommonPropsProjectImportProperty(); items[currentItem++] = basicProjectProperties; object[] configurations = this.GetConfigurations(basicProjectProperties); for (int j = 0; j < configurations.Length; j++) { items[currentItem++] = configurations[j]; } items[currentItem++] = this.CreatePojectReferences(module, basicProjectProperties); if (this.projectType == WinRTProjectType.ComponentForUniversal) { items[currentItem++] = new ProjectItemGroup() { TargetPlatform = new ProjectItemGroupTargetPlatform[] { new ProjectItemGroupTargetPlatform() { Include = "WindowsPhoneApp, Version=8.1" }, new ProjectItemGroupTargetPlatform() { Include = "Windows, Version=8.1" } } }; } items[currentItem++] = this.fileGenContext.GetProjectItemGroup(); if (this.projectType != WinRTProjectType.ComponentForUniversal) { items[currentItem++] = this.GetVisualStudioVersionPropertyGroup(); } if (this.projectType == WinRTProjectType.ComponentForWindowsPhone) { items[currentItem++] = new ProjectPropertyGroup() { Condition = " '$(TargetPlatformIdentifier)' == '' ", TargetPlatformIdentifier = "WindowsPhoneApp" }; } if (shouldAddVisualBasicItems) { items[currentItem++] = this.GetCompileOptions(); } items[currentItem++] = this.GenerateLanguageTargetsProjectImportProperty(); return items; }
protected override ProjectItemGroup CreatePojectReferences(ModuleDefinition module, ProjectPropertyGroup basicProjectProperties) { ProjectItemGroup result = base.CreatePojectReferences(module, basicProjectProperties); if (IsUWPProject) { result.None = new ProjectItemGroupNone() { Include = ProjectJsonWriter.ProjectJsonFileName }; } return result; }