예제 #1
0
        protected override void WriteToolTip(ITextColorWriter output, IDecompiler decompiler)
        {
            output.WriteModule(Document.ModuleDef.Name);

            output.WriteLine();
            output.Write(BoxedTextColor.EnumField, TargetFrameworkInfo.Create(Document.ModuleDef).ToString());

            output.WriteLine();
            output.Write(BoxedTextColor.EnumField, TargetFrameworkUtils.GetArchString(Document.ModuleDef));

            output.WriteLine();
            output.WriteFilename(Document.Filename);
        }
예제 #2
0
        protected override void WriteToolTip(ISyntaxHighlightOutput output, ILanguage language)
        {
            output.WriteModule(DnSpyFile.ModuleDef.Name);

            output.WriteLine();
            output.Write(TargetFrameworkInfo.Create(DnSpyFile.ModuleDef).ToString(), TextTokenKind.EnumField);

            output.WriteLine();
            output.Write(TargetFrameworkUtils.GetArchString(DnSpyFile.ModuleDef), TextTokenKind.EnumField);

            output.WriteLine();
            output.WriteFilename(DnSpyFile.Filename);
        }
예제 #3
0
        protected override void WriteToolTip(ITextColorWriter output, ILanguage language)
        {
            output.Write(DnSpyFile.AssemblyDef);

            output.WriteLine();
            output.Write(BoxedTextColor.EnumField, TargetFrameworkInfo.Create(DnSpyFile.AssemblyDef.ManifestModule).ToString());

            output.WriteLine();
            output.Write(BoxedTextColor.EnumField, TargetFrameworkUtils.GetArchString(DnSpyFile.AssemblyDef.ManifestModule));

            output.WriteLine();
            output.WriteFilename(DnSpyFile.Filename);
        }
예제 #4
0
        protected override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options)
        {
            if ((options & DocumentNodeWriteOptions.ToolTip) == 0)
            {
                new NodePrinter().Write(output, decompiler, Document.ModuleDef, false);
            }
            else
            {
                output.WriteModule(Document.ModuleDef.Name);

                output.WriteLine();
                output.Write(BoxedTextColor.Text, TargetFrameworkInfo.Create(Document.ModuleDef).ToString());

                output.WriteLine();
                output.Write(BoxedTextColor.Text, TargetFrameworkUtils.GetArchString(Document.ModuleDef));

                output.WriteLine();
                output.WriteFilename(Document.Filename);
            }
        }
예제 #5
0
        protected override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options)
        {
            if ((options & DocumentNodeWriteOptions.ToolTip) == 0)
            {
                new NodePrinter().Write(output, decompiler, Document.AssemblyDef, false, Context.ShowAssemblyVersion, Context.ShowAssemblyPublicKeyToken);
            }
            else
            {
                output.Write(Document.AssemblyDef);

                output.WriteLine();
                output.Write(BoxedTextColor.Text, TargetFrameworkInfo.Create(Document.AssemblyDef.ManifestModule).ToString());

                output.WriteLine();
                output.Write(BoxedTextColor.Text, TargetFrameworkUtils.GetArchString(Document.AssemblyDef.ManifestModule));

                output.WriteLine();
                output.WriteFilename(Document.Filename);
            }
        }
예제 #6
0
        public void Write()
        {
            project.OnWrite();
            var settings = new XmlWriterSettings {
                Encoding = Encoding.UTF8,
                Indent   = true,
            };

            if (projectVersion == ProjectVersion.VS2005)
            {
                settings.OmitXmlDeclaration = true;
            }
            using (var writer = XmlWriter.Create(project.Filename, settings)) {
                project.Platform = GetPlatformString();

                writer.WriteStartDocument();
                writer.WriteStartElement("Project", "http://schemas.microsoft.com/developer/msbuild/2003");
                var toolsVersion = GetToolsVersion();
                if (toolsVersion != null)
                {
                    writer.WriteAttributeString("ToolsVersion", toolsVersion);
                }
                if (projectVersion <= ProjectVersion.VS2015)
                {
                    writer.WriteAttributeString("DefaultTargets", "Build");
                }
                if (projectVersion >= ProjectVersion.VS2012)
                {
                    writer.WriteStartElement("Import");
                    writer.WriteAttributeString("Project", @"$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props");
                    writer.WriteAttributeString("Condition", @"Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')");
                    writer.WriteEndElement();
                }

                // Default property group
                writer.WriteStartElement("PropertyGroup");

                writer.WriteStartElement("Configuration");
                writer.WriteAttributeString("Condition", " '$(Configuration)' == '' ");
                writer.WriteString("Debug");
                writer.WriteEndElement();

                writer.WriteStartElement("Platform");
                writer.WriteAttributeString("Condition", " '$(Platform)' == '' ");
                writer.WriteString(project.Platform);
                writer.WriteEndElement();

                writer.WriteElementString("ProjectGuid", project.Guid.ToString("B").ToUpperInvariant());
                writer.WriteElementString("OutputType", GetOutputType());
                var appDesignFolder = GetAppDesignerFolder();
                if (appDesignFolder != null)
                {
                    writer.WriteElementString("AppDesignerFolder", appDesignFolder);
                }
                writer.WriteElementString("RootNamespace", GetRootNamespace());
                var asmName = GetAssemblyName();
                if (!string.IsNullOrEmpty(asmName))
                {
                    writer.WriteElementString("AssemblyName", GetAssemblyName());
                }
                var fwkInfo = TargetFrameworkInfo.Create(project.Module);
                if (projectVersion > ProjectVersion.VS2005 || !fwkInfo.IsDotNetFramework || fwkInfo.Version != "2.0")
                {
                    writer.WriteElementString("TargetFrameworkVersion", "v" + fwkInfo.Version);
                }
                if (!string.IsNullOrEmpty(fwkInfo.Profile))
                {
                    writer.WriteElementString("TargetFrameworkProfile", fwkInfo.Profile);
                }
                if (!fwkInfo.IsDotNetFramework)
                {
                    writer.WriteElementString("TargetFrameworkIdentifier", fwkInfo.Framework);
                }
                writer.WriteElementString("FileAlignment", GetFileAlignment());
                if (project.ProjectTypeGuids.Count != 0)
                {
                    var text = string.Join(";", project.ProjectTypeGuids.Select(a => a.ToString("B").ToUpperInvariant()).ToArray());
                    writer.WriteElementString("ProjectTypeGuids", text);
                }
                //TODO: VB includes a "MyType"
                if (project.ApplicationManifest != null)
                {
                    writer.WriteElementString("ApplicationManifest", GetRelativePath(project.ApplicationManifest.Filename));
                }
                if (project.ApplicationIcon != null)
                {
                    writer.WriteElementString("ApplicationIcon", GetRelativePath(project.ApplicationIcon.Filename));
                }
                if (project.StartupObject != null)
                {
                    writer.WriteElementString("StartupObject", project.StartupObject);
                }
                writer.WriteEndElement();

                // Debug property group
                var noWarnList = GetNoWarnList();
                writer.WriteStartElement("PropertyGroup");
                writer.WriteAttributeString("Condition", $" '$(Configuration)|$(Platform)' == 'Debug|{project.Platform}' ");
                writer.WriteElementString("PlatformTarget", project.Platform);
                writer.WriteElementString("DebugSymbols", "true");
                writer.WriteElementString("DebugType", "full");
                writer.WriteElementString("Optimize", "false");
                writer.WriteElementString("OutputPath", @"bin\Debug\");
                writer.WriteElementString("DefineConstants", "DEBUG;TRACE");
                writer.WriteElementString("ErrorReport", "prompt");
                writer.WriteElementString("WarningLevel", "4");
                if (project.Options.DontReferenceStdLib)
                {
                    writer.WriteElementString("NoStdLib", "true");
                }
                if (project.AllowUnsafeBlocks)
                {
                    writer.WriteElementString("AllowUnsafeBlocks", "true");
                }
                if (noWarnList != null)
                {
                    writer.WriteElementString("NoWarn", noWarnList);
                }
                writer.WriteEndElement();

                // Release property group
                writer.WriteStartElement("PropertyGroup");
                writer.WriteAttributeString("Condition", $" '$(Configuration)|$(Platform)' == 'Release|{project.Platform}' ");
                writer.WriteElementString("PlatformTarget", project.Platform);
                writer.WriteElementString("DebugType", "pdbonly");
                writer.WriteElementString("Optimize", "true");
                writer.WriteElementString("OutputPath", @"bin\Release\");
                writer.WriteElementString("DefineConstants", "TRACE");
                writer.WriteElementString("ErrorReport", "prompt");
                writer.WriteElementString("WarningLevel", "4");
                if (project.Options.DontReferenceStdLib)
                {
                    writer.WriteElementString("NoStdLib", "true");
                }
                if (project.AllowUnsafeBlocks)
                {
                    writer.WriteElementString("AllowUnsafeBlocks", "true");
                }
                if (noWarnList != null)
                {
                    writer.WriteElementString("NoWarn", noWarnList);
                }
                writer.WriteEndElement();

                // GAC references
                var gacRefs = project.Module.GetAssemblyRefs().Where(a => a.Name != "mscorlib").OrderBy(a => a.Name.String, StringComparer.OrdinalIgnoreCase).ToArray();
                if (gacRefs.Length > 0 || project.ExtraAssemblyReferences.Count > 0)
                {
                    writer.WriteStartElement("ItemGroup");
                    var hash = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                    foreach (var r in gacRefs)
                    {
                        var asm = project.Module.Context.AssemblyResolver.Resolve(r, project.Module);
                        if (asm != null && ExistsInProject(asm.ManifestModule.Location))
                        {
                            continue;
                        }
                        hash.Add(r.Name);
                        writer.WriteStartElement("Reference");
                        writer.WriteAttributeString("Include", IdentifierEscaper.Escape(r.Name));
                        var hintPath = GetHintPath(asm);
                        if (hintPath != null)
                        {
                            writer.WriteElementString("HintPath", hintPath);
                        }
                        writer.WriteEndElement();
                    }
                    foreach (var r in project.ExtraAssemblyReferences)
                    {
                        if (hash.Contains(r) || AssemblyExistsInProject(r))
                        {
                            continue;
                        }
                        hash.Add(r);
                        writer.WriteStartElement("Reference");
                        writer.WriteAttributeString("Include", IdentifierEscaper.Escape(r));
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }

                writer.WriteStartElement("ItemGroup");
                writer.WriteStartElement("AppDesigner");
                writer.WriteAttributeString("Include", project.PropertiesFolder + "\\");
                writer.WriteEndElement();
                writer.WriteEndElement();

                Write(writer, BuildAction.Compile);
                Write(writer, BuildAction.EmbeddedResource);

                // Project references
                var projRefs = project.Module.GetAssemblyRefs().
                               Select(a => project.Module.Context.AssemblyResolver.Resolve(a, project.Module)).
                               Select(a => a == null ? null : FindOtherProject(a.ManifestModule.Location)).
                               Where(a => a != null).OrderBy(a => a.Filename, StringComparer.OrdinalIgnoreCase).ToArray();
                if (projRefs.Length > 0)
                {
                    writer.WriteStartElement("ItemGroup");
                    foreach (var otherProj in projRefs)
                    {
                        writer.WriteStartElement("ProjectReference");
                        writer.WriteAttributeString("Include", GetRelativePath(otherProj.Filename));
                        writer.WriteStartElement("Project");
                        var guidString = otherProj.Guid.ToString("B");
                        if (projectVersion < ProjectVersion.VS2012)
                        {
                            guidString = guidString.ToUpperInvariant();
                        }
                        writer.WriteString(guidString);
                        writer.WriteEndElement();
                        writer.WriteStartElement("Name");
                        writer.WriteString(IdentifierEscaper.Escape(otherProj.Module.Assembly == null ? string.Empty : otherProj.Module.Assembly.Name.String));
                        writer.WriteEndElement();
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }

                Write(writer, BuildAction.None);
                Write(writer, BuildAction.ApplicationDefinition);
                Write(writer, BuildAction.Page);
                Write(writer, BuildAction.Resource);
                Write(writer, BuildAction.SplashScreen);

                writer.WriteStartElement("Import");
                writer.WriteAttributeString("Project", GetLanguageTargets());
                writer.WriteEndElement();

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
        }